/eslint-bug-ignores

Reproduceable eslint bug with "ignores" key in new configuration file

Primary LanguageJavaScript

eslint-bug-ignores

Reproduceable eslint bug with "ignores" key in new configuration file

WHAT DID YOU DO

Configuration
[
  {
    rules: {
      "no-unused-vars": "error",
    },
  },
  {
    ignores: ["error.js"],
    rules: {
      "no-unused-vars": "warn",
    },
  },
];

./error.js and ./warn.js:

let unusedVar;

Then run eslint .

EXPECTED

{cwd}/error.js
  1:5  error  'unusedVar' is defined but never used  no-unused-vars

{cwd}/warn.js
  1:5  warning  'unusedVar' is defined but never used  no-unused-vars

HAPPENED

{cwd}/error.js
  1:5  warning  'unusedVar' is defined but never used  no-unused-vars

{cwd}/warn.js
  1:5  warning  'unusedVar' is defined but never used  no-unused-vars

COMMENTS

I set 2 configuration objects: one with a rule all files and another to change that rule for all files EXCEPT error.js. I omitted the files property in these objects; although the documentation recommends using ignores with files, it states that this should work and omitting files should be the same as using files: '**/*'.

In reality, it works only if I explicitly set files in the second configuration object:

[
  {
    rules: {
      "no-unused-vars": "error",
    },
  },
  {
    files: ["**/*"],
    ignores: ["error.js"],
    rules: {
      "no-unused-vars": "warn",
    },
  },
];