How to turn off ESLint rule via config file or via javascript

Turn off ESLint rules

Turn off ESLint rules

ESLint is fully configurable, so you are able to turn off linting rules.
There are two ways for disabling rules: you can tell ESLint to do this from a Javascript comment or from a configuration file.

How to turn off an ESLint rule from the .eslintrc config file

To disable specific rules from the .eslintrc file you have to add a “rules” section. For example, if you want to turn the no-varoff, you have to add to the .eslintrc file the following lines

How to disable ESLint on a specific line for a specific rule with a Javascript comment

You can disable ESLint on a specific line of a file

If you don’t like having the comment on the same line you can disable ESLint for the next line, this way

And you can disable only a specific rule on the line.
Here we disable the no-alert rule.

How to disable ESLint for a whole file with a Javascript comment

You can disable ESLint for a whole file by using the following Javascript comment

You can then re-enable ESlint with

This method is usefull also to disable linting on a piece of code, like:

References

You can find further details here: https://eslint.org/docs/user-guide/configuring#configuring-rules