Skip to content

Commit

Permalink
feat(linter): add disclaimer for when nx/linter is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Aug 22, 2023
1 parent 3dae274 commit 37699ef
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions packages/workspace/src/generators/move/lib/update-eslint-config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ensurePackage, ProjectConfiguration, Tree } from '@nx/devkit';
import { output, ProjectConfiguration, Tree } from '@nx/devkit';
import { NormalizedSchema } from '../schema';
import { nxVersion } from '../../../utils/versions';

/**
* Update the .eslintrc file of the project if it exists.
Expand All @@ -16,14 +15,22 @@ export function updateEslintConfig(
if (!tree.exists('.eslintrc.json') && !tree.exists('eslint.config.js')) {
return;
}
ensurePackage('@nx/linter', nxVersion);
const {
updateRelativePathsInConfig,
// nx-ignore-next-line
} = require('@nx/linter/src/generators/utils/eslint-file');
updateRelativePathsInConfig(
tree,
project.root,
schema.relativeToRootDestination
);
try {
const {
updateRelativePathsInConfig,
// nx-ignore-next-line
} = require('@nx/linter/src/generators/utils/eslint-file');
updateRelativePathsInConfig(
tree,
project.root,
schema.relativeToRootDestination
);
} catch {
output.warn({
title: `Could not update the eslint config file.`,
bodyLines: [
'The @nx/linter package could not be loaded. Please update the paths in eslint config manually.',
],
});
}
}

0 comments on commit 37699ef

Please sign in to comment.