Skip to content

Commit

Permalink
fix(linter): do not break migration if eslint file is missing (#18762)
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav authored Aug 29, 2023
1 parent 53da4e6 commit 9fe9afd
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/linter/src/generators/init/init-migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,24 @@ export function migrateConfigToMonorepoStyle(
projects.forEach((project) => {
const lintTarget = findLintTarget(project);
if (lintTarget) {
const projectEslintPath = joinPathFragments(
project.root,
lintTarget.options.eslintConfig || findEslintFile(tree, project.root)
);
migrateEslintFile(projectEslintPath, tree);
const eslintFile =
lintTarget.options.eslintConfig || findEslintFile(tree, project.root);
if (eslintFile) {
const projectEslintPath = joinPathFragments(project.root, eslintFile);
migrateEslintFile(projectEslintPath, tree);
}
}
});
}

export function findLintTarget(
project: ProjectConfiguration
): TargetConfiguration {
return Object.entries(project.targets ?? {}).find(
([name, target]) =>
name === 'lint' ||
return Object.values(project.targets ?? {}).find(
(target) =>
target.executor === '@nx/linter:eslint' ||
target.executor === '@nrwl/linter:eslint'
)?.[1];
);
}

function migrateEslintFile(projectEslintPath: string, tree: Tree) {
Expand Down

0 comments on commit 9fe9afd

Please sign in to comment.