How to disable eslint eqeqeq?
Asked Answered
B

6

5

I use create-react-app and just want to add rules to my package.json. I see that I can disable this rule, but how? In the official document, only the phrase "If you don't want to enforce a style for using equality operators, then it's safe to disable this rule."

https://github.com/eslint/eslint/blob/master/docs/rules/eqeqeq.md#when-not-to-use-it

I found that i can write this:

// package.json
{
  "name": "mypackage",
  ...,
  "eslintConfig": {
    "rules": {
      "eqeqeq": "off"
    }
  }
}

but it not works.

I would like to clarify the question. The reason for my question here is not that I don't know how to disable the rule, I do not know how to disable it in the package.json. I just don't want to clutter up the project's root directory with an additional file.

Bumbling answered 30/12, 2019 at 11:21 Comment(2)
"eslintConfig": { "extends": [ "react-app", "react-app/jest" ], "rules": { "eqeqeq": "off" } }, works perfectly fine for meAnsley
I have same error. Can you resolve it?Am‚lie
M
4
{
  "root": true,
  "ignorePatterns": [
    "projects/**/*"
  ],
  "overrides": [
    {
      "files": [
        "*.ts"
      ],
      "parserOptions": {
        "project": [
          "tsconfig.json",
          "e2e/tsconfig.json"
        ],
        "createDefaultProgram": true
      },
      "extends": [
        "plugin:@angular-eslint/recommended",
        "plugin:@angular-eslint/template/process-inline-templates"
      ],
      "rules": {
        "@angular-eslint/directive-selector": [
          "error",
          {
            "type": "attribute",
            "prefix": "app",
            "style": "camelCase"
          }
        ],
        "@angular-eslint/component-selector": [
          "error",
          {
            "type": "element",
            "prefix": "app",
            "style": "kebab-case"
          }
        ]
      }
    },
    {
      "files": [
        "*.html"
      ],
      "extends": [
        "plugin:@angular-eslint/template/recommended"
      ],
      "rules": {
        "@angular-eslint/template/eqeqeq": "off"
    }
    }
  ]
}

Look at the last rule

Now as how to turn it to "smart" rather than "off" I'm yet to figure that out.

** Notice how its in the "files": [.html] or "files": [.ts]. I put mine in the .html rules because my errors were in html files but if they were in a ts file I'd put the rule there instead.

EDIT 1: I found this website useful https://github.com/nrwl/nx-examples/blob/master/.eslintrc.json

Moonraker answered 13/1, 2022 at 4:9 Comment(1)
NOTE: The answer you choose depends on what you are linting and where it gets invoked e.g. html files VIA ng lint (linting templates through angular) @Moonraker - Thank you for the angular variation...Forjudge
L
4

Go to the root directory of your project (where the package.json file is located) and create a file named .eslintrc.json

Inside this add the following:

{
  "rules": {
    "eqeqeq": "off"
  }
}

Then relaunch the app and the rule should be disabled.

Lianaliane answered 12/8, 2022 at 13:39 Comment(0)
H
1

you can add an eslint configuration file .eslintrc and disable the rules you want inside it.

docs

Harwood answered 30/12, 2019 at 12:0 Comment(0)
A
-1

You may locate the eslint configuration file, and change eqeqeq rule to off:

eqeqeq: 'off',

Also, make sure that you don't override the setting farther.

Accursed answered 14/11, 2020 at 11:24 Comment(2)
Thanks, but this is not a suitable solution to the question. I met information that you can not create a separate configuration fileBumbling
I think @Bumbling is right. you cannot create a separate config file for thisHyperventilation
E
-1

Go to .eslintrc.js then add

rules: {
  eqeqeq: 'off',
},
Endocranium answered 29/4, 2022 at 5:48 Comment(0)
P
-1

At the top of the file you intend to disable the rule for, add

/* eslint eqeqeq: "off" */

This will turn off the eqeqeq rule for the file.

Pinup answered 17/8 at 12:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.