diff --git a/packages/eslint/src/plugins/plugin.ts b/packages/eslint/src/plugins/plugin.ts index 83db17d74d0ee..6c61cab70d3fb 100644 --- a/packages/eslint/src/plugins/plugin.ts +++ b/packages/eslint/src/plugins/plugin.ts @@ -169,13 +169,11 @@ const internalCreateNodes = async ( }; }; -let collectingLintableFilesPromise: Promise; const internalCreateNodesV2 = async ( configFilePath: string, options: EslintPluginOptions, context: CreateNodesContextV2, eslintConfigFiles: string[], - allProjectRoots: string[], projectRootsByEslintRoots: Map, lintableFilesPerProjectRoot: Map, projectsCache: Record @@ -208,17 +206,6 @@ const internalCreateNodesV2 = async ( return; } - if (!lintableFilesPerProjectRoot.size) { - collectingLintableFilesPromise ??= collectLintableFilesByProjectRoot( - lintableFilesPerProjectRoot, - allProjectRoots, - options, - context - ); - await collectingLintableFilesPromise; - collectingLintableFilesPromise = null; - } - const eslint = new ESLint({ cwd: join(context.workspaceRoot, projectRoot), }); @@ -273,8 +260,11 @@ export const createNodesV2: CreateNodesV2 = [ const { eslintConfigFiles, projectRoots, projectRootsByEslintRoots } = splitConfigFiles(configFiles); - const lintableFilesPerProjectRoot = new Map(); - + const lintableFilesPerProjectRoot = await collectLintableFilesByProjectRoot( + projectRoots, + options, + context + ); try { return await createNodesFromFiles( (configFile, options, context) => @@ -283,7 +273,6 @@ export const createNodesV2: CreateNodesV2 = [ options, context, eslintConfigFiles, - projectRoots, projectRootsByEslintRoots, lintableFilesPerProjectRoot, targetsCache @@ -360,11 +349,12 @@ function groupProjectRootsByEslintRoots( } async function collectLintableFilesByProjectRoot( - lintableFilesPerProjectRoot: Map, projectRoots: string[], options: EslintPluginOptions, context: CreateNodesContext | CreateNodesContextV2 -): Promise { +): Promise> { + const lintableFilesPerProjectRoot = new Map(); + const lintableFiles = await globWithWorkspaceContext(context.workspaceRoot, [ `**/*.{${options.extensions.join(',')}}`, ]); @@ -382,6 +372,8 @@ async function collectLintableFilesByProjectRoot( lintableFilesPerProjectRoot.get(projectRoot).push(file); } } + + return lintableFilesPerProjectRoot; } function getRootForDirectory(