1、全局安装eslint
npm install eslint -g
2、vscode安装eslint插件
3、在vscode的设置中,搜索eslint
4、在vscode的settings.json文件中,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
5、eslint的rules
rules: {
// allow async-await
'no-console': 'off',
indent: ['error', 2, { SwitchCase: 1 }],
// 是否分号
semi: ['error', 'always'],
'space-before-function-paren': [
'error',
{ anonymous: 'always', named: 'never' }
],
'generator-star-spacing': 'off',
// // allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'import/no-absolute-path': 'off',
'new-cap': 'warn',
'node/handle-callback-err': 'warn',
'no-empty': 'warn',
'vue/no-mutating-props': 'off',
'prefer-regex-literals': 'off'
}