Skip to content

Commit 344da49

Browse files
authored
fix: Remove name property from all and recommended configs (#200)
* fix: Remove `name` property from eslint:all and eslint:recommended configs * unconditionally delete `name` from configs
1 parent cf3ebdb commit 344da49

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

lib/flat-compat.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,25 @@ class FlatCompat {
226226
throw new TypeError("Missing parameter 'allConfig' in FlatCompat constructor.");
227227
}
228228

229-
return allConfig;
229+
// remove name property if it exists
230+
const config = { ...allConfig };
231+
232+
delete config.name;
233+
234+
return config;
230235
},
231236
getEslintRecommendedConfig() {
232237

233238
if (!recommendedConfig) {
234239
throw new TypeError("Missing parameter 'recommendedConfig' in FlatCompat constructor.");
235240
}
236241

237-
return recommendedConfig;
242+
// remove name property if it exists
243+
const config = { ...recommendedConfig };
244+
245+
delete config.name;
246+
247+
return config;
238248
}
239249
});
240250
}

tests/lib/flat-compat.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,28 @@ describe("FlatCompat", () => {
10271027
}, /Missing parameter 'recommendedConfig'/gu);
10281028
});
10291029

1030+
it("should remove name property from eslint:all and eslint:recommended configs", () => {
1031+
const compatWithNames = new FlatCompat({
1032+
baseDirectory: getFixturePath("config"),
1033+
recommendedConfig: {
1034+
name: "eslint:recommended",
1035+
settings: { "eslint:recommended": true }
1036+
},
1037+
allConfig: {
1038+
name: "eslint:all",
1039+
settings: { "eslint:all": true }
1040+
}
1041+
});
1042+
1043+
const allResult = compatWithNames.extends("eslint:all");
1044+
const recommendedResult = compatWithNames.extends("eslint:recommended");
1045+
1046+
assert.strictEqual(allResult.length, 1);
1047+
assert.isTrue(allResult[0].settings["eslint:all"]);
1048+
1049+
assert.strictEqual(recommendedResult.length, 1);
1050+
assert.isTrue(recommendedResult[0].settings["eslint:recommended"]);
1051+
});
10301052
});
10311053

10321054
describe("plugins()", () => {

0 commit comments

Comments
 (0)