vscode 安装eslint插件
配置自己的规则 文件–》首选项-》设置
"eslint.autoFixOnSave": true,
"eslint.options": {
"configFile": "D:/................/.eslintrc.json"
},
"eslint.run": "onSave",
"eslint.validate": [
"javascript",
"javascriptreact",
{
"language": "vue",
"autoFix": true
},
{
"language": "html",
"autoFix": true
}
],
configFile为配置文件路径,
文件名称.eslintrc.json
我的配置
// http://eslint.org/docs/user-guide/configuring
module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
env: {
browser: true,
"node": true,
"es6": true
},
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
extends: 'standard',
// required to lint *.vue files
plugins: [
// 'vuefix',
'html'
],
// add your custom rules here
'rules': {
"no-undef":1,
"no-new": 1,//禁止在使用new构造一个实例后不赋
"no-tabs":0,
"indent":1,
"no-mixed-spaces-and-tabs": [0, false],//禁止混用tab和空格
"camelcase": 0,//驼峰法命名
"eqeqeq": 0,//全等
// "indent": ["error", 4, {"SwitchCase": 1}],
// allow paren-less arrow functions
'arrow-parens': 0,
// allow async-await
'generator-star-spacing': 0,
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
}
}
更详细的配置查看中文文档:http://eslint.cn/docs/rules/


最新评论
这小生活不错呀
不错,必须顶一下!
看着你还在坚持,很好
看来忙了也没时间更新博客了
NIce。学习了。。。。
网站不错!!!!
简洁实用,好文章!
不错,过来支持一下