Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

eslint `ignores` property has no effect on scanned files

I can’t seem to get eslint to correctly directories in my project.
Using eslint config inspector, I can see my ignores look correct.

const globals = require("globals");

module.exports =[{
    languageOptions: {
        globals: {
            ...globals.commonjs,
            ...globals.node,
            ...globals.mocha,
        },

        ecmaVersion: 2022,
        sourceType: "module",
    },

    rules: {
        "no-const-assign": "warn"
    },

    ignores: ["media/mermaid.min.js"]
}];

Result:

ESLint detects the ignore rule

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

ESLint still wants to scan the ignored file

The media folder is in the root of the project and I am running commands while in the project root directory. In addition to trying a specific file as per the screenshot, I have tried the following patterns without success:

  • **/media/**
  • media/**
  • media/**/*.js
  • media/*
  • media
  • **/*.js (as a test)

I have also tried setting the eslint working directory via .vscode/settings.json but that had no effect.

Using eslint -c eslint.config.js . in the project root directory produces the same result as eslint .. Both appear to detect the correct config file and corroborate the eslint config inspector.

node: v22.10.0

eslint: v9.13.0

>Solution :

It seems like the documentation for how to use the ignores property is misleading. Try specifying it as a separate configuration:

module.exports =[
 {
   ignores: ["media/mermaid.min.js"]
 },
 {
  languageOptions: {
      globals: {
          ...globals.commonjs,
          ...globals.node,
          ...globals.mocha,
      },

      ecmaVersion: 2022,
      sourceType: "module",
  },

  rules: {
      "no-const-assign": "warn"
  }
}];

See discussion.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading