1、.eslintrc.js
文件配置
module.exports = {
root: true,
env: {
node: true,
jquery: true
},
extends: ['plugin:vue/essential', '@vue/prettier'],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'prettier/prettier': [
'error',
{
tabWidth: 2,
useTabs: false,
semi: false,
singleQuote: true,
trailingComma: 'none',
bracketSpacing: true,
jsxBracketSameLine: true,
arrowParens: 'always',
printWidth: 200
}
]
},
parserOptions: {
parser: 'babel-eslint'
},
globals: {
$App: true
}
}
2、setting.json
文件配置
{
"jshint.enable": false,
"files.associations": {
"*.vue": "vue"
},
"eslint.validate": [
"javascript",
"html",
"javascriptreact",
{
"language": "vue",
"autoFix": true
}
],
"prettier.printWidth": 180,
"prettier.singleQuote": true,
"prettier.semi": false,
"prettier.eslintIntegration": true, // 让prettier使用eslint的代码格式进行校验
"eslint.autoFixOnSave": true, // 保存时eslint自动修复错误
"editor.formatOnSave": true // 保存自动格式化
}
网友评论