feat(linter): remove tslint support (#12279)

This commit is contained in:
Colum Ferry 2022-09-28 16:08:01 +01:00 committed by GitHub
parent 56957cc292
commit 09c6ccb266
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
55 changed files with 115 additions and 563 deletions

View File

@ -85,7 +85,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint", "none"], "enum": ["eslint", "none"],
"default": "eslint" "default": "eslint"
}, },
"js": { "js": {

View File

@ -73,7 +73,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint", "none"], "enum": ["eslint", "none"],
"default": "eslint" "default": "eslint"
}, },
"js": { "js": {

View File

@ -87,7 +87,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint"], "enum": ["eslint"],
"default": "eslint" "default": "eslint"
}, },
"unitTestRunner": { "unitTestRunner": {
@ -163,7 +163,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint"], "enum": ["eslint"],
"default": "eslint" "default": "eslint"
}, },
"unitTestRunner": { "unitTestRunner": {

View File

@ -131,7 +131,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint"], "enum": ["eslint"],
"default": "eslint" "default": "eslint"
}, },
"skipFormat": { "skipFormat": {
@ -481,7 +481,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint"], "enum": ["eslint"],
"default": "eslint" "default": "eslint"
}, },
"unitTestRunner": { "unitTestRunner": {

View File

@ -86,7 +86,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint"], "enum": ["eslint"],
"default": "eslint" "default": "eslint"
}, },
"unitTestRunner": { "unitTestRunner": {
@ -175,7 +175,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint"], "enum": ["eslint"],
"default": "eslint" "default": "eslint"
}, },
"unitTestRunner": { "unitTestRunner": {

View File

@ -102,7 +102,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint"], "enum": ["eslint"],
"default": "eslint" "default": "eslint"
}, },
"unitTestRunner": { "unitTestRunner": {
@ -180,7 +180,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint"], "enum": ["eslint"],
"default": "eslint" "default": "eslint"
}, },
"unitTestRunner": { "unitTestRunner": {

View File

@ -136,7 +136,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint"], "enum": ["eslint"],
"default": "eslint" "default": "eslint"
}, },
"routing": { "routing": {
@ -304,7 +304,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint"], "enum": ["eslint"],
"default": "eslint" "default": "eslint"
}, },
"unitTestRunner": { "unitTestRunner": {

View File

@ -161,7 +161,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint", "none"], "enum": ["eslint", "none"],
"default": "eslint" "default": "eslint"
}, },
"js": { "js": {
@ -225,7 +225,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint", "none"], "enum": ["eslint", "none"],
"default": "eslint" "default": "eslint"
}, },
"standaloneConfig": { "standaloneConfig": {

View File

@ -235,7 +235,6 @@
"ts-node": "10.9.1", "ts-node": "10.9.1",
"tsconfig-paths": "^3.9.0", "tsconfig-paths": "^3.9.0",
"tsconfig-paths-webpack-plugin": "3.5.2", "tsconfig-paths-webpack-plugin": "3.5.2",
"tslint": "6.1.3",
"tslint-to-eslint-config": "^2.13.0", "tslint-to-eslint-config": "^2.13.0",
"typedoc": "0.22.9", "typedoc": "0.22.9",
"typedoc-plugin-markdown": "3.11.6", "typedoc-plugin-markdown": "3.11.6",

View File

@ -1,8 +1,9 @@
import { E2eTestRunner, UnitTestRunner } from '../../../utils/test-runners'; import { E2eTestRunner, UnitTestRunner } from '../../../utils/test-runners';
import type { AngularLinter, Schema } from '../schema'; import type { Schema } from '../schema';
import { Linter } from '@nrwl/linter';
export interface NormalizedSchema extends Schema { export interface NormalizedSchema extends Schema {
linter: AngularLinter; linter: Linter;
unitTestRunner: UnitTestRunner; unitTestRunner: UnitTestRunner;
e2eTestRunner: E2eTestRunner; e2eTestRunner: E2eTestRunner;
prefix: string; prefix: string;

View File

@ -2,8 +2,6 @@ import { Linter } from '@nrwl/linter';
import { E2eTestRunner, UnitTestRunner } from '../../utils/test-runners'; import { E2eTestRunner, UnitTestRunner } from '../../utils/test-runners';
import type { Styles } from '../utils/types'; import type { Styles } from '../utils/types';
type AngularLinter = Exclude<Linter, Linter.TsLint>;
export interface Schema { export interface Schema {
name: string; name: string;
addTailwind?: boolean; addTailwind?: boolean;
@ -17,7 +15,7 @@ export interface Schema {
skipTests?: boolean; skipTests?: boolean;
directory?: string; directory?: string;
tags?: string; tags?: string;
linter?: AngularLinter; linter?: Linter;
unitTestRunner?: UnitTestRunner; unitTestRunner?: UnitTestRunner;
e2eTestRunner?: E2eTestRunner; e2eTestRunner?: E2eTestRunner;
backendProject?: string; backendProject?: string;

View File

@ -2,8 +2,6 @@ import { Linter } from '@nrwl/linter';
import { E2eTestRunner, UnitTestRunner } from '../../utils/test-runners'; import { E2eTestRunner, UnitTestRunner } from '../../utils/test-runners';
import type { Styles } from '../utils/types'; import type { Styles } from '../utils/types';
type AngularLinter = Exclude<Linter, Linter.TsLint>;
export interface Schema { export interface Schema {
name: string; name: string;
remotes?: string[]; remotes?: string[];
@ -17,7 +15,7 @@ export interface Schema {
skipTests?: boolean; skipTests?: boolean;
directory?: string; directory?: string;
tags?: string; tags?: string;
linter?: AngularLinter; linter?: Linter;
unitTestRunner?: UnitTestRunner; unitTestRunner?: UnitTestRunner;
e2eTestRunner?: E2eTestRunner; e2eTestRunner?: E2eTestRunner;
backendProject?: string; backendProject?: string;

View File

@ -8,7 +8,7 @@ export interface Schema {
skipFormat?: boolean; skipFormat?: boolean;
skipInstall?: boolean; skipInstall?: boolean;
style?: Styles; style?: Styles;
linter?: Exclude<Linter, Linter.TsLint>; linter?: Linter;
skipPackageJson?: boolean; skipPackageJson?: boolean;
skipPostInstall?: boolean; skipPostInstall?: boolean;
} }

View File

@ -1,5 +1,5 @@
import { UnitTestRunner } from '../../../utils/test-runners'; import { UnitTestRunner } from '../../../utils/test-runners';
import type { AngularLinter } from '../schema'; import type { Linter } from '@nrwl/linter';
export interface NormalizedSchema { export interface NormalizedSchema {
libraryOptions: { libraryOptions: {
@ -28,7 +28,7 @@ export interface NormalizedSchema {
skipPackageJson?: boolean; skipPackageJson?: boolean;
skipPostInstall?: boolean; skipPostInstall?: boolean;
standalone?: boolean; standalone?: boolean;
linter: AngularLinter; linter: Linter;
unitTestRunner: UnitTestRunner; unitTestRunner: UnitTestRunner;
prefix: string; prefix: string;
fileName: string; fileName: string;

View File

@ -1,8 +1,6 @@
import { UnitTestRunner } from '../../utils/test-runners'; import { UnitTestRunner } from '../../utils/test-runners';
import { Linter } from '@nrwl/linter'; import { Linter } from '@nrwl/linter';
type AngularLinter = Exclude<Linter, Linter.TsLint>;
export interface Schema { export interface Schema {
name: string; name: string;
addTailwind?: boolean; addTailwind?: boolean;
@ -24,7 +22,7 @@ export interface Schema {
parent?: string; parent?: string;
tags?: string; tags?: string;
strict?: boolean; strict?: boolean;
linter?: AngularLinter; linter?: Linter;
unitTestRunner?: UnitTestRunner; unitTestRunner?: UnitTestRunner;
compilationMode?: 'full' | 'partial'; compilationMode?: 'full' | 'partial';
setParserOptionsProject?: boolean; setParserOptionsProject?: boolean;

View File

@ -2,8 +2,6 @@ import { Linter } from '@nrwl/linter';
import { E2eTestRunner, UnitTestRunner } from '../../utils/test-runners'; import { E2eTestRunner, UnitTestRunner } from '../../utils/test-runners';
import type { Styles } from '../utils/types'; import type { Styles } from '../utils/types';
type AngularLinter = Exclude<Linter, Linter.TsLint>;
export interface Schema { export interface Schema {
name: string; name: string;
host?: string; host?: string;
@ -16,7 +14,7 @@ export interface Schema {
skipTests?: boolean; skipTests?: boolean;
directory?: string; directory?: string;
tags?: string; tags?: string;
linter?: AngularLinter; linter?: Linter;
unitTestRunner?: UnitTestRunner; unitTestRunner?: UnitTestRunner;
e2eTestRunner?: E2eTestRunner; e2eTestRunner?: E2eTestRunner;
backendProject?: string; backendProject?: string;

View File

@ -4,7 +4,7 @@ export interface StorybookConfigurationOptions {
configureCypress: boolean; configureCypress: boolean;
generateCypressSpecs: boolean; generateCypressSpecs: boolean;
generateStories: boolean; generateStories: boolean;
linter: Exclude<Linter, Linter.TsLint>; linter: Linter;
name: string; name: string;
cypressDirectory?: string; cypressDirectory?: string;
tsConfiguration?: boolean; tsConfiguration?: boolean;

View File

@ -49,16 +49,15 @@ Object {
}, },
}, },
"lint": Object { "lint": Object {
"builder": "@angular-devkit/build-angular:tslint", "builder": "@nrwl/linter:eslint",
"options": Object { "options": Object {
"exclude": Array [ "lintFilePatterns": Array [
"**/node_modules/**", "apps/my-dir/my-app-e2e/**/*.{js,ts}",
"!apps/my-dir/my-app-e2e/**/*",
],
"tsConfig": Array [
"apps/my-dir/my-app-e2e/tsconfig.json",
], ],
}, },
"outputs": Array [
"{options.outputFile}",
],
}, },
} }
`; `;
@ -96,16 +95,15 @@ Object {
}, },
}, },
"lint": Object { "lint": Object {
"builder": "@angular-devkit/build-angular:tslint", "builder": "@nrwl/linter:eslint",
"options": Object { "options": Object {
"exclude": Array [ "lintFilePatterns": Array [
"**/node_modules/**", "apps/my-dir/my-app-e2e/**/*.{js,ts}",
"!apps/my-dir/my-app-e2e/**/*",
],
"tsConfig": Array [
"apps/my-dir/my-app-e2e/tsconfig.json",
], ],
}, },
"outputs": Array [
"{options.outputFile}",
],
}, },
} }
`; `;
@ -122,16 +120,15 @@ Object {
}, },
}, },
"lint": Object { "lint": Object {
"builder": "@angular-devkit/build-angular:tslint", "builder": "@nrwl/linter:eslint",
"options": Object { "options": Object {
"exclude": Array [ "lintFilePatterns": Array [
"**/node_modules/**", "apps/my-app-e2e/**/*.{js,ts}",
"!apps/my-app-e2e/**/*",
],
"tsConfig": Array [
"apps/my-app-e2e/tsconfig.json",
], ],
}, },
"outputs": Array [
"{options.outputFile}",
],
}, },
} }
`; `;
@ -153,16 +150,15 @@ Object {
}, },
}, },
"lint": Object { "lint": Object {
"builder": "@angular-devkit/build-angular:tslint", "builder": "@nrwl/linter:eslint",
"options": Object { "options": Object {
"exclude": Array [ "lintFilePatterns": Array [
"**/node_modules/**", "apps/my-app-e2e/**/*.{js,ts}",
"!apps/my-app-e2e/**/*",
],
"tsConfig": Array [
"apps/my-app-e2e/tsconfig.json",
], ],
}, },
"outputs": Array [
"{options.outputFile}",
],
}, },
} }
`; `;
@ -184,16 +180,15 @@ Object {
}, },
}, },
"lint": Object { "lint": Object {
"builder": "@angular-devkit/build-angular:tslint", "builder": "@nrwl/linter:eslint",
"options": Object { "options": Object {
"exclude": Array [ "lintFilePatterns": Array [
"**/node_modules/**", "apps/my-app-e2e/**/*.{js,ts}",
"!apps/my-app-e2e/**/*",
],
"tsConfig": Array [
"apps/my-app-e2e/tsconfig.json",
], ],
}, },
"outputs": Array [
"{options.outputFile}",
],
}, },
} }
`; `;

View File

@ -323,7 +323,7 @@ describe('Cypress Project', () => {
await cypressProjectGenerator(tree, { await cypressProjectGenerator(tree, {
name: 'my-app-e2e', name: 'my-app-e2e',
project: 'my-app', project: 'my-app',
linter: Linter.TsLint, linter: Linter.EsLint,
standaloneConfig: false, standaloneConfig: false,
}); });
const workspaceJson = readJson(tree, 'workspace.json'); const workspaceJson = readJson(tree, 'workspace.json');
@ -339,7 +339,7 @@ describe('Cypress Project', () => {
name: 'my-app-e2e', name: 'my-app-e2e',
project: 'my-app', project: 'my-app',
baseUrl: 'http://localhost:3000', baseUrl: 'http://localhost:3000',
linter: Linter.TsLint, linter: Linter.EsLint,
standaloneConfig: false, standaloneConfig: false,
}); });
const workspaceJson = readJson(tree, 'workspace.json'); const workspaceJson = readJson(tree, 'workspace.json');
@ -359,7 +359,7 @@ describe('Cypress Project', () => {
await cypressProjectGenerator(tree, { await cypressProjectGenerator(tree, {
name: 'my-app-e2e', name: 'my-app-e2e',
project: 'my-app', project: 'my-app',
linter: Linter.TsLint, linter: Linter.EsLint,
standaloneConfig: false, standaloneConfig: false,
}); });
const workspaceJson = readJson(tree, 'workspace.json'); const workspaceJson = readJson(tree, 'workspace.json');
@ -376,7 +376,7 @@ describe('Cypress Project', () => {
name: 'my-app-e2e', name: 'my-app-e2e',
project: 'my-dir-my-app', project: 'my-dir-my-app',
directory: 'my-dir', directory: 'my-dir',
linter: Linter.TsLint, linter: Linter.EsLint,
standaloneConfig: false, standaloneConfig: false,
}); });
const projectConfig = readJson(tree, 'workspace.json').projects[ const projectConfig = readJson(tree, 'workspace.json').projects[
@ -413,7 +413,7 @@ describe('Cypress Project', () => {
await cypressProjectGenerator(tree, { await cypressProjectGenerator(tree, {
name: 'my-dir/my-app-e2e', name: 'my-dir/my-app-e2e',
project: 'my-dir-my-app', project: 'my-dir-my-app',
linter: Linter.TsLint, linter: Linter.EsLint,
standaloneConfig: false, standaloneConfig: false,
}); });
}); });

View File

@ -33,7 +33,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint", "none"], "enum": ["eslint", "none"],
"default": "eslint" "default": "eslint"
}, },
"js": { "js": {

View File

@ -42,27 +42,6 @@ describe('Add Linting', () => {
expect(project.targets.lint.executor).toEqual('@nrwl/linter:eslint'); expect(project.targets.lint.executor).toEqual('@nrwl/linter:eslint');
}); });
it('should add update `workspace.json` file properly when tslint is passed', () => {
addLinting(tree, {
name: 'my-app-e2e',
projectName: 'my-app-e2e',
projectDirectory: 'apps',
projectRoot: 'apps/my-app-e2e',
project: 'my-app',
appFileName: 'my-app',
appClassName: 'MyApp',
appDisplayName: 'MyApp',
linter: Linter.TsLint,
framework: 'react-native',
});
const project = readProjectConfiguration(tree, 'my-app-e2e');
expect(project.targets.lint).toBeDefined();
expect(project.targets.lint.executor).toEqual(
'@angular-devkit/build-angular:tslint'
);
});
it('should not add lint target when "none" is passed', async () => { it('should not add lint target when "none" is passed', async () => {
addLinting(tree, { addLinting(tree, {
name: 'my-app-e2e', name: 'my-app-e2e',

View File

@ -3,10 +3,10 @@ import { Linter, lintProjectGenerator } from '@nrwl/linter';
import { import {
addDependenciesToPackageJson, addDependenciesToPackageJson,
joinPathFragments, joinPathFragments,
updateJson,
Tree, Tree,
updateJson,
} from '@nrwl/devkit'; } from '@nrwl/devkit';
import { extraEslintDependencies, createReactEslintJson } from '@nrwl/react'; import { createReactEslintJson, extraEslintDependencies } from '@nrwl/react';
import { NormalizedSchema } from './normalize-options'; import { NormalizedSchema } from './normalize-options';
export async function addLinting(host: Tree, options: NormalizedSchema) { export async function addLinting(host: Tree, options: NormalizedSchema) {
@ -24,10 +24,6 @@ export async function addLinting(host: Tree, options: NormalizedSchema) {
skipFormat: true, skipFormat: true,
}); });
if (options.linter === Linter.TsLint) {
return () => {};
}
const reactEslintJson = createReactEslintJson( const reactEslintJson = createReactEslintJson(
options.projectRoot, options.projectRoot,
options.setParserOptionsProject options.setParserOptionsProject

View File

@ -34,7 +34,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint", "none"], "enum": ["eslint", "none"],
"default": "eslint" "default": "eslint"
}, },
"js": { "js": {

View File

@ -41,7 +41,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint"], "enum": ["eslint"],
"default": "eslint" "default": "eslint"
}, },
"unitTestRunner": { "unitTestRunner": {

View File

@ -29,7 +29,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint"], "enum": ["eslint"],
"default": "eslint" "default": "eslint"
}, },
"unitTestRunner": { "unitTestRunner": {

View File

@ -29,22 +29,6 @@ describe('Add Linting', () => {
expect(project.targets.lint.executor).toEqual('@nrwl/linter:eslint'); expect(project.targets.lint.executor).toEqual('@nrwl/linter:eslint');
}); });
it('should add update `project configuration` file properly when tslint is passed', () => {
addLinting(
tree,
'my-lib',
'libs/my-lib',
['libs/my-lib/tsconfig.lib.json'],
Linter.TsLint
);
const project = readProjectConfiguration(tree, 'my-lib');
expect(project.targets.lint).toBeDefined();
expect(project.targets.lint.executor).toEqual(
'@angular-devkit/build-angular:tslint'
);
});
it('should not add lint target when "none" is passed', async () => { it('should not add lint target when "none" is passed', async () => {
addLinting( addLinting(
tree, tree,

View File

@ -3,10 +3,10 @@ import { Linter, lintProjectGenerator } from '@nrwl/linter';
import { import {
addDependenciesToPackageJson, addDependenciesToPackageJson,
joinPathFragments, joinPathFragments,
updateJson,
Tree, Tree,
updateJson,
} from '@nrwl/devkit'; } from '@nrwl/devkit';
import { extraEslintDependencies, createReactEslintJson } from '@nrwl/react'; import { createReactEslintJson, extraEslintDependencies } from '@nrwl/react';
import type { Linter as ESLintLinter } from 'eslint'; import type { Linter as ESLintLinter } from 'eslint';
export async function addLinting( export async function addLinting(
@ -29,10 +29,6 @@ export async function addLinting(
skipFormat: true, skipFormat: true,
}); });
if (linter === Linter.TsLint) {
return () => {};
}
const reactEslintJson = createReactEslintJson( const reactEslintJson = createReactEslintJson(
appProjectRoot, appProjectRoot,
setParserOptionsProject setParserOptionsProject

View File

@ -12,7 +12,6 @@
"Monorepo", "Monorepo",
"Web", "Web",
"Lint", "Lint",
"TSLint",
"ESLint", "ESLint",
"CLI" "CLI"
], ],

View File

@ -59,96 +59,3 @@ exports[`@nrwl/linter:init --linter eslint should generate the global eslint con
} }
" "
`; `;
exports[`@nrwl/linter:init --linter tslint should generate the global tslint config 1`] = `
"{
\\"rulesDirectory\\": [
\\"node_modules/@nrwl/workspace/src/tslint\\"
],
\\"linterOptions\\": {
\\"exclude\\": [
\\"**/*\\"
]
},
\\"rules\\": {
\\"arrow-return-shorthand\\": true,
\\"callable-types\\": true,
\\"class-name\\": true,
\\"deprecation\\": {
\\"severity\\": \\"warn\\"
},
\\"forin\\": true,
\\"import-blacklist\\": [
true,
\\"rxjs/Rx\\"
],
\\"interface-over-type-literal\\": true,
\\"member-access\\": false,
\\"member-ordering\\": [
true,
{
\\"order\\": [
\\"static-field\\",
\\"instance-field\\",
\\"static-method\\",
\\"instance-method\\"
]
}
],
\\"no-arg\\": true,
\\"no-bitwise\\": true,
\\"no-console\\": [
true,
\\"debug\\",
\\"info\\",
\\"time\\",
\\"timeEnd\\",
\\"trace\\"
],
\\"no-construct\\": true,
\\"no-debugger\\": true,
\\"no-duplicate-super\\": true,
\\"no-empty\\": false,
\\"no-empty-interface\\": true,
\\"no-eval\\": true,
\\"no-inferrable-types\\": [
true,
\\"ignore-params\\"
],
\\"no-misused-new\\": true,
\\"no-non-null-assertion\\": true,
\\"no-shadowed-variable\\": true,
\\"no-string-literal\\": false,
\\"no-string-throw\\": true,
\\"no-switch-case-fall-through\\": true,
\\"no-unnecessary-initializer\\": true,
\\"no-unused-expression\\": true,
\\"no-var-keyword\\": true,
\\"object-literal-sort-keys\\": false,
\\"prefer-const\\": true,
\\"radix\\": true,
\\"triple-equals\\": [
true,
\\"allow-null-check\\"
],
\\"unified-signatures\\": true,
\\"variable-name\\": false,
\\"nx-enforce-module-boundaries\\": [
true,
{
\\"enforceBuildableLibDependency\\": true,
\\"allow\\": [],
\\"depConstraints\\": [
{
\\"sourceTag\\": \\"*\\",
\\"onlyDependOnLibsWithTags\\": [
\\"*\\"
]
}
]
}
]
}
}
"
`;

View File

@ -40,15 +40,5 @@ describe('@nrwl/linter:init', () => {
expect(tree.exists('.eslintrc.json')).toBe(false); expect(tree.exists('.eslintrc.json')).toBe(false);
}); });
}); });
describe('tslint', () => {
it('should generate the global tslint config', async () => {
await lintInitGenerator(tree, {
linter: Linter.TsLint,
});
expect(tree.read('tslint.json', 'utf-8')).toMatchSnapshot();
});
});
}); });
}); });

View File

@ -8,11 +8,9 @@ import {
writeJson, writeJson,
} from '@nrwl/devkit'; } from '@nrwl/devkit';
import { import {
buildAngularVersion,
eslintConfigPrettierVersion, eslintConfigPrettierVersion,
eslintVersion, eslintVersion,
nxVersion, nxVersion,
tslintVersion,
typescriptESLintVersion, typescriptESLintVersion,
} from '../../utils/versions'; } from '../../utils/versions';
@ -26,70 +24,6 @@ export interface LinterInitOptions {
skipPackageJson?: boolean; skipPackageJson?: boolean;
} }
const globalTsLintConfiguration = {
rulesDirectory: ['node_modules/@nrwl/workspace/src/tslint'],
linterOptions: {
exclude: ['**/*'],
},
rules: {
'arrow-return-shorthand': true,
'callable-types': true,
'class-name': true,
deprecation: {
severity: 'warn',
},
forin: true,
'import-blacklist': [true, 'rxjs/Rx'],
'interface-over-type-literal': true,
'member-access': false,
'member-ordering': [
true,
{
order: [
'static-field',
'instance-field',
'static-method',
'instance-method',
],
},
],
'no-arg': true,
'no-bitwise': true,
'no-console': [true, 'debug', 'info', 'time', 'timeEnd', 'trace'],
'no-construct': true,
'no-debugger': true,
'no-duplicate-super': true,
'no-empty': false,
'no-empty-interface': true,
'no-eval': true,
'no-inferrable-types': [true, 'ignore-params'],
'no-misused-new': true,
'no-non-null-assertion': true,
'no-shadowed-variable': true,
'no-string-literal': false,
'no-string-throw': true,
'no-switch-case-fall-through': true,
'no-unnecessary-initializer': true,
'no-unused-expression': true,
'no-var-keyword': true,
'object-literal-sort-keys': false,
'prefer-const': true,
radix: true,
'triple-equals': [true, 'allow-null-check'],
'unified-signatures': true,
'variable-name': false,
'nx-enforce-module-boundaries': [
true,
{
enforceBuildableLibDependency: true,
allow: [],
depConstraints: [{ sourceTag: '*', onlyDependOnLibsWithTags: ['*'] }],
},
],
},
};
const getGlobalEsLintConfiguration = (unitTestRunner?: string) => { const getGlobalEsLintConfiguration = (unitTestRunner?: string) => {
const config: ESLint.ConfigData = { const config: ESLint.ConfigData = {
root: true, root: true,
@ -164,24 +98,6 @@ const getGlobalEsLintConfiguration = (unitTestRunner?: string) => {
return config; return config;
}; };
function initTsLint(tree: Tree, options: LinterInitOptions): GeneratorCallback {
if (tree.exists('/tslint.json')) {
return () => {};
}
writeJson(tree, 'tslint.json', globalTsLintConfiguration);
return !options.skipPackageJson
? addDependenciesToPackageJson(
tree,
{},
{
tslint: tslintVersion,
'@angular-devkit/build-angular': buildAngularVersion,
}
)
: () => {};
}
function addTargetDefaults(tree: Tree) { function addTargetDefaults(tree: Tree) {
const workspaceConfiguration = readWorkspaceConfiguration(tree); const workspaceConfiguration = readWorkspaceConfiguration(tree);
@ -249,9 +165,5 @@ function initEsLint(tree: Tree, options: LinterInitOptions): GeneratorCallback {
} }
export function lintInitGenerator(tree: Tree, options: LinterInitOptions) { export function lintInitGenerator(tree: Tree, options: LinterInitOptions) {
if (!options.linter || options.linter === Linter.EsLint) {
return initEsLint(tree, options); return initEsLint(tree, options);
} else if (options.linter === Linter.TsLint) {
return initTsLint(tree, options);
}
} }

View File

@ -73,16 +73,3 @@ exports[`@nrwl/linter:lint-project --linter eslint should generate a eslint conf
} }
" "
`; `;
exports[`@nrwl/linter:lint-project --linter tslint should generate a tslint config 1`] = `
"{
\\"extends\\": \\"../../tslint.json\\",
\\"linterOptions\\": {
\\"exclude\\": [
\\"!**/*\\"
]
},
\\"rules\\": {}
}
"
`;

View File

@ -1,7 +1,7 @@
import { import {
Tree,
addProjectConfiguration, addProjectConfiguration,
readProjectConfiguration, readProjectConfiguration,
Tree,
} from '@nrwl/devkit'; } from '@nrwl/devkit';
import { Linter } from '../utils/linter'; import { Linter } from '../utils/linter';
@ -80,47 +80,5 @@ describe('@nrwl/linter:lint-project', () => {
).toMatchSnapshot(); ).toMatchSnapshot();
}); });
}); });
describe('tslint', () => {
it('should generate a tslint config', async () => {
await lintProjectGenerator(tree, {
...defaultOptions,
linter: Linter.TsLint,
tsConfigPaths: ['tsconfig.json'],
project: 'test-lib',
setParserOptionsProject: false,
});
expect(
tree.read('libs/test-lib/tslint.json', 'utf-8')
).toMatchSnapshot();
});
it('should configure the target in project configuration', async () => {
await lintProjectGenerator(tree, {
...defaultOptions,
linter: Linter.TsLint,
tsConfigPaths: ['tsconfig.json'],
project: 'test-lib',
setParserOptionsProject: false,
});
const projectConfig = readProjectConfiguration(tree, 'test-lib');
expect(projectConfig.targets.lint).toMatchInlineSnapshot(`
Object {
"executor": "@angular-devkit/build-angular:tslint",
"options": Object {
"exclude": Array [
"**/node_modules/**",
"!libs/test-lib/**/*",
],
"tsConfig": Array [
"tsconfig.json",
],
},
}
`);
});
});
}); });
}); });

View File

@ -23,20 +23,6 @@ interface LintProjectOptions {
unitTestRunner?: string; unitTestRunner?: string;
} }
function createTsLintConfiguration(
tree: Tree,
projectConfig: ProjectConfiguration
) {
writeJson(tree, join(projectConfig.root, `tslint.json`), {
extends: `${offsetFromRoot(projectConfig.root)}tslint.json`,
// Include project files to be linted since the global one excludes all files.
linterOptions: {
exclude: ['!**/*'],
},
rules: {},
});
}
function createEsLintConfiguration( function createEsLintConfiguration(
tree: Tree, tree: Tree,
projectConfig: ProjectConfiguration, projectConfig: ProjectConfiguration,
@ -99,7 +85,6 @@ export async function lintProjectGenerator(
}); });
const projectConfig = readProjectConfiguration(tree, options.project); const projectConfig = readProjectConfiguration(tree, options.project);
if (options.linter === Linter.EsLint) {
projectConfig.targets['lint'] = { projectConfig.targets['lint'] = {
executor: '@nrwl/linter:eslint', executor: '@nrwl/linter:eslint',
outputs: ['{options.outputFile}'], outputs: ['{options.outputFile}'],
@ -112,16 +97,6 @@ export async function lintProjectGenerator(
projectConfig, projectConfig,
options.setParserOptionsProject options.setParserOptionsProject
); );
} else {
projectConfig.targets['lint'] = {
executor: '@angular-devkit/build-angular:tslint',
options: {
tsConfig: options.tsConfigPaths,
exclude: ['**/node_modules/**', `!${projectConfig.root}/**/*`],
},
};
createTsLintConfiguration(tree, projectConfig);
}
updateProjectConfiguration(tree, options.project, projectConfig); updateProjectConfiguration(tree, options.project, projectConfig);

View File

@ -1,5 +1,4 @@
export enum Linter { export enum Linter {
EsLint = 'eslint', EsLint = 'eslint',
TsLint = 'tslint',
None = 'none', None = 'none',
} }

View File

@ -1,6 +1,5 @@
export const nxVersion = require('../../package.json').version; export const nxVersion = require('../../package.json').version;
export const tslintVersion = '~6.1.0';
export const tslintToEslintConfigVersion = '^2.13.0'; export const tslintToEslintConfigVersion = '^2.13.0';
export const buildAngularVersion = '~14.2.0'; export const buildAngularVersion = '~14.2.0';

View File

@ -1,6 +1,5 @@
import { Linter } from '@nrwl/linter';
import { createTreeWithEmptyV1Workspace } from '@nrwl/devkit/testing'; import { createTreeWithEmptyV1Workspace } from '@nrwl/devkit/testing';
import { getProjects, readJson, NxJsonConfiguration, Tree } from '@nrwl/devkit'; import { getProjects, NxJsonConfiguration, readJson, Tree } from '@nrwl/devkit';
import { applicationGenerator } from './application'; import { applicationGenerator } from './application';
@ -403,30 +402,6 @@ describe('app', () => {
`); `);
}); });
}); });
describe('tslint', () => {
it('should generate files', async () => {
await applicationGenerator(tree, {
name: 'myApp',
style: 'css',
linter: Linter.TsLint,
standaloneConfig: false,
});
const tslintJson = readJson(tree, 'apps/my-app/tslint.json');
expect(tslintJson).toMatchInlineSnapshot(`
Object {
"extends": "../../tslint.json",
"linterOptions": Object {
"exclude": Array [
"!**/*",
],
},
"rules": Object {},
}
`);
});
});
}); });
describe('--js', () => { describe('--js', () => {

View File

@ -71,7 +71,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint"], "enum": ["eslint"],
"default": "eslint" "default": "eslint"
}, },
"skipFormat": { "skipFormat": {

View File

@ -75,7 +75,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint"], "enum": ["eslint"],
"default": "eslint" "default": "eslint"
}, },
"unitTestRunner": { "unitTestRunner": {

View File

@ -32,7 +32,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint"], "enum": ["eslint"],
"default": "eslint" "default": "eslint"
}, },
"unitTestRunner": { "unitTestRunner": {

View File

@ -34,7 +34,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint"], "enum": ["eslint"],
"default": "eslint" "default": "eslint"
}, },
"unitTestRunner": { "unitTestRunner": {

View File

@ -42,7 +42,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint"], "enum": ["eslint"],
"default": "eslint" "default": "eslint"
}, },
"unitTestRunner": { "unitTestRunner": {

View File

@ -15,7 +15,7 @@ describe('react-native:component-story', () => {
describe('default setup', () => { describe('default setup', () => {
beforeEach(async () => { beforeEach(async () => {
appTree = await createTestUILib('test-ui-lib', true); appTree = await createTestUILib('test-ui-lib');
}); });
describe('when file does not contain a component', () => { describe('when file does not contain a component', () => {
@ -376,7 +376,7 @@ describe('react-native:component-story', () => {
describe('using eslint', () => { describe('using eslint', () => {
beforeEach(async () => { beforeEach(async () => {
appTree = await createTestUILib('test-ui-lib', false); appTree = await createTestUILib('test-ui-lib');
await componentGenerator(appTree, { await componentGenerator(appTree, {
name: 'test-ui-lib', name: 'test-ui-lib',
project: 'test-ui-lib', project: 'test-ui-lib',
@ -404,16 +404,13 @@ describe('react-native:component-story', () => {
}); });
}); });
export async function createTestUILib( export async function createTestUILib(libName: string): Promise<Tree> {
libName: string,
useEsLint = false
): Promise<Tree> {
let appTree = createTreeWithEmptyWorkspace(); let appTree = createTreeWithEmptyWorkspace();
appTree.write('.gitignore', ''); appTree.write('.gitignore', '');
await libraryGenerator(appTree, { await libraryGenerator(appTree, {
name: libName, name: libName,
linter: useEsLint ? Linter.EsLint : Linter.TsLint, linter: Linter.EsLint,
skipFormat: true, skipFormat: true,
skipTsConfig: false, skipTsConfig: false,
unitTestRunner: 'jest', unitTestRunner: 'jest',
@ -425,14 +422,12 @@ export async function createTestUILib(
export: true, export: true,
}); });
if (useEsLint) {
const currentWorkspaceJson = getProjects(appTree); const currentWorkspaceJson = getProjects(appTree);
const projectConfig = currentWorkspaceJson.get(libName); const projectConfig = currentWorkspaceJson.get(libName);
projectConfig.targets.lint.options.linter = 'eslint'; projectConfig.targets.lint.options.linter = 'eslint';
updateProjectConfiguration(appTree, libName, projectConfig); updateProjectConfiguration(appTree, libName, projectConfig);
}
return appTree; return appTree;
} }

View File

@ -30,7 +30,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint"], "enum": ["eslint"],
"default": "eslint" "default": "eslint"
}, },
"unitTestRunner": { "unitTestRunner": {

View File

@ -28,21 +28,6 @@ describe('Add Linting', () => {
expect(project.targets.lint.executor).toEqual('@nrwl/linter:eslint'); expect(project.targets.lint.executor).toEqual('@nrwl/linter:eslint');
}); });
it('should add update `workspace.json` file properly when tslint is passed', () => {
addLinting(tree, {
projectName: 'my-lib',
linter: Linter.TsLint,
tsConfigPaths: ['libs/my-lib/tsconfig.lib.json'],
projectRoot: 'libs/my-lib',
});
const project = readProjectConfiguration(tree, 'my-lib');
expect(project.targets.lint).toBeDefined();
expect(project.targets.lint.executor).toEqual(
'@angular-devkit/build-angular:tslint'
);
});
it('should not add lint target when "none" is passed', async () => { it('should not add lint target when "none" is passed', async () => {
addLinting(tree, { addLinting(tree, {
projectName: 'my-lib', projectName: 'my-lib',

View File

@ -3,10 +3,10 @@ import { Linter, lintProjectGenerator } from '@nrwl/linter';
import { import {
addDependenciesToPackageJson, addDependenciesToPackageJson,
joinPathFragments, joinPathFragments,
updateJson,
Tree, Tree,
updateJson,
} from '@nrwl/devkit'; } from '@nrwl/devkit';
import { extraEslintDependencies, createReactEslintJson } from '@nrwl/react'; import { createReactEslintJson, extraEslintDependencies } from '@nrwl/react';
import type { Linter as ESLintLinter } from 'eslint'; import type { Linter as ESLintLinter } from 'eslint';
interface NormalizedSchema { interface NormalizedSchema {
@ -30,10 +30,6 @@ export async function addLinting(host: Tree, options: NormalizedSchema) {
skipFormat: true, skipFormat: true,
}); });
if (options.linter === Linter.TsLint) {
return () => {};
}
const reactEslintJson = createReactEslintJson( const reactEslintJson = createReactEslintJson(
options.projectRoot, options.projectRoot,
options.setParserOptionsProject options.setParserOptionsProject

View File

@ -82,7 +82,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint"], "enum": ["eslint"],
"default": "eslint" "default": "eslint"
}, },
"routing": { "routing": {

View File

@ -12,7 +12,7 @@ describe('react:component-story', () => {
describe('default setup', () => { describe('default setup', () => {
beforeEach(async () => { beforeEach(async () => {
appTree = await createTestUILib('test-ui-lib', true); appTree = await createTestUILib('test-ui-lib');
}); });
describe('when file does not contain a component', () => { describe('when file does not contain a component', () => {
@ -677,7 +677,7 @@ describe('react:component-story', () => {
describe('using eslint', () => { describe('using eslint', () => {
beforeEach(async () => { beforeEach(async () => {
appTree = await createTestUILib('test-ui-lib', false); appTree = await createTestUILib('test-ui-lib');
await componentStoryGenerator(appTree, { await componentStoryGenerator(appTree, {
componentPath: 'lib/test-ui-lib.tsx', componentPath: 'lib/test-ui-lib.tsx',
project: 'test-ui-lib', project: 'test-ui-lib',
@ -705,14 +705,11 @@ describe('react:component-story', () => {
}); });
}); });
export async function createTestUILib( export async function createTestUILib(libName: string): Promise<Tree> {
libName: string,
useEsLint = false
): Promise<Tree> {
let appTree = createTreeWithEmptyV1Workspace(); let appTree = createTreeWithEmptyV1Workspace();
await libraryGenerator(appTree, { await libraryGenerator(appTree, {
name: libName, name: libName,
linter: useEsLint ? Linter.EsLint : Linter.TsLint, linter: Linter.EsLint,
component: true, component: true,
skipFormat: true, skipFormat: true,
skipTsConfig: false, skipTsConfig: false,
@ -721,14 +718,12 @@ export async function createTestUILib(
standaloneConfig: false, standaloneConfig: false,
}); });
if (useEsLint) {
const currentWorkspaceJson = getProjects(appTree); const currentWorkspaceJson = getProjects(appTree);
const projectConfig = currentWorkspaceJson.get(libName); const projectConfig = currentWorkspaceJson.get(libName);
projectConfig.targets.lint.options.linter = 'eslint'; projectConfig.targets.lint.options.linter = 'eslint';
updateProjectConfiguration(appTree, libName, projectConfig); updateProjectConfiguration(appTree, libName, projectConfig);
}
return appTree; return appTree;
} }

View File

@ -19,7 +19,7 @@ import {
import { getImportPath } from 'nx/src/utils/path'; import { getImportPath } from 'nx/src/utils/path';
import { jestProjectGenerator } from '@nrwl/jest'; import { jestProjectGenerator } from '@nrwl/jest';
import { swcCoreVersion } from '@nrwl/js/src/utils/versions'; import { swcCoreVersion } from '@nrwl/js/src/utils/versions';
import { Linter, lintProjectGenerator } from '@nrwl/linter'; import { lintProjectGenerator } from '@nrwl/linter';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial'; import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
import { import {
getRelativePathToRootTsConfig, getRelativePathToRootTsConfig,
@ -152,10 +152,6 @@ async function addLinting(host: Tree, options: NormalizedSchema) {
skipFormat: true, skipFormat: true,
}); });
if (options.linter === Linter.TsLint) {
return;
}
const reactEslintJson = createReactEslintJson( const reactEslintJson = createReactEslintJson(
options.projectRoot, options.projectRoot,
options.setParserOptionsProject options.setParserOptionsProject

View File

@ -75,7 +75,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint"], "enum": ["eslint"],
"default": "eslint" "default": "eslint"
}, },
"unitTestRunner": { "unitTestRunner": {

View File

@ -135,7 +135,7 @@ function normalizeSchema(
): StorybookConfigureSchema { ): StorybookConfigureSchema {
const defaults = { const defaults = {
configureCypress: true, configureCypress: true,
linter: Linter.TsLint, linter: Linter.EsLint,
js: false, js: false,
}; };
return { return {

View File

@ -44,7 +44,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint", "none"], "enum": ["eslint", "none"],
"default": "eslint" "default": "eslint"
}, },
"js": { "js": {

View File

@ -262,7 +262,7 @@ export function normalizeSchema(
): StorybookConfigureSchema { ): StorybookConfigureSchema {
const defaults = { const defaults = {
configureCypress: true, configureCypress: true,
linter: Linter.TsLint, linter: Linter.EsLint,
js: false, js: false,
}; };
return { return {

View File

@ -29,7 +29,7 @@
"linter": { "linter": {
"description": "The tool to use for running lint checks.", "description": "The tool to use for running lint checks.",
"type": "string", "type": "string",
"enum": ["eslint", "tslint", "none"], "enum": ["eslint", "none"],
"default": "eslint" "default": "eslint"
}, },
"standaloneConfig": { "standaloneConfig": {

View File

@ -1,7 +1,7 @@
import { import {
readProjectConfiguration,
getProjects, getProjects,
readJson, readJson,
readProjectConfiguration,
Tree, Tree,
updateJson, updateJson,
} from '@nrwl/devkit'; } from '@nrwl/devkit';
@ -496,64 +496,6 @@ describe('lib', () => {
}); });
}); });
}); });
describe('tslint', () => {
it('should add tslint dependencies', async () => {
await libraryGenerator(tree, {
...defaultOptions,
name: 'myLib',
linter: 'tslint',
});
const packageJson = readJson(tree, 'package.json');
expect(packageJson.devDependencies['tslint']).toBeDefined();
expect(
packageJson.devDependencies['@angular-devkit/build-angular']
).toBeDefined();
});
it('should update workspace.json', async () => {
await libraryGenerator(tree, {
...defaultOptions,
name: 'myLib',
directory: 'myDir',
linter: 'tslint',
});
const workspaceJson = readJson(tree, 'workspace.json');
expect(workspaceJson.projects['my-dir-my-lib'].architect.lint).toEqual({
builder: '@angular-devkit/build-angular:tslint',
options: {
exclude: ['**/node_modules/**', '!libs/my-dir/my-lib/**/*'],
tsConfig: [
'libs/my-dir/my-lib/tsconfig.lib.json',
'libs/my-dir/my-lib/tsconfig.spec.json',
],
},
});
});
it('should create a local tslint.json', async () => {
await libraryGenerator(tree, {
...defaultOptions,
name: 'myLib',
directory: 'myDir',
linter: 'tslint',
});
const tslintJson = readJson(tree, 'libs/my-dir/my-lib/tslint.json');
expect(tslintJson).toMatchInlineSnapshot(`
Object {
"extends": "../../../tslint.json",
"linterOptions": Object {
"exclude": Array [
"!**/*",
],
},
"rules": Object {},
}
`);
});
});
}); });
describe('--unit-test-runner none', () => { describe('--unit-test-runner none', () => {