1
- import { dirname , resolve } from 'node:path'
1
+ import { dirname , relative , resolve } from 'node:path'
2
2
import process from 'node:process'
3
+ import { ConfigArray } from '@eslint/config-array'
4
+ import { configArrayFindFiles } from '@voxpelli/config-array-find-files'
3
5
import { bundleRequire } from 'bundle-require'
4
- import fg from 'fast-glob'
5
6
import { findUp } from 'find-up'
6
7
import c from 'picocolors'
7
8
import { resolve as resolveModule } from 'mlly'
@@ -208,28 +209,39 @@ export async function readConfig(
208
209
}
209
210
}
210
211
212
+ const noopSchema = {
213
+ merge : 'replace' ,
214
+ validate ( ) { } ,
215
+ }
216
+
217
+ const flatConfigNoopSchema = {
218
+ settings : noopSchema ,
219
+ linterOptions : noopSchema ,
220
+ language : noopSchema ,
221
+ languageOptions : noopSchema ,
222
+ processor : noopSchema ,
223
+ plugins : noopSchema ,
224
+ rules : noopSchema ,
225
+ }
226
+
211
227
export async function globMatchedFiles (
212
228
basePath : string ,
213
229
configs : FlatConfigItem [ ] ,
214
230
) : Promise < MatchedFile [ ] > {
215
231
console . log ( MARK_INFO , 'Globing matched files' )
216
- const files = await fg (
217
- configs . flatMap ( i => i . files ?? [ ] ) . filter ( i => typeof i === 'string' ) as string [ ] ,
218
- {
219
- cwd : basePath ,
220
- onlyFiles : true ,
221
- ignore : [
222
- '**/node_modules/**' ,
223
- '**/dist/**' ,
224
- '**/.git/**' ,
225
- ...configs
226
- . filter ( i => isIgnoreOnlyConfig ( i ) )
227
- . flatMap ( i => i . ignores ?? [ ] )
228
- . filter ( i => typeof i === 'string' ) as string [ ] ,
229
- ] ,
230
- deep : 5 , // TODO: maybe increase this?
231
- } ,
232
- )
232
+
233
+ const configArray = new ConfigArray ( configs , {
234
+ basePath,
235
+ schema : flatConfigNoopSchema ,
236
+ } )
237
+
238
+ await configArray . normalize ( )
239
+
240
+ const files = await configArrayFindFiles ( {
241
+ basePath,
242
+ configs : configArray ,
243
+ } )
244
+
233
245
files . sort ( )
234
246
235
247
const ignoreOnlyConfigs = configs . filter ( isIgnoreOnlyConfig )
@@ -245,6 +257,7 @@ export async function globMatchedFiles(
245
257
246
258
return files
247
259
. map ( ( filepath ) => {
260
+ filepath = relative ( basePath , filepath )
248
261
const result = matchFile ( filepath , configs , ignoreOnlyConfigs )
249
262
if ( ! result . configs . length )
250
263
return undefined
0 commit comments