Eslint disable all rules for one line

29 views Asked by At

I have integrated eslint in my JS project, and I get one error for class attributes. For example, in this case:

class RateLimit {
  delay = 2 * 1000;
  ...
}

I am getting "Parsing error: Unexpected token =". Here is my eslint config:

module.exports = {
  "env": {
    "node": true,
    "es2017": true
  },
  "extends": [
    "eslint:recommended",
    "prettier"
  ],
  "parserOptions": {
    "ecmaVersion": 12,
    "sourceType": "module"
  },
  "rules": {
    "no-unused-vars": [ 2, { "args": "all", "argsIgnorePattern": "_$" } ],
    "semi": [ "error", "always" ],
    "no-undef": "error",
    "indent": [ "error", 2 ],
    "quotes": [ "error", "double" ],
    "arrow-parens": [ "error", "always" ],
    "no-extra-semi": "error",
    "no-magic-numbers": [ "warn", { ignore: [ -1, 0, 1 ] } ],
    "eqeqeq": [ "warn", "always" ],
    "comma-spacing": [ "error", { before: false, after: true } ],
    "array-bracket-spacing": [ "error", "always" ],
    "object-curly-spacing": [ "error", "always" ],
    "no-debugger":"off",
    "no-multiple-empty-lines": [ "error", { max: 1 } ]
  },
};

I'd like to know what is the correct key I can add to the rules object, or how I can disable that line only for all rules?

I have tried adding

/* eslint-disable-next-line */ 

and

// eslint-disable-next-line no-unexpected-token 

but none of those worked.

1

There are 1 answers

0
Lilit Mazmanyan On

I could fix the error by changing the ECMA version to 2022 in parser options