eslint-plugin-node icon indicating copy to clipboard operation
eslint-plugin-node copied to clipboard

Unable to easily customize recommended config due to overrides

Open jaydenseric opened this issue 5 years ago • 2 comments

It is difficult to override rules causing errors in .mjs (and presumably .cjs) files in projects, due to the use of overrides in the recommended config having a high specificity:

https://github.com/mysticatea/eslint-plugin-node/blob/v9.0.1/lib/configs/recommended.js#L13

This ESLint config will not work:

{
  "plugins": ["node"],
  "extends": ["plugin:node/recommended"],
  "rules": {
    "node/no-missing-import": "off"
  }
}

You must use matching overrides for .mjs:

{
  "plugins": ["node"],
  "extends": ["plugin:node/recommended"],
  "overrides": [
    {
      "files": ["*.mjs", ".*.mjs"],
      "rules": {
        "node/no-missing-import": "off"
      }
    }
  ]
}

jaydenseric avatar May 13 '19 00:05 jaydenseric

Thank you for the report.

This is a bug of ESLint (eslint/eslint#11510) and has been fixed on master (eslint/eslint#11546).

For now, please use one of workarounds:

  • Use plugin:node/recommended-script or plugin:node/recommended-module.
  • Use overrides in your config.
  • Use eslint@next (6.0.0-alpha.1)

mysticatea avatar May 13 '19 04:05 mysticatea

Can this issue be closed now, given that it sounds like it was fixed in ESLint almost 2 years ago?

overlookmotel avatar Feb 27 '21 12:02 overlookmotel