Skip to content

Commit

Permalink
chore(core): try and fix failing e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHenry committed Feb 12, 2024
1 parent b75eb56 commit f9a0605
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/eslint/src/plugins/plugin.ts
Expand Up @@ -26,6 +26,9 @@ export const createNodes: CreateNodes<EslintPluginOptions> = [
(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 {
Expand Down Expand Up @@ -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('/') &&
Expand All @@ -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)
)
)
);

Expand Down

0 comments on commit f9a0605

Please sign in to comment.