diff --git a/packages/eslint/src/plugins/plugin.ts b/packages/eslint/src/plugins/plugin.ts index df3dd69c056375..1d293d1582feb4 100644 --- a/packages/eslint/src/plugins/plugin.ts +++ b/packages/eslint/src/plugins/plugin.ts @@ -26,6 +26,9 @@ export const createNodes: CreateNodes = [ (configFilePath, options, context) => { options = normalizeOptions(options); + // TODO: Figure out why this is required to protect against failures in e2e-run + (context as any).workspaceFiles = context.workspaceFiles ?? []; + const configDir = dirname(configFilePath); if (configDir === '.') { return { @@ -53,24 +56,23 @@ function getProjectsUsingRootESLintConfig( context: CreateNodesContext ): CreateNodesResult['projects'] { const projects: CreateNodesResult['projects'] = {}; - const workspaceFiles = context.workspaceFiles ?? []; // If there's no src folder, it's not a standalone project, so a project.json would be explicitly required to add the root to the mapping const isStandaloneWorkspace = - workspaceFiles.some((f) => f.startsWith('src')) && - workspaceFiles.includes('package.json'); + context.workspaceFiles.some((f) => f.startsWith('src')) && + context.workspaceFiles.includes('package.json'); if (isStandaloneWorkspace) { projects['.'] = { targets: buildEslintTargets([configFilePath], '.', options, true), }; - } else if (workspaceFiles.includes('project.json')) { + } else if (context.workspaceFiles.includes('project.json')) { projects['.'] = { targets: buildEslintTargets([configFilePath], '.', options), }; } // Some nested projects may require a lint target based on this root level config as well (in the case they don't have their own) - const childProjectRoots = workspaceFiles + const childProjectRoots = context.workspaceFiles .filter( (f) => f.includes('/') && @@ -82,7 +84,9 @@ function getProjectsUsingRootESLintConfig( const childProjectsWithoutEslintConfig = childProjectRoots.filter( (childProjectRoot) => !ESLINT_CONFIG_FILENAMES.some((eslintConfigFile) => - workspaceFiles.includes(join(childProjectRoot, eslintConfigFile)) + context.workspaceFiles.includes( + join(childProjectRoot, eslintConfigFile) + ) ) );