【发布时间】:2020-05-17 01:15:27
【问题描述】:
似乎所有 eslint 规则的默认错误级别都是"error"。这很烦人,因为即使省略了分号,我的应用程序也无法编译。
如何将其设置为 "warn" 以便我的应用编译但显示警告?
我知道我可以将每个规则设置为手动警告,但我更愿意在全局范围内进行。在官方文档中我没有找到这样的选项。
这是我在.eslingtrc.js 中的配置:
// http://eslint.org/docs/user-guide/configuring
module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
env: {
browser: true,
},
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
extends: 'standard',
// required to lint *.vue files
plugins: [
'html'
],
// add your custom rules here
'rules': {
// allow paren-less arrow functions
'arrow-parens': 0,
'indent': 1,
// allow async-await
'generator-star-spacing': 0,
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'padded-blocks': [1, {classes: 'always'}],
'semi': 1
}
}
【问题讨论】:
-
我也想知道这个。我讨厌 webstorm 中的所有红色波浪线,但我确实想注意不良 linting
-
最后我们保留了错误。我们意识到这样我们的代码始终处于良好状态,并且不会引入技术债务(即静态代码分析带来的债务)。
-
如果不逐个检查每个错误,就无法全局执行...
-
我认为目前还不可能。这里有一个关于它的讨论 - github.com/eslint/eslint/issues/10438
标签: eslint