Skip to content Skip to sidebar Skip to footer

Eslint - Require Let Or Const Instead Of Var (no-var)

How to disable the rule of discouraging the use of var and encouraging the use of const or let instead on ESlint?

Solution 1:

In your package.json (assuming that is what you are using), include:

"eslintConfig": {
    "rules": {
        "no-var": 0
    }
}

no-var is the rule, and 0sets the rule to "off".

If you're not using package.json, you can set the the same in an .eslintrc.js, or, on a per-file basis, include a comment at the top of the file /* eslint no-var: 0 */.

All this comes from the ESlint Configuration Documentation.

Solution 2:

Extending the previous answer, all of these variants work for comments at the beginning of the block:

/* eslint no-var: off */
...

/* eslint no-var: */
...

/* eslint no-var: 0 */
...

Post a Comment for "Eslint - Require Let Or Const Instead Of Var (no-var)"