fix(angular): use build-angular for linting
This commit is contained in:
parent
cdcab0107c
commit
aecdd2bc4c
@ -369,7 +369,7 @@ export default function(schema: Schema): Rule {
|
|||||||
...options,
|
...options,
|
||||||
skipFormat: true
|
skipFormat: true
|
||||||
}),
|
}),
|
||||||
addLintFiles(options.appProjectRoot, 'tslint', true),
|
addLintFiles(options.appProjectRoot, options.linter, true),
|
||||||
externalSchematic('@schematics/angular', 'application', {
|
externalSchematic('@schematics/angular', 'application', {
|
||||||
name: options.name,
|
name: options.name,
|
||||||
inlineStyle: options.inlineStyle,
|
inlineStyle: options.inlineStyle,
|
||||||
@ -394,7 +394,8 @@ export default function(schema: Schema): Rule {
|
|||||||
? externalSchematic('@nrwl/cypress', 'cypress-project', {
|
? externalSchematic('@nrwl/cypress', 'cypress-project', {
|
||||||
name: options.e2eProjectName,
|
name: options.e2eProjectName,
|
||||||
directory: options.directory,
|
directory: options.directory,
|
||||||
project: options.name
|
project: options.name,
|
||||||
|
linter: options.linter
|
||||||
})
|
})
|
||||||
: noop(),
|
: noop(),
|
||||||
move(appProjectRoot, options.appProjectRoot),
|
move(appProjectRoot, options.appProjectRoot),
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { E2eTestRunner } from '../../utils/test-runners';
|
import { E2eTestRunner } from '../../utils/test-runners';
|
||||||
import { UnitTestRunner } from '../../utils/UnitTestRunner';
|
import { UnitTestRunner } from '../../utils/UnitTestRunner';
|
||||||
|
import { Linter } from '@nrwl/workspace';
|
||||||
|
|
||||||
export interface Schema {
|
export interface Schema {
|
||||||
name: string;
|
name: string;
|
||||||
@ -14,7 +15,7 @@ export interface Schema {
|
|||||||
skipTests?: boolean;
|
skipTests?: boolean;
|
||||||
directory?: string;
|
directory?: string;
|
||||||
tags?: string;
|
tags?: string;
|
||||||
linter: string;
|
linter: Linter;
|
||||||
unitTestRunner: UnitTestRunner;
|
unitTestRunner: UnitTestRunner;
|
||||||
e2eTestRunner: E2eTestRunner;
|
e2eTestRunner: E2eTestRunner;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,38 +1,41 @@
|
|||||||
import { join, normalize } from '@angular-devkit/core';
|
import { join, normalize } from '@angular-devkit/core';
|
||||||
import {
|
import {
|
||||||
|
apply,
|
||||||
chain,
|
chain,
|
||||||
externalSchematic,
|
externalSchematic,
|
||||||
noop,
|
MergeStrategy,
|
||||||
Rule,
|
|
||||||
Tree,
|
|
||||||
SchematicContext,
|
|
||||||
schematic,
|
|
||||||
url,
|
|
||||||
apply,
|
|
||||||
mergeWith,
|
mergeWith,
|
||||||
move,
|
move,
|
||||||
|
noop,
|
||||||
|
Rule,
|
||||||
|
schematic,
|
||||||
|
SchematicContext,
|
||||||
template,
|
template,
|
||||||
MergeStrategy
|
Tree,
|
||||||
|
url
|
||||||
} from '@angular-devkit/schematics';
|
} from '@angular-devkit/schematics';
|
||||||
import { Schema } from './schema';
|
import { Schema } from './schema';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
NxJson,
|
addGlobal,
|
||||||
updateJsonInTree,
|
addIncludeToTsConfig,
|
||||||
readJsonInTree,
|
addLintFiles,
|
||||||
offsetFromRoot,
|
formatFiles,
|
||||||
addLintFiles
|
|
||||||
} from '@nrwl/workspace';
|
|
||||||
import { addGlobal, addIncludeToTsConfig, insert } from '@nrwl/workspace';
|
|
||||||
import { toClassName, toFileName, toPropertyName } from '@nrwl/workspace';
|
|
||||||
import {
|
|
||||||
getNpmScope,
|
getNpmScope,
|
||||||
getWorkspacePath,
|
getWorkspacePath,
|
||||||
replaceAppNameWithPath
|
insert,
|
||||||
|
Linter,
|
||||||
|
NxJson,
|
||||||
|
offsetFromRoot,
|
||||||
|
readJsonInTree,
|
||||||
|
replaceAppNameWithPath,
|
||||||
|
toClassName,
|
||||||
|
toFileName,
|
||||||
|
toPropertyName,
|
||||||
|
updateJsonInTree
|
||||||
} from '@nrwl/workspace';
|
} from '@nrwl/workspace';
|
||||||
import { formatFiles } from '@nrwl/workspace';
|
|
||||||
import { addUnitTestRunner } from '../ng-add/ng-add';
|
import { addUnitTestRunner } from '../ng-add/ng-add';
|
||||||
import { addImportToModule, addRoute } from '../../utils/ast-utils';
|
import { addImportToModule, addRoute } from '../../utils/ast-utils';
|
||||||
import { insertImport } from '@nrwl/workspace/src/utils/ast-utils';
|
import { insertImport } from '@nrwl/workspace/src/utils/ast-utils';
|
||||||
@ -431,7 +434,7 @@ export default function(schema: Schema): Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return chain([
|
return chain([
|
||||||
addLintFiles(options.projectRoot, 'tslint', true),
|
addLintFiles(options.projectRoot, Linter.TsLint, true),
|
||||||
addUnitTestRunner(options),
|
addUnitTestRunner(options),
|
||||||
externalSchematic('@schematics/angular', 'library', {
|
externalSchematic('@schematics/angular', 'library', {
|
||||||
name: options.name,
|
name: options.name,
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import { UnitTestRunner } from '../../utils/test-runners';
|
import { UnitTestRunner } from '../../utils/test-runners';
|
||||||
import { Framework } from '../../utils/framework';
|
|
||||||
|
|
||||||
export interface Schema {
|
export interface Schema {
|
||||||
name: string;
|
name: string;
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
import { Tree } from '@angular-devkit/schematics';
|
import { Tree } from '@angular-devkit/schematics';
|
||||||
import { createEmptyWorkspace } from '@nrwl/workspace/testing';
|
import { createEmptyWorkspace } from '@nrwl/workspace/testing';
|
||||||
import { runSchematic } from '../../utils/testing';
|
import { runSchematic } from '../../utils/testing';
|
||||||
import { readJsonInTree } from '@nrwl/workspace';
|
import { readJsonInTree, Linter } from '@nrwl/workspace';
|
||||||
import { join, normalize } from '@angular-devkit/core';
|
|
||||||
|
|
||||||
describe('schematic:cypress-project', () => {
|
describe('schematic:cypress-project', () => {
|
||||||
let appTree: Tree;
|
let appTree: Tree;
|
||||||
@ -40,7 +39,7 @@ describe('schematic:cypress-project', () => {
|
|||||||
it('should add update `workspace.json` file', async () => {
|
it('should add update `workspace.json` file', async () => {
|
||||||
const tree = await runSchematic(
|
const tree = await runSchematic(
|
||||||
'cypress-project',
|
'cypress-project',
|
||||||
{ name: 'my-app-e2e', project: 'my-app' },
|
{ name: 'my-app-e2e', project: 'my-app', linter: Linter.TsLint },
|
||||||
appTree
|
appTree
|
||||||
);
|
);
|
||||||
const workspaceJson = readJsonInTree(tree, 'workspace.json');
|
const workspaceJson = readJsonInTree(tree, 'workspace.json');
|
||||||
@ -49,9 +48,8 @@ describe('schematic:cypress-project', () => {
|
|||||||
expect(project.root).toEqual('apps/my-app-e2e');
|
expect(project.root).toEqual('apps/my-app-e2e');
|
||||||
|
|
||||||
expect(project.architect.lint).toEqual({
|
expect(project.architect.lint).toEqual({
|
||||||
builder: '@nrwl/linter:lint',
|
builder: '@angular-devkit/build-angular:tslint',
|
||||||
options: {
|
options: {
|
||||||
linter: 'tslint',
|
|
||||||
tsConfig: ['apps/my-app-e2e/tsconfig.e2e.json'],
|
tsConfig: ['apps/my-app-e2e/tsconfig.e2e.json'],
|
||||||
exclude: ['**/node_modules/**', '!apps/my-app-e2e/**']
|
exclude: ['**/node_modules/**', '!apps/my-app-e2e/**']
|
||||||
}
|
}
|
||||||
@ -71,6 +69,26 @@ describe('schematic:cypress-project', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should add update `workspace.json` file properly when eslint is passed', async () => {
|
||||||
|
const tree = await runSchematic(
|
||||||
|
'cypress-project',
|
||||||
|
{ name: 'my-app-e2e', project: 'my-app', linter: Linter.EsLint },
|
||||||
|
appTree
|
||||||
|
);
|
||||||
|
const workspaceJson = readJsonInTree(tree, 'workspace.json');
|
||||||
|
const project = workspaceJson.projects['my-app-e2e'];
|
||||||
|
|
||||||
|
expect(project.architect.lint).toEqual({
|
||||||
|
builder: '@nrwl/linter:lint',
|
||||||
|
options: {
|
||||||
|
linter: 'eslint',
|
||||||
|
config: 'apps/my-app-e2e/.eslintrc',
|
||||||
|
tsConfig: ['apps/my-app-e2e/tsconfig.e2e.json'],
|
||||||
|
exclude: ['**/node_modules/**', '!apps/my-app-e2e/**']
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should set right path names in `cypress.json`', async () => {
|
it('should set right path names in `cypress.json`', async () => {
|
||||||
const tree = await runSchematic(
|
const tree = await runSchematic(
|
||||||
'cypress-project',
|
'cypress-project',
|
||||||
@ -111,7 +129,12 @@ describe('schematic:cypress-project', () => {
|
|||||||
it('should update workspace.json', async () => {
|
it('should update workspace.json', async () => {
|
||||||
const tree = await runSchematic(
|
const tree = await runSchematic(
|
||||||
'cypress-project',
|
'cypress-project',
|
||||||
{ name: 'my-app-e2e', project: 'my-dir-my-app', directory: 'my-dir' },
|
{
|
||||||
|
name: 'my-app-e2e',
|
||||||
|
project: 'my-dir-my-app',
|
||||||
|
directory: 'my-dir',
|
||||||
|
linter: Linter.TsLint
|
||||||
|
},
|
||||||
appTree
|
appTree
|
||||||
);
|
);
|
||||||
const projectConfig = readJsonInTree(tree, 'workspace.json').projects[
|
const projectConfig = readJsonInTree(tree, 'workspace.json').projects[
|
||||||
@ -120,9 +143,8 @@ describe('schematic:cypress-project', () => {
|
|||||||
|
|
||||||
expect(projectConfig).toBeDefined();
|
expect(projectConfig).toBeDefined();
|
||||||
expect(projectConfig.architect.lint).toEqual({
|
expect(projectConfig.architect.lint).toEqual({
|
||||||
builder: '@nrwl/linter:lint',
|
builder: '@angular-devkit/build-angular:tslint',
|
||||||
options: {
|
options: {
|
||||||
linter: 'tslint',
|
|
||||||
tsConfig: ['apps/my-dir/my-app-e2e/tsconfig.e2e.json'],
|
tsConfig: ['apps/my-dir/my-app-e2e/tsconfig.e2e.json'],
|
||||||
exclude: ['**/node_modules/**', '!apps/my-dir/my-app-e2e/**']
|
exclude: ['**/node_modules/**', '!apps/my-dir/my-app-e2e/**']
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
|
import { Linter } from '@nrwl/workspace';
|
||||||
|
|
||||||
export interface Schema {
|
export interface Schema {
|
||||||
project: string;
|
project: string;
|
||||||
name: string;
|
name: string;
|
||||||
directory: string;
|
directory: string;
|
||||||
linter: 'eslint' | 'tslint';
|
linter: Linter;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
import { UnitTestRunner } from '../../utils/test-runners';
|
import { UnitTestRunner } from '../../utils/test-runners';
|
||||||
|
import { Linter } from '@nrwl/workspace';
|
||||||
|
|
||||||
export interface Schema {
|
export interface Schema {
|
||||||
name: string;
|
name: string;
|
||||||
skipFormat: boolean;
|
skipFormat: boolean;
|
||||||
@ -6,6 +8,6 @@ export interface Schema {
|
|||||||
directory?: string;
|
directory?: string;
|
||||||
unitTestRunner: UnitTestRunner;
|
unitTestRunner: UnitTestRunner;
|
||||||
tags?: string;
|
tags?: string;
|
||||||
linter: string;
|
linter: Linter;
|
||||||
frontendProject?: string;
|
frontendProject?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,9 +15,8 @@ describe('jestProject', () => {
|
|||||||
root: 'libs/lib1',
|
root: 'libs/lib1',
|
||||||
architect: {
|
architect: {
|
||||||
lint: {
|
lint: {
|
||||||
builder: '@nrwl/linter:lint',
|
builder: '@angular-devkit/build-angular:tslint',
|
||||||
options: {
|
options: {
|
||||||
linter: 'tslint',
|
|
||||||
tsConfig: []
|
tsConfig: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
import { UnitTestRunner } from '../../utils/test-runners';
|
import { UnitTestRunner } from '../../utils/test-runners';
|
||||||
|
import { Linter } from 'tslint';
|
||||||
|
|
||||||
export interface Schema {
|
export interface Schema {
|
||||||
name: string;
|
name: string;
|
||||||
skipFormat: boolean;
|
skipFormat: boolean;
|
||||||
@ -6,6 +8,6 @@ export interface Schema {
|
|||||||
directory?: string;
|
directory?: string;
|
||||||
unitTestRunner: UnitTestRunner;
|
unitTestRunner: UnitTestRunner;
|
||||||
tags?: string;
|
tags?: string;
|
||||||
linter: string;
|
linter: Linter;
|
||||||
frontendProject?: string;
|
frontendProject?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,9 +53,8 @@ describe('app', () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
expect(workspaceJson.projects['my-node-app'].architect.lint).toEqual({
|
expect(workspaceJson.projects['my-node-app'].architect.lint).toEqual({
|
||||||
builder: '@nrwl/linter:lint',
|
builder: '@angular-devkit/build-angular:tslint',
|
||||||
options: {
|
options: {
|
||||||
linter: 'tslint',
|
|
||||||
tsConfig: [
|
tsConfig: [
|
||||||
'apps/my-node-app/tsconfig.app.json',
|
'apps/my-node-app/tsconfig.app.json',
|
||||||
'apps/my-node-app/tsconfig.spec.json'
|
'apps/my-node-app/tsconfig.spec.json'
|
||||||
@ -125,9 +124,8 @@ describe('app', () => {
|
|||||||
expect(
|
expect(
|
||||||
workspaceJson.projects['my-dir-my-node-app'].architect.lint
|
workspaceJson.projects['my-dir-my-node-app'].architect.lint
|
||||||
).toEqual({
|
).toEqual({
|
||||||
builder: '@nrwl/linter:lint',
|
builder: '@angular-devkit/build-angular:tslint',
|
||||||
options: {
|
options: {
|
||||||
linter: 'tslint',
|
|
||||||
tsConfig: [
|
tsConfig: [
|
||||||
'apps/my-dir/my-node-app/tsconfig.app.json',
|
'apps/my-dir/my-node-app/tsconfig.app.json',
|
||||||
'apps/my-dir/my-node-app/tsconfig.spec.json'
|
'apps/my-dir/my-node-app/tsconfig.spec.json'
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
|
import { Linter } from '@nrwl/workspace';
|
||||||
|
|
||||||
export interface Schema {
|
export interface Schema {
|
||||||
name: string;
|
name: string;
|
||||||
skipFormat: boolean;
|
skipFormat: boolean;
|
||||||
skipPackageJson: boolean;
|
skipPackageJson: boolean;
|
||||||
directory?: string;
|
directory?: string;
|
||||||
unitTestRunner: 'jest' | 'none';
|
unitTestRunner: 'jest' | 'none';
|
||||||
linter: 'eslint' | 'tslint';
|
linter: Linter;
|
||||||
tags?: string;
|
tags?: string;
|
||||||
frontendProject?: string;
|
frontendProject?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -292,9 +292,8 @@ describe('app', () => {
|
|||||||
);
|
);
|
||||||
const workspaceJson = readJsonInTree(tree, 'workspace.json');
|
const workspaceJson = readJsonInTree(tree, 'workspace.json');
|
||||||
expect(workspaceJson.projects['my-app'].architect.lint).toEqual({
|
expect(workspaceJson.projects['my-app'].architect.lint).toEqual({
|
||||||
builder: '@nrwl/linter:lint',
|
builder: '@angular-devkit/build-angular:tslint',
|
||||||
options: {
|
options: {
|
||||||
linter: 'tslint',
|
|
||||||
exclude: ['**/node_modules/**', '!apps/my-app/**'],
|
exclude: ['**/node_modules/**', '!apps/my-app/**'],
|
||||||
tsConfig: [
|
tsConfig: [
|
||||||
'apps/my-app/tsconfig.app.json',
|
'apps/my-app/tsconfig.app.json',
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import { Linter } from '@nrwl/workspace';
|
||||||
|
|
||||||
export interface Schema {
|
export interface Schema {
|
||||||
name: string;
|
name: string;
|
||||||
style?: string;
|
style?: string;
|
||||||
@ -6,7 +8,7 @@ export interface Schema {
|
|||||||
tags?: string;
|
tags?: string;
|
||||||
unitTestRunner: 'jest' | 'none';
|
unitTestRunner: 'jest' | 'none';
|
||||||
e2eTestRunner: 'cypress' | 'none';
|
e2eTestRunner: 'cypress' | 'none';
|
||||||
linter: 'eslint' | 'tslint';
|
linter: Linter;
|
||||||
pascalCaseFiles?: boolean;
|
pascalCaseFiles?: boolean;
|
||||||
classComponent?: boolean;
|
classComponent?: boolean;
|
||||||
routing?: boolean;
|
routing?: boolean;
|
||||||
|
|||||||
@ -19,9 +19,8 @@ describe('lib', () => {
|
|||||||
expect(workspaceJson.projects['my-lib'].root).toEqual('libs/my-lib');
|
expect(workspaceJson.projects['my-lib'].root).toEqual('libs/my-lib');
|
||||||
expect(workspaceJson.projects['my-lib'].architect.build).toBeUndefined();
|
expect(workspaceJson.projects['my-lib'].architect.build).toBeUndefined();
|
||||||
expect(workspaceJson.projects['my-lib'].architect.lint).toEqual({
|
expect(workspaceJson.projects['my-lib'].architect.lint).toEqual({
|
||||||
builder: '@nrwl/linter:lint',
|
builder: '@angular-devkit/build-angular:tslint',
|
||||||
options: {
|
options: {
|
||||||
linter: 'tslint',
|
|
||||||
exclude: ['**/node_modules/**', '!libs/my-lib/**'],
|
exclude: ['**/node_modules/**', '!libs/my-lib/**'],
|
||||||
tsConfig: [
|
tsConfig: [
|
||||||
'libs/my-lib/tsconfig.lib.json',
|
'libs/my-lib/tsconfig.lib.json',
|
||||||
@ -184,9 +183,8 @@ describe('lib', () => {
|
|||||||
'libs/my-dir/my-lib'
|
'libs/my-dir/my-lib'
|
||||||
);
|
);
|
||||||
expect(workspaceJson.projects['my-dir-my-lib'].architect.lint).toEqual({
|
expect(workspaceJson.projects['my-dir-my-lib'].architect.lint).toEqual({
|
||||||
builder: '@nrwl/linter:lint',
|
builder: '@angular-devkit/build-angular:tslint',
|
||||||
options: {
|
options: {
|
||||||
linter: 'tslint',
|
|
||||||
exclude: ['**/node_modules/**', '!libs/my-dir/my-lib/**'],
|
exclude: ['**/node_modules/**', '!libs/my-dir/my-lib/**'],
|
||||||
tsConfig: [
|
tsConfig: [
|
||||||
'libs/my-dir/my-lib/tsconfig.lib.json',
|
'libs/my-dir/my-lib/tsconfig.lib.json',
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import { Linter } from '@nrwl/workspace';
|
||||||
|
|
||||||
export interface Schema {
|
export interface Schema {
|
||||||
name: string;
|
name: string;
|
||||||
directory?: string;
|
directory?: string;
|
||||||
@ -10,5 +12,5 @@ export interface Schema {
|
|||||||
routing?: boolean;
|
routing?: boolean;
|
||||||
parentRoute?: string;
|
parentRoute?: string;
|
||||||
unitTestRunner: 'jest' | 'none';
|
unitTestRunner: 'jest' | 'none';
|
||||||
linter: 'eslint' | 'tslint';
|
linter: Linter;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -284,9 +284,8 @@ describe('app', () => {
|
|||||||
const workspaceJson = readJsonInTree(tree, 'workspace.json');
|
const workspaceJson = readJsonInTree(tree, 'workspace.json');
|
||||||
|
|
||||||
expect(workspaceJson.projects['my-app'].architect.lint).toEqual({
|
expect(workspaceJson.projects['my-app'].architect.lint).toEqual({
|
||||||
builder: '@nrwl/linter:lint',
|
builder: '@angular-devkit/build-angular:tslint',
|
||||||
options: {
|
options: {
|
||||||
linter: 'tslint',
|
|
||||||
exclude: ['**/node_modules/**', '!apps/my-app/**'],
|
exclude: ['**/node_modules/**', '!apps/my-app/**'],
|
||||||
tsConfig: [
|
tsConfig: [
|
||||||
'apps/my-app/tsconfig.app.json',
|
'apps/my-app/tsconfig.app.json',
|
||||||
|
|||||||
@ -7,5 +7,5 @@ export interface Schema {
|
|||||||
tags?: string;
|
tags?: string;
|
||||||
unitTestRunner: 'jest' | 'none';
|
unitTestRunner: 'jest' | 'none';
|
||||||
e2eTestRunner: 'cypress' | 'none';
|
e2eTestRunner: 'cypress' | 'none';
|
||||||
linter: 'eslint' | 'tslint';
|
linter: Linter;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,7 +58,7 @@ export {
|
|||||||
|
|
||||||
export { getWorkspace, updateWorkspace } from './src/utils/workspace';
|
export { getWorkspace, updateWorkspace } from './src/utils/workspace';
|
||||||
export { addUpdateTask } from './src/utils/update-task';
|
export { addUpdateTask } from './src/utils/update-task';
|
||||||
export { addLintFiles, generateProjectLint } from './src/utils/lint';
|
export { addLintFiles, generateProjectLint, Linter } from './src/utils/lint';
|
||||||
|
|
||||||
export { formatFiles } from './src/utils/rules/format-files';
|
export { formatFiles } from './src/utils/rules/format-files';
|
||||||
export { deleteFile } from './src/utils/rules/deleteFile';
|
export { deleteFile } from './src/utils/rules/deleteFile';
|
||||||
|
|||||||
@ -20,9 +20,8 @@ describe('lib', () => {
|
|||||||
expect(workspaceJson.projects['my-lib'].root).toEqual('libs/my-lib');
|
expect(workspaceJson.projects['my-lib'].root).toEqual('libs/my-lib');
|
||||||
expect(workspaceJson.projects['my-lib'].architect.build).toBeUndefined();
|
expect(workspaceJson.projects['my-lib'].architect.build).toBeUndefined();
|
||||||
expect(workspaceJson.projects['my-lib'].architect.lint).toEqual({
|
expect(workspaceJson.projects['my-lib'].architect.lint).toEqual({
|
||||||
builder: '@nrwl/linter:lint',
|
builder: '@angular-devkit/build-angular:tslint',
|
||||||
options: {
|
options: {
|
||||||
linter: 'tslint',
|
|
||||||
exclude: ['**/node_modules/**', '!libs/my-lib/**'],
|
exclude: ['**/node_modules/**', '!libs/my-lib/**'],
|
||||||
tsConfig: [
|
tsConfig: [
|
||||||
'libs/my-lib/tsconfig.lib.json',
|
'libs/my-lib/tsconfig.lib.json',
|
||||||
@ -167,9 +166,8 @@ describe('lib', () => {
|
|||||||
'libs/my-dir/my-lib'
|
'libs/my-dir/my-lib'
|
||||||
);
|
);
|
||||||
expect(workspaceJson.projects['my-dir-my-lib'].architect.lint).toEqual({
|
expect(workspaceJson.projects['my-dir-my-lib'].architect.lint).toEqual({
|
||||||
builder: '@nrwl/linter:lint',
|
builder: '@angular-devkit/build-angular:tslint',
|
||||||
options: {
|
options: {
|
||||||
linter: 'tslint',
|
|
||||||
exclude: ['**/node_modules/**', '!libs/my-dir/my-lib/**'],
|
exclude: ['**/node_modules/**', '!libs/my-dir/my-lib/**'],
|
||||||
tsConfig: [
|
tsConfig: [
|
||||||
'libs/my-dir/my-lib/tsconfig.lib.json',
|
'libs/my-dir/my-lib/tsconfig.lib.json',
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { UnitTestRunner } from '../../utils/test-runners';
|
import { Linter } from '@nrwl/workspace/src/utils/lint';
|
||||||
|
|
||||||
export interface Schema {
|
export interface Schema {
|
||||||
name: string;
|
name: string;
|
||||||
@ -8,5 +8,5 @@ export interface Schema {
|
|||||||
tags?: string;
|
tags?: string;
|
||||||
simpleModuleName: boolean;
|
simpleModuleName: boolean;
|
||||||
unitTestRunner: 'jest' | 'none';
|
unitTestRunner: 'jest' | 'none';
|
||||||
linter: 'eslint' | 'tslint';
|
linter: Linter;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,21 +13,26 @@ import {
|
|||||||
eslintConfigPrettierVersion
|
eslintConfigPrettierVersion
|
||||||
} from './versions';
|
} from './versions';
|
||||||
|
|
||||||
|
export const enum Linter {
|
||||||
|
TsLint = 'tslint',
|
||||||
|
EsLint = 'eslint',
|
||||||
|
None = 'none'
|
||||||
|
}
|
||||||
|
|
||||||
export function generateProjectLint(
|
export function generateProjectLint(
|
||||||
projectRoot: string,
|
projectRoot: string,
|
||||||
tsConfigPath: string,
|
tsConfigPath: string,
|
||||||
linter: 'tslint' | 'eslint' | 'none'
|
linter: Linter
|
||||||
) {
|
) {
|
||||||
if (linter === 'tslint') {
|
if (linter === Linter.TsLint) {
|
||||||
return {
|
return {
|
||||||
builder: '@nrwl/linter:lint',
|
builder: '@angular-devkit/build-angular:tslint',
|
||||||
options: {
|
options: {
|
||||||
linter: 'tslint',
|
|
||||||
tsConfig: [tsConfigPath],
|
tsConfig: [tsConfigPath],
|
||||||
exclude: ['**/node_modules/**', '!' + projectRoot + '/**']
|
exclude: ['**/node_modules/**', '!' + projectRoot + '/**']
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else if (linter === 'eslint') {
|
} else if (linter === Linter.EsLint) {
|
||||||
return {
|
return {
|
||||||
builder: '@nrwl/linter:lint',
|
builder: '@nrwl/linter:lint',
|
||||||
options: {
|
options: {
|
||||||
@ -44,7 +49,7 @@ export function generateProjectLint(
|
|||||||
|
|
||||||
export function addLintFiles(
|
export function addLintFiles(
|
||||||
projectRoot: string,
|
projectRoot: string,
|
||||||
linter: 'tslint' | 'eslint' | 'none',
|
linter: Linter,
|
||||||
onlyGlobal = false
|
onlyGlobal = false
|
||||||
): Rule {
|
): Rule {
|
||||||
return (host: Tree, context: SchematicContext) => {
|
return (host: Tree, context: SchematicContext) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user