fix(core): eslint workspaces should not contain codelyzer (#4529)
This commit is contained in:
parent
f25776d903
commit
d0d7cf4a8c
@ -28,7 +28,9 @@ describe('init', () => {
|
|||||||
expect(devDependencies['@angular/compiler-cli']).toBeDefined();
|
expect(devDependencies['@angular/compiler-cli']).toBeDefined();
|
||||||
expect(devDependencies['@angular/language-service']).toBeDefined();
|
expect(devDependencies['@angular/language-service']).toBeDefined();
|
||||||
expect(devDependencies['@angular-devkit/build-angular']).toBeDefined();
|
expect(devDependencies['@angular-devkit/build-angular']).toBeDefined();
|
||||||
expect(devDependencies['codelyzer']).toBeDefined();
|
|
||||||
|
// codelyzer should no longer be there by default
|
||||||
|
expect(devDependencies['codelyzer']).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add a postinstall script for ngcc', async () => {
|
it('should add a postinstall script for ngcc', async () => {
|
||||||
@ -208,6 +210,22 @@ describe('init', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('--linter', () => {
|
||||||
|
describe('tslint', () => {
|
||||||
|
it('should add codelyzer', async () => {
|
||||||
|
const tree = await runSchematic(
|
||||||
|
'init',
|
||||||
|
{
|
||||||
|
linter: 'tslint',
|
||||||
|
},
|
||||||
|
appTree
|
||||||
|
);
|
||||||
|
const { devDependencies } = readJsonInTree(tree, 'package.json');
|
||||||
|
expect(devDependencies['codelyzer']).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('defaultCollection', () => {
|
describe('defaultCollection', () => {
|
||||||
it('should be set if none was set before', async () => {
|
it('should be set if none was set before', async () => {
|
||||||
const result = await runSchematic('init', {}, appTree);
|
const result = await runSchematic('init', {}, appTree);
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import {
|
|||||||
setDefaultCollection,
|
setDefaultCollection,
|
||||||
updateJsonInTree,
|
updateJsonInTree,
|
||||||
updateWorkspace,
|
updateWorkspace,
|
||||||
|
Linter,
|
||||||
} from '@nrwl/workspace';
|
} from '@nrwl/workspace';
|
||||||
import {
|
import {
|
||||||
angularDevkitVersion,
|
angularDevkitVersion,
|
||||||
@ -22,9 +23,9 @@ import {
|
|||||||
} from '../../utils/versions';
|
} from '../../utils/versions';
|
||||||
import { Schema } from './schema';
|
import { Schema } from './schema';
|
||||||
import { E2eTestRunner, UnitTestRunner } from '../../utils/test-runners';
|
import { E2eTestRunner, UnitTestRunner } from '../../utils/test-runners';
|
||||||
import { stripIndents } from '@angular-devkit/core/src/utils/literals';
|
|
||||||
|
|
||||||
const updateDependencies = addDepsToPackageJson(
|
const updateDependencies = (options: Pick<Schema, 'linter'>): Rule =>
|
||||||
|
addDepsToPackageJson(
|
||||||
{
|
{
|
||||||
'@angular/animations': angularVersion,
|
'@angular/animations': angularVersion,
|
||||||
'@angular/common': angularVersion,
|
'@angular/common': angularVersion,
|
||||||
@ -42,9 +43,9 @@ const updateDependencies = addDepsToPackageJson(
|
|||||||
'@angular/compiler-cli': angularVersion,
|
'@angular/compiler-cli': angularVersion,
|
||||||
'@angular/language-service': angularVersion,
|
'@angular/language-service': angularVersion,
|
||||||
'@angular-devkit/build-angular': angularDevkitVersion,
|
'@angular-devkit/build-angular': angularDevkitVersion,
|
||||||
codelyzer: '^6.0.0',
|
codelyzer: options.linter === Linter.TsLint ? '^6.0.0' : undefined,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
export function addUnitTestRunner(
|
export function addUnitTestRunner(
|
||||||
options: Pick<Schema, 'unitTestRunner'>
|
options: Pick<Schema, 'unitTestRunner'>
|
||||||
@ -168,7 +169,7 @@ export default function (options: Schema): Rule {
|
|||||||
setDefaults(options),
|
setDefaults(options),
|
||||||
// TODO: Remove this when ngcc can be run in parallel
|
// TODO: Remove this when ngcc can be run in parallel
|
||||||
addPostinstall(),
|
addPostinstall(),
|
||||||
updateDependencies,
|
updateDependencies(options),
|
||||||
addUnitTestRunner(options),
|
addUnitTestRunner(options),
|
||||||
addE2eTestRunner(options),
|
addE2eTestRunner(options),
|
||||||
formatFiles(),
|
formatFiles(),
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
import { E2eTestRunner, UnitTestRunner } from '../../utils/test-runners';
|
import { E2eTestRunner, UnitTestRunner } from '../../utils/test-runners';
|
||||||
|
import { Linter } from '@nrwl/workspace';
|
||||||
|
|
||||||
export interface Schema {
|
export interface Schema {
|
||||||
unitTestRunner: UnitTestRunner;
|
unitTestRunner: UnitTestRunner;
|
||||||
e2eTestRunner?: E2eTestRunner;
|
e2eTestRunner?: E2eTestRunner;
|
||||||
skipFormat: boolean;
|
skipFormat: boolean;
|
||||||
skipInstall?: boolean;
|
skipInstall?: boolean;
|
||||||
style?: string;
|
style?: string;
|
||||||
|
linter: Linter;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,6 +26,12 @@
|
|||||||
"description": "Skip formatting files",
|
"description": "Skip formatting files",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false
|
"default": false
|
||||||
|
},
|
||||||
|
"linter": {
|
||||||
|
"description": "The tool to use for running lint checks.",
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["tslint", "eslint"],
|
||||||
|
"default": "eslint"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user