How can I turn off ESLint’s no-restricted-syntax rule just for ForOfStatement?

Check existing config

Based on the current master branch, eslint-config-airbnb currently disables four syntax forms:

  1. ForInStatement
  2. ForOfStatement
  3. LabeledStatement
  4. WithStatement

You can verify this or see if there are any differences by using ESLint’s --print-config CLI flag:

$ eslint --print-config file.js

ESLint will print out the config it would use to lint file.js, and you can find the config for the no-restricted-syntax rule there.

Override no-restricted-syntax

If you want to override Airbnb’s preset, you can do so in the rules section of your .eslintrc.json file:

{
    "rules": {
        "no-restricted-syntax": ["error", "ForInStatement", "LabeledStatement", "WithStatement"]
    }
}

There’s no way to configure the rule to use the no-restricted-syntax config inherited from Airbnb’s preset excepting only a single syntax form.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)