sun*_*ong 5 node.js eslint visual-studio-code
我试图在VS代码中为我的eslint关闭lint警告.
我的代码包含.
console.log('blabla..');
Run Code Online (Sandbox Code Playgroud)
eslint如下所述.
error Unexpected console statement no-console
Run Code Online (Sandbox Code Playgroud)
即使已经在我的.eslintrc.json中添加了无限制语法,也没有修复.
这是我的.eslintrc.json
{
"env": {
"es6": true,
"node": true,
"amd": true,
"mocha": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module"
},
"rules": {
"linebreak-style": [
"error",
"windows"
],
"no-restricted-syntax": [
"error",
{
"selector": "CallExpression[callee.object.name='console'][callee.property.name=/^(log|warn|error|info|trace)$/]",
"message": "Unexpected property on console object was called"
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
我弄错了什么?
允许console.log
留在代码中需要单独的规则.您需要在规则中添加"no-console"语句.
像这样:
rules: {
"no-console": 0
}
Run Code Online (Sandbox Code Playgroud)
更好的做法是警告eslint config rules
您代码中的所有内容,如下所示:
rules: {
"no-console": 1
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4027 次 |
最近记录: |