Skip to content

feat: Add new includeIgnoreFile() to config-helpers#430

Merged
DMartens merged 37 commits intoeslint:mainfrom
kirkwaiblinger:include-gitignore-in-path
May 4, 2026
Merged

feat: Add new includeIgnoreFile() to config-helpers#430
DMartens merged 37 commits intoeslint:mainfrom
kirkwaiblinger:include-gitignore-in-path

Conversation

@kirkwaiblinger
Copy link
Copy Markdown
Contributor

@kirkwaiblinger kirkwaiblinger commented Apr 8, 2026

Prerequisites checklist

AI acknowledgment

  • I did not use AI to generate this PR.
    • (for the most part; some AI use for the added documentation)
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

What is the purpose of this pull request?

fixes #329

What changes did you make? (Give an overview)

Deprecate includeIgnoreFile(),convertIgnorePatternToMinimatch() in @eslint/compat. Add and export new includeIgnoreFile() (documented),convertIgnorePatternToMinimatch() (undocumented) in @eslint/config-helpers.

The new convertIgnorePatternToMinimatch() is unaltered.
The new includeIgnoreFile():

  • adds a gitignoreResolution option which can be false (default; interprets patterns relative to config file) or true (interprets patterns relative to ignore file).
  • can accept an array of ignore file paths rather than only a single ignore file path.

Related Issues

#329

Is there anything you'd like reviewers to focus on?


There is a companion PR in eslint repo: eslint/eslint#20735

@github-project-automation github-project-automation Bot moved this to Needs Triage in Triage Apr 8, 2026
@kirkwaiblinger kirkwaiblinger marked this pull request as ready for review April 8, 2026 19:30
@kirkwaiblinger kirkwaiblinger changed the title feat: Add new includeIgnoreFIle() to config-helpers feat: Add new includeIgnoreFile() to config-helpers Apr 8, 2026
});

it("should return an object with an `ignores` property", () => {
const ignoreFilePath = fileURLToPath(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should simplify this and in other spots by using import.meta.resolve (requires Node v18+)

Suggested change
const ignoreFilePath = fileURLToPath(
const ignoreFilePath = import.meta.resolve("../tests/fixtures/ignore-files/gitignore1.txt")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh... I never knew about import.meta.resolve. But in any case it looks like that still gets us a URL, which would need to be converted to a path with fileURLToPath(). So I'm not sure that that gains us anything? Unless I'm misunderstanding.

At the end of the day, this is really just the workaround for not having access to import.meta.dirname, which the linter complains about (due to supporting older versions of node)

Comment thread packages/config-helpers/tests/ignore-file.test.js
Comment thread packages/config-helpers/src/ignore-file.js Outdated
@kirkwaiblinger kirkwaiblinger requested a review from DMartens April 8, 2026 23:41
@mdjermanovic mdjermanovic moved this from Needs Triage to Implementing in Triage Apr 9, 2026
Comment thread packages/compat/README.md Outdated
Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
Comment thread packages/compat/tests/ignore-file.test.js Outdated
Comment thread packages/compat/README.md Outdated
Comment thread packages/config-helpers/README.md Outdated
Comment thread packages/migrate-config/package.json
mdjermanovic
mdjermanovic previously approved these changes Apr 25, 2026
Copy link
Copy Markdown
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! Leaving open for others to verify their review comments.

@lumirlumir lumirlumir moved this from Implementing to Second Review Needed in Triage Apr 26, 2026
Comment thread packages/config-helpers/src/ignore-file.js Outdated
Comment thread packages/config-helpers/src/ignore-file.js Outdated
Comment thread packages/config-helpers/tests/ignore-file.test.js Outdated
Comment thread packages/config-helpers/tests/ignore-file.test.js Outdated
lumirlumir
lumirlumir previously approved these changes May 4, 2026
Copy link
Copy Markdown
Member

@lumirlumir lumirlumir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for your time and effort on this PR!

Would like @mdjermanovic to verify the changes before merging.

Comment thread packages/config-helpers/README.md Outdated
Co-authored-by: 루밀LuMir <rpfos@naver.com>
mdjermanovic
mdjermanovic previously approved these changes May 4, 2026
Copy link
Copy Markdown
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! Leaving open for @fasttime and @DMartens to verify.

fasttime
fasttime previously approved these changes May 4, 2026
Copy link
Copy Markdown
Member

@fasttime fasttime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

]);
});

// convert above to for ... of loop
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is an unresolved TODO comment related to line 61 which uses Array#forEach to create a parameterised test case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gah! that was a prompt to copilot that I forgot to remove, yep 🫣. Thanks for pointing that out.

@DMartens
Copy link
Copy Markdown

DMartens commented May 4, 2026

Changes LGTM, thank you for the continued work on this.
Only found a seemingly unresolved TODO comment.

@kirkwaiblinger kirkwaiblinger dismissed stale reviews from fasttime and mdjermanovic via 8f99a34 May 4, 2026 21:29
@kirkwaiblinger kirkwaiblinger requested a review from DMartens May 4, 2026 21:31
@DMartens DMartens merged commit 9b51352 into eslint:main May 4, 2026
59 checks passed
@github-project-automation github-project-automation Bot moved this from Second Review Needed to Complete in Triage May 4, 2026
@eslintbot eslintbot mentioned this pull request May 4, 2026
@kirkwaiblinger kirkwaiblinger deleted the include-gitignore-in-path branch May 4, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

Change Request: includeIgnoreFile should respect the path to the directory containing the .gitignore

6 participants