Skip to content

fix: consider negated patterns universal #220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2025
Merged

Conversation

mdjermanovic
Copy link
Member

Prerequisites checklist

What is the purpose of this pull request?

Fixes the problem described in eslint/eslint#19813.

What changes did you make? (Give an overview)

Updated regex pattern that checks for universal patterns to treat negated patterns as such.

Related Issues

eslint/eslint#19813

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

@eslint-github-bot eslint-github-bot bot added the bug Something isn't working label Jun 6, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Jun 6, 2025
Comment on lines +1528 to 1535
it('should return "unconfigured" when passed docx filename', () => {
const filename = "sss.docx";

assert.strictEqual(
configs.getConfigStatus(filename),
"matched",
"unconfigured",
);
});
Copy link
Member Author

@mdjermanovic mdjermanovic Jun 6, 2025

Choose a reason for hiding this comment

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

This test was added in #7, where part of the change was to update isFileIgnored() to return true only if the file is "really" ignored, that is, ignored by ignore patterns and not just unmatched. I think the test was added to correlate with a similar test for isFileIgnored(), and was rather describing the current behavior at the time than insisting that the behavior is correct in this case.

Copy link
Member Author

Choose a reason for hiding this comment

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

On the other hand, tests for isIgnored methods with a .docx file, that were added at the time when unmatched files were considered the same as ignored, were asserting that this filename should not be ignored, i.e., that it should be matched, so that might have been the intent.

Here's the commit that added the original test with a .docx file:

humanwhocodes/config-array@343e5a0#diff-1191860929aeaa1bf678ce5c01f7f18dfe40a70ef71105a86b2f4ea95859016aR616-R620

It's interesting that the test description says true but then asserts that it is false.

it('should return true when passed docx filename', () => {
	const filename = path.resolve(basePath, 'sss.docx');

	expect(configs.isIgnored(filename)).to.be.false;
});

Copy link
Member

Choose a reason for hiding this comment

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

Yes, in that test getConfigStatus is returning "matched" because one of the config objects contains a negated pattern, which is being treated as a non-universal match according to the current logic:

{
files: ["!*.css"],
defs: {
css: false,
},
},

This was the expected behavior prior to this fix.

Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Would like @fasttime to review before merging.

@nzakas nzakas moved this from Needs Triage to Second Review Needed in Triage Jun 6, 2025
@nzakas nzakas added the accepted label Jun 6, 2025
Copy link
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, thanks!

@fasttime fasttime merged commit 2dbe2b9 into main Jun 7, 2025
21 checks passed
@fasttime fasttime deleted the issue-eslint19813 branch June 7, 2025 12:35
@github-project-automation github-project-automation bot moved this from Second Review Needed to Complete in Triage Jun 7, 2025
@github-actions github-actions bot mentioned this pull request Jun 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted bug Something isn't working
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

3 participants