Extending `.eslintrc.base.js`, but omit one plugin from parent

Viewed 402

I have an .eslintrc.base.js with the following configuration:

module.exports = {
    env: {
        browser: true,
        node: true,
        jest: true
    },
    extends: [
        'eslint:recommended',
        'plugin:react/recommended',
        'prettier'
    ],
    // ...
}

Most sub-packages in my project inherit this and just add to the rules or modify a couple of rules.

For one package though, I'd like to omit plugin:react/recommended, which the base config extends.

Is this possible? Or do I need to create an additional layer of config files, something like this:

  • .eslintrc.base.js: as it is now, but without plugin:react/recommended
  • .eslintrc.base.react.js: extends base config, adding react elements
  • <package>/.eslintrc.js: extends either .eslintrc.base or .eslintrc.base.react
1 Answers

You could have a single ESLint configuration file and specify overrides in it.

{
  "env": {
    "browser": true,
    "node": true,
    "jest": true
  },
  "extends": [
    "plugin:react/recommended",
    "eslint:recommended",
    "prettier"
  ],
  //override "extends" for the package for which you want to omit "plugin:react/recommended"
  "overrides": [
    {
      "files": ["package/that/omits/plugin/react/*"],
      "extends": [
        "eslint:recommended",
        "prettier"
      ]
    }
  ]
}
Related