Skip to content

Commit

Permalink
fix(nx-plugin): remove dependency of nx-plugin to linter (#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
goetzrobin authored Jul 25, 2023
1 parent c449757 commit 43f30e8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/nx-plugin/src/generators/app/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export async function appGenerator(

addHomePage(tree, normalizedOptions);

await addEslint(tree, normalizedOptions);
await addEslint(tree, majorNxVersion, normalizedOptions);

if (!normalizedOptions.skipFormat) {
await formatFiles(tree);
Expand Down
26 changes: 22 additions & 4 deletions packages/nx-plugin/src/generators/app/lib/add-eslint.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
import { Tree } from '@nx/devkit';
import { Linter, lintProjectGenerator } from '@nx/linter';
import { NormalizedOptions } from '../generator';

export async function addEslint(
tree: Tree,
majorNxVersion: number,
options: NormalizedOptions
): Promise<void> {
await lintProjectGenerator(tree, {
linter: Linter.EsLint,
const linterOptions = {
// needed to not depend on linter package
linter: 'eslint' as any,
project: options.projectName,
eslintFilePatterns: [`${options.projectRoot}/**/*.{ts,html}`],
skipFormat: true,
});
};
if (majorNxVersion === 16) {
await (
await import(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
'@nx/linter'
)
).lintProjectGenerator(tree, linterOptions);
} else {
await (
await import(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
'@nrwl/linter'
)
).lintProjectGenerator(tree, linterOptions);
}
}

0 comments on commit 43f30e8

Please sign in to comment.