Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

217
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda