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!
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!
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.
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!! :D –
Kimono 7.32.0
–
Incumber 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"
],
"prettier/prettier": process.env.NODE_ENV === "production" ? "error" : "warn"
to warn in dev, but fail in production :) –
Varietal If you're only interested in VSCode output, you can achieve this with a single setting:
"eslint.rules.customizations": [
{ "rule": "*", "severity": "warn" }
]
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.
Install eslint-plugin-only-warn
https://www.npmjs.com/package/eslint-plugin-only-warn
"plugins": [
"only-warn",
...
],
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"
)
© 2022 - 2024 — McMap. All rights reserved.