Is it possible to show warnings instead of errors on ALL of eslint rules?
Asked Answered
E

6

94

As the title says, would it be possible for eslint to show warnings instead of errors on ALL of the rules? I'm using Standard JS, if that information is relevant.

Thanks!

Evvoia answered 5/6, 2018 at 17:9 Comment(2)
Do you want to just show warnings and suppress the errors? Or do you want the errors to be treated as warnings and shown as such?Jen
I want the errors to be treated as warnings and shown as such.Evvoia
D
64

I think there's no out-of-the-box option right now, but maybe you could use a plugin to achieve that: Eslint plugin only warn

Or set all the rules as warning instead of errors.

Dilution answered 5/6, 2018 at 17:53 Comment(7)
Unfortunately this seems to not work with the newest version of eslint (v6). It works well for v5, though.Karoline
I can confirm it works with eslint: 7.2.0, when i tried. Thank the lord for these plugin makers. It fills me with immediate magma temperature RAGE! When in the middle of a complex bug and everything fails because there's a space at the end of the line or one of your imports has not yet been used. It grinds my gears!! :DKimono
The opposite plugin also exists: eslint-plugin-only-error.Centurial
Works perfect with 7.32.0Incumber
The only issue with eslint-plugin-only-warn is that actual errors like undefined variables appear as warnings, and it's not possible to change thatPore
@Jasper it's possible to allow some errors with this fork: github.com/aminya/eslint-plugin-only-warnStevenson
Works great. I always prefer to use this package.Sideband
P
54

Following es-lint-plugin-prettier readme, edit your .eslintrc.json and put a specific rule for prettier:

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

  "prettier/prettier": "warn"
}

Then, prettier rules will be issued as warnings instead of errors.

Not sure of all the side effects, but it seems to work ok for my project, where I also use @typescript-eslint/eslint-plugin, @typescript-eslint/parser, eslint-config-prettier and eslint-plugin-prettier.

If it helps, my extends config in .eslintrc.json:

"extends": [
  "eslint:recommended",
  "plugin:@typescript-eslint/eslint-recommended",
  "plugin:@typescript-eslint/recommended",
  "prettier/@typescript-eslint",
  "plugin:prettier/recommended"
],
Paracasein answered 16/1, 2020 at 12:13 Comment(3)
This answer is great if you're using prettier & eslint (I am), though not sure the OP is.Incumber
Exactly what I was after!Bludgeon
Or use "prettier/prettier": process.env.NODE_ENV === "production" ? "error" : "warn" to warn in dev, but fail in production :)Varietal
D
5

If you're only interested in VSCode output, you can achieve this with a single setting:

"eslint.rules.customizations": [
  { "rule": "*", "severity": "warn" }
]
Doby answered 24/10, 2023 at 13:17 Comment(1)
Thanks! This exactly helped for my case: All eslint errors are now yellow underlined as warning. What I was missing is that this is a rule for VSCode settings.json (but not for .eslintrc) so I wanted to point that out here again.Impend
E
1

What I did was overwrite the rules that I want to only show warnings. You can do it in .eslitrc.cjs. Here is what I have in mine:

module.exports = {
  root: true,
  env: { browser: true, es2020: true },
  extends: [
    'eslint:recommended',
    'plugin:react/recommended',
    'plugin:react/jsx-runtime',
    'plugin:react-hooks/recommended',
  ],
  ignorePatterns: ['dist', '.eslintrc.cjs'],
  parserOptions: { ecmaVersion: 'latest', sourceType: 'module', parser: "@babel/eslint-parser" },
  settings: { react: { version: '18.2' } },
  plugins: ['react-refresh'],
  rules: {
    'react-refresh/only-export-components': [
      'warn',
      { allowConstantExport: true },
    ],
    'no-unused-vars':['warn'],
    'react/jsx-key':['warn'],
    'react/no-unescaped-entities':['warn'],
    'react/prop-types':['warn'],
    'no-undef':['warn']
  },
}

For any problem that comes up as an error that is constantly in your way, you can just add it to the rules here to overwrite it. Then you can continue coding and deal with the problems at your leisure.

Emphatic answered 23/1 at 19:0 Comment(0)
S
0

Install eslint-plugin-only-warn

https://www.npmjs.com/package/eslint-plugin-only-warn

  "plugins": [
    "only-warn", 
    ...
  ],

Sideband answered 7/8 at 6:38 Comment(0)
J
-2

You can create an .eslintrc file with all the rules set to "warn"

If you already have an eslintrc file you can use that, or extend from a rules file such as the one here. In this one, all the rules are set to 0 (disabled). You can modify specific ones or all of them and set them to 1 (or "warn")

Jen answered 5/6, 2018 at 17:52 Comment(1)
this is very tediousEvvoia

© 2022 - 2024 — McMap. All rights reserved.