You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Fix] no-unused-modules: only honor flat config ignores on ESLint 8.21+, and support older config-array (isIgnored) APIs
Flat config does not exist before ESLint 8.21, so a discovered
`eslint.config.js` is inert on older versions and its `ignores` must not filter the file set.
Gate the predicate on the installed ESLint version, and additionally guard the `config-array` API so ESLint 8.21-8.27
(`isIgnored`, no `isFileIgnored`/`isDirectoryIgnored`) works,
rather than crashing with `configArray.normalizeSync is not a function`
(ESLint 7, `config-array` 0.5.0)
or a spurious "neither could be loaded" throw (ESLint 2-6).
thrownewError('eslint-plugin-import: honoring flat config `ignores` in `no-unused-modules` requires `@eslint/config-array` (ESLint 9.4+) or `@humanwhocodes/config-array` (ESLint 8–9.3); neither could be loaded.');
thrownewError('eslint-plugin-import: honoring flat config `ignores` in `no-unused-modules` requires `@eslint/config-array` (ESLint 9.4+) or `@humanwhocodes/config-array` (ESLint 8–9.3); neither could be loaded.');
90
117
}
118
+
returnConfigArray;
91
119
}
92
120
93
121
/**
@@ -96,9 +124,14 @@ function getConfigArray() {
96
124
* @param {string} cwd - directory to resolve the flat config from
@@ -124,7 +138,7 @@ describe('listFilesWithNodeFs, flat-config ignores', function () {
124
138
]);
125
139
});
126
140
127
-
it('throws, rather than silently scanning ignored files, when a flat config has global `ignores` but no config-array implementation resolves',function(){
141
+
(supportsFlatConfig ? it : it.skip)('throws, rather than silently scanning ignored files, when a flat config has global `ignores` but no config-array implementation resolves',function(){
128
142
// stub every installed config-array copy (resolved both directly and from eslint's dir, as the
129
143
// code does) so accessing `ConfigArray` throws; copies that aren't installed already throw.
0 commit comments