1. package.json增加:
"scripts": {
"lint":"eslint --ext .js,.vue src test/unit/specs test/e2e/specs",
},
"devDependencies": {
"babel-eslint":"^7.1.1",
"eslint":"^3.19.0",
"eslint-config-standard":"^10.2.1",
"eslint-friendly-formatter":"^3.0.0",
"eslint-loader":"^1.7.1",
"eslint-plugin-html":"^3.0.0",
"eslint-plugin-import":"^2.7.0",
"eslint-plugin-node":"^5.2.0",
"eslint-plugin-promise":"^3.4.0",
"eslint-plugin-standard":"^3.0.1",
},
2. npm install 地球人都懂得
3. 根目录增加.eslintrc.js文件
// https://eslint.org/docs/user-guide/configuring
module.exports={
root:true,
parser:'babel-eslint',
parserOptions:{
sourceType:'module'
},
env:{
browser:true,
},
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
extends:'standard',
// required to lint *.vue files
plugins:[
'html'
],
// add your custom rules here
rules:{
// allow async-await
'generator-star-spacing':'off',
// allow debugger during development
'no-debugger':process.env.NODE_ENV==='production'?'error':'off'
}
}
4. 根目录创建.eslintignore
/build/
/config/
/dist/
/*.js
/test/unit/coverage/
5.切记不要忘了最后一步vscode 首选项->设置中 eslint.validate中增加html和vue