Skip to content

Commit a2810bc

Browse files
authored
fix: Ensure that directories can be unignored. (#16436)
This fix makes sure that ignored directories can be unignored using negated patterns inside of an 'ignores' entry. Fixes #16414
1 parent 631cf72 commit a2810bc

4 files changed

Lines changed: 33 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"bugs": "https://github.com/eslint/eslint/issues/",
5757
"dependencies": {
5858
"@eslint/eslintrc": "^1.3.3",
59-
"@humanwhocodes/config-array": "^0.11.3",
59+
"@humanwhocodes/config-array": "^0.11.5",
6060
"@humanwhocodes/module-importer": "^1.0.1",
6161
"@nodelib/fs.walk": "^1.2.8",
6262
"ajv": "^6.10.0",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
ignores: ["subdir"]
3+
};

tests/fixtures/ignores-subdirectory/subdir/subsubdir/a.js

Whitespace-only changes.

tests/lib/eslint/flat-eslint.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ describe("FlatESLint", () => {
11021102
});
11031103

11041104
// https://github.com/eslint/eslint/issues/16354
1105-
it("should skip subdirectory files when ignore pattern matches subdirectory", async () => {
1105+
it("should skip subdirectory files when ignore pattern matches deep subdirectory", async () => {
11061106
eslint = new FlatESLint({
11071107
cwd: getFixturePath("ignores-directory")
11081108
});
@@ -1124,6 +1124,34 @@ describe("FlatESLint", () => {
11241124

11251125
});
11261126

1127+
// https://github.com/eslint/eslint/issues/16414
1128+
it("should skip subdirectory files when ignore pattern matches subdirectory", async () => {
1129+
eslint = new FlatESLint({
1130+
cwd: getFixturePath("ignores-subdirectory")
1131+
});
1132+
1133+
await assert.rejects(async () => {
1134+
await eslint.lintFiles(["subdir/**/*.js"]);
1135+
}, /All files matched by 'subdir\/\*\*\/\*\.js' are ignored\./u);
1136+
1137+
const results = await eslint.lintFiles(["subdir/subsubdir/a.js"]);
1138+
1139+
assert.strictEqual(results.length, 1);
1140+
assert.strictEqual(results[0].filePath, getFixturePath("ignores-subdirectory/subdir/subsubdir/a.js"));
1141+
assert.strictEqual(results[0].warningCount, 1);
1142+
assert(results[0].messages[0].message.startsWith("File ignored"), "Should contain file ignored warning");
1143+
1144+
eslint = new FlatESLint({
1145+
cwd: getFixturePath("ignores-subdirectory/subdir")
1146+
});
1147+
1148+
await assert.rejects(async () => {
1149+
await eslint.lintFiles(["subsubdir/**/*.js"]);
1150+
}, /All files matched by 'subsubdir\/\*\*\/\*\.js' are ignored\./u);
1151+
1152+
1153+
});
1154+
11271155
// https://github.com/eslint/eslint/issues/16340
11281156
it("should lint files even when cwd directory name matches ignores pattern", async () => {
11291157
eslint = new FlatESLint({

0 commit comments

Comments
 (0)