Skip to content

Bug: [new config system] ignores should be relative to configs.basePath #16300

@mdjermanovic

Description

@mdjermanovic

Environment

Node version: v16.14.0
npm version: v8.3.1
Local ESLint version: v8.23.1 (Currently used)
Global ESLint version: Not found
Operating System: win32 10.0.19044

What parser are you using?

Default (Espree)

What did you do?

Folder structure:

my-app/
├── foo/
│   └── a.js
├── a.js
└── eslint.config.js

Config file:

// eslint.config.js
module.exports = [{
    ignores: ["a.js"]
}];

Command:

cd foo && npx eslint "**/*.js" -f tap

What did you expect to happen?

I would expect that cd foo && npx eslint "**/*.js" -f tap prints:

TAP version 13
1..1
ok 1 - D:\tmp\my-app\foo\a.js

The a.js pattern in ignores is intended to ignore only a.js file in the root of the project. To confirm that, I also ran the following commands, and they're correctly returning foo/a.js.

npx eslint "**/*.js" -f tap:

TAP version 13
1..2
ok 1 - D:\tmp\my-app\eslint.config.js
ok 2 - D:\tmp\my-app\foo\a.js

cd foo && npx eslint a.js -f tap:

TAP version 13
1..1
ok 1 - D:\tmp\my-app\foo\a.js

What actually happened?

cd foo && npx eslint "**/*.js" -f tap prints:

Oops! Something went wrong! :(

ESLint: 8.23.1

You are linting "**/*.js", but all of the files matching the glob pattern "**/*.js" are ignored.

If you don't want to lint these files, remove the pattern "**/*.js" from the list of arguments passed to ESLint.

If you do want to lint these files, try the following solutions:

* Check your .eslintignore file, or the eslintIgnore property in package.json, to ensure that the files are not configured to be ignored.
* Explicitly list the files from this glob that you'd like to lint on the command-line, rather than providing a glob as an argument.

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

Config array correctly treats ignores as relative to the config base path, hence the difference between cd foo && npx eslint a.js and cd foo && npx eslint "**/*.js". The latter one goes through globby, where foo/a.js ends up being ignored because we are passing in ignores from the config file as-is so globby interprets them as relative to cwd, which is in this case foo.

const globbyResults = (await globby(globbyPatterns, {
cwd,
absolute: true,
ignore: configs.ignores.filter(matcher => typeof matcher === "string")
}));

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionbugESLint is working incorrectlyrepro:yesIssues with a reproducible example

    Type

    No type

    Projects

    Status

    Complete

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions