vue cli版本 3.0
安装 @vue/cli-plugin-eslint
vue add eslint
安装好了之后我们发现项目中被自动创建了.eslintrc.js文件
package.json文件的script模块中自动加入了lint命令
修改lint命令来满足实际项目需求
"lint": "vue-cli-service lint test src --ext .js,.vue",
修改.eslintrc.js来满足项目需求
module.exports = {
root: true,
env: {
node: true
},
extends: ["plugin:vue/essential", "eslint:recommended", "@vue/prettier"],
parserOptions: {
parser: "babel-eslint"
},
rules: {
'standard/array-bracket-even-spacing': 'off',
'vue/no-unused-components': 'off',
'vue/valid-v-bind': 'off',
'no-undef': 'off',
'no-debugger': 'off',
'spaced-comment': 'off',
'no-console': 'off',
'vue/no-parsing-error': 'off',
'vue/no-use-v-if-with-v-for': 'off',
'eqeqeq': 'off',
'no-control-regex': 'off',
'no-cond-assign': 'off',
'prefer-promise-reject-errors': 'off',
'no-unused-expressions': 'off',
'camelcase': 'off',
'no-new': 'off',
'standard/no-callback-literal': 'off',
'no-unreachable': 'off',
'no-unused-vars': 'off',
'vue/no-unused-vars': 'off',
'no-proto': 'off',
'vue/require-v-for-key': 'off',
'no-irregular-whitespace': 'off',
'no-empty': 'off'
}
};
执行npm run lint 就可以检查代码了