是否可以在所有eslint规则上显示警告而不是错误?

nri*_*ion 6 reactjs eslint react-native standardjs eslintrc

如标题所述,eslint是否有可能在所有规则上显示警告而不是错误?如果该信息相关,我正在使用Standard JS。

谢谢!

Mic*_*Mic 21

遵循es-lint-plugin-prettier readme,编辑您的.eslintrc.json并为以下内容添加特定规则prettier

"rules": {
  // maybe your other rules...

  "prettier/prettier": "warn"
}
Run Code Online (Sandbox Code Playgroud)

然后,prettier规则将作为警告而不是错误发出。

不知道的所有的副作用,但它似乎工作确定为我的项目,在这里我也用@typescript-eslint/eslint-plugin@typescript-eslint/parsereslint-config-prettiereslint-plugin-prettier

如果有帮助,我的extends配置.eslintrc.json

"extends": [
  "eslint:recommended",
  "plugin:@typescript-eslint/eslint-recommended",
  "plugin:@typescript-eslint/recommended",
  "prettier/@typescript-eslint",
  "plugin:prettier/recommended"
],
Run Code Online (Sandbox Code Playgroud)


Way*_*rex 10

我认为目前没有开箱即用的选项,但也许您可以使用插件来归档Eslint插件仅警告

或将所有规则设置为警告而不是错误。

  • 当我尝试时,我可以确认它可以与“eslint:7.2.0”一起使用。感谢主给了这些插件制作者。它立即让我充满了岩浆温度的愤怒!当遇到复杂的错误时,一切都会失败,因为行尾有空格或者您的导入之一尚未使用。它磨我的齿轮!:D (4认同)
  • 不幸的是,这似乎不适用于最新版本的 eslint (v6)。不过,它对于 v5 来说效果很好。 (2认同)
  • 相反的插件也存在:[eslint-plugin-only-error](https://github.com/davidjbradshaw/eslint-plugin-only-error)。 (2认同)