Skip to content

Commit

Permalink
feat(core): move @nrwl/linter to inside the func
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongemi committed Feb 16, 2023
1 parent f3212af commit f9504bf
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ export async function addUnitTestRunner(host: Tree, options: NormalizedSchema) {
rootProject: options.rootProject,
});
} else if (options.unitTestRunner === UnitTestRunner.Karma) {
const {
karmaProjectGenerator,
} = require('../../../karma-project/karma-project');
await karmaProjectGenerator(host, {
project: options.name,
skipFormat: true,
Expand Down
7 changes: 2 additions & 5 deletions packages/angular/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export async function angularInitGenerator(
}
const unitTestTask = await addUnitTestRunner(tree, options);
tasks.push(unitTestTask);
const e2eTask = await addE2ETestRunner(tree, options);
const e2eTask = addE2ETestRunner(tree, options);
tasks.push(e2eTask);

addGitIgnoreEntry(tree, '.angular');
Expand Down Expand Up @@ -188,10 +188,7 @@ async function addUnitTestRunner(
}
}

async function addE2ETestRunner(
tree: Tree,
options: Schema
): Promise<GeneratorCallback> {
function addE2ETestRunner(tree: Tree, options: Schema): GeneratorCallback {
switch (options.e2eTestRunner) {
case E2eTestRunner.Protractor:
return !options.skipPackageJson
Expand Down
3 changes: 1 addition & 2 deletions packages/js/src/generators/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import {
writeJson,
} from '@nrwl/devkit';
import { getImportPath } from 'nx/src/utils/path';
// nx-ignore-next-line
const { Linter } = require('@nrwl/linter'); // use require to import to avoid circular dependency
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
import {
getRelativePathToRootTsConfig,
Expand Down Expand Up @@ -380,6 +378,7 @@ function normalizeOptions(
options.buildable = true;
}

const { Linter } = require('@nrwl/linter');
if (options.config === 'npm-scripts') {
options.unitTestRunner = 'none';
options.linter = Linter.None;
Expand Down
3 changes: 2 additions & 1 deletion packages/workspace/src/generators/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ function normalizeOptions(tree: Tree, options: Schema): NormalizedSchema {
}

if (!options.linter) {
options.linter = 'eslint';
const { Linter } = require('@nrwl/linter');
options.linter = Linter.EsLint;
}

const projectName = projectDirectory.replace(new RegExp('/', 'g'), '-');
Expand Down

0 comments on commit f9504bf

Please sign in to comment.