Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

216
Views
Combining ESLint rules during an override

I am working on a project which has a mix of TypeScript and JavaScript files and I am trying to setup linting rules for them. I am using ESLint to lint the JS files and the typescript eslint plugin to lint the typescript files. Since the codebase I am adding linting to is fairly large I had to turn off a few rules for both JS and TS. This proved to be a little problematic when I tried to create the configuration file for ESLint. In my configuration file. I had the main set of rules for the JS files and then created an override section for *.ts files where I can use the typescript lint rules. My config file looks something like below (The rules section is just representational).

{
    "extends": "eslint:recommended",
    "rules": {
        "no-unused-vars": "off",
        "no-undef": "error",
        "max-classes-per-file": "off"
    },
    "env": {
        "es6": true,
        "browser": true
    },
    "parserOptions": {
        "ecmaVersion": 10
    },
    "overrides": [
        {
            "files": [
                "*.ts"
            ],
            "extends": [
                "eslint:recommended",
                "plugin:@typescript-eslint/recommended"
            ],
            "rules": {
                "@typescript-eslint/no-unsafe-argument": "off",
                "@typescript-eslint/no-unsafe-member-access": "off"
            },
            "parserOptions": {
                "project": "tsconfig.json"
            }
        }
    ]
}

I had to create an override section for TS files since not all JS files were included in tsconfig.json which became problematic when trying to lint all JS and TS files through the same configuration.

The problem I am now running into is that creating the override section for TS files now completely ignores the rule overrides I had done in the JS section and I end up having to configure each ESLint rule in both the JS config the override I have for the TS files. Is there a way I can combine rules from the parent section in the override so that it is just adding additional rules instead of completely replacing them?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can add a second override for both *.js and *.ts files, and disable rules there, i.e.:


{
    "extends": "eslint:recommended",
    "rules": {
        "no-undef": "error"
    },
    "env": {
        "es6": true,
        "browser": true
    },
    "parserOptions": {
        "ecmaVersion": 10
    },
    "overrides": [
        {
            "files": [
                "*.ts"
            ],
            "extends": [
                "eslint:recommended",
                "plugin:@typescript-eslint/recommended"
            ],
            "rules": {
                "@typescript-eslint/no-unsafe-argument": "off",
                "@typescript-eslint/no-unsafe-member-access": "off"
            },
            "parserOptions": {
                "project": "tsconfig.json"
            }
        },
        {
            "files": [
                "*.js",
                "*.ts"
            ],
            "rules": {
                "no-unused-vars": "off",
                "max-classes-per-file": "off"
            }
        }
    ]
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!