diff --git a/docs/generated/packages/express.json b/docs/generated/packages/express.json index e07a4e467d..42a37810b8 100644 --- a/docs/generated/packages/express.json +++ b/docs/generated/packages/express.json @@ -82,7 +82,7 @@ "linter": { "description": "The tool to use for running lint checks.", "type": "string", - "enum": ["eslint", "tslint"], + "enum": ["eslint"], "default": "eslint" }, "unitTestRunner": { diff --git a/docs/generated/packages/linter.json b/docs/generated/packages/linter.json index 217f300221..90f1ad1beb 100644 --- a/docs/generated/packages/linter.json +++ b/docs/generated/packages/linter.json @@ -104,14 +104,14 @@ "linter": { "description": "The tool to use for running lint checks.", "type": "string", - "enum": ["eslint", "tslint"], + "enum": ["eslint"], "default": "eslint" }, "config": { "type": "string", "description": "The name of the configuration file.", "x-completion-type": "file", - "x-completion-glob": "(tslint.json|.eslintrc.json)" + "x-completion-glob": ".eslintrc.json)" }, "tsConfig": { "description": "The name of the TypeScript configuration file.", diff --git a/docs/generated/packages/nx-plugin.json b/docs/generated/packages/nx-plugin.json index 28a2b04ac6..7e703c06df 100644 --- a/docs/generated/packages/nx-plugin.json +++ b/docs/generated/packages/nx-plugin.json @@ -50,9 +50,8 @@ "linter": { "description": "The tool to use for running lint checks.", "type": "string", - "enum": ["eslint", "tslint"], - "default": "eslint", - "x-deprecated": "TSLint support is deprecated and will be removed" + "enum": ["eslint"], + "default": "eslint" }, "unitTestRunner": { "type": "string", diff --git a/docs/generated/packages/react-native.json b/docs/generated/packages/react-native.json index 5275bf95a1..9a681008b0 100644 --- a/docs/generated/packages/react-native.json +++ b/docs/generated/packages/react-native.json @@ -375,7 +375,7 @@ "linter": { "description": "The tool to use for running lint checks.", "type": "string", - "enum": ["eslint", "tslint"], + "enum": ["eslint"], "default": "eslint" }, "standaloneConfig": { diff --git a/docs/generated/packages/react.json b/docs/generated/packages/react.json index c44e9ef1bb..8c90c49ed6 100644 --- a/docs/generated/packages/react.json +++ b/docs/generated/packages/react.json @@ -645,7 +645,7 @@ "linter": { "description": "The tool to use for running lint checks.", "type": "string", - "enum": ["eslint", "tslint"], + "enum": ["eslint"], "default": "eslint" }, "standaloneConfig": { @@ -956,7 +956,7 @@ "linter": { "description": "The tool to use for running lint checks.", "type": "string", - "enum": ["eslint", "tslint"], + "enum": ["eslint"], "default": "eslint" }, "skipFormat": { @@ -1113,7 +1113,7 @@ "linter": { "description": "The tool to use for running lint checks.", "type": "string", - "enum": ["eslint", "tslint"], + "enum": ["eslint"], "default": "eslint" }, "routing": { diff --git a/docs/generated/packages/web.json b/docs/generated/packages/web.json index 48b57f1d5d..0b80248a78 100644 --- a/docs/generated/packages/web.json +++ b/docs/generated/packages/web.json @@ -120,7 +120,7 @@ "linter": { "description": "The tool to use for running lint checks.", "type": "string", - "enum": ["eslint", "tslint"], + "enum": ["eslint"], "default": "eslint" }, "skipFormat": { diff --git a/docs/generated/packages/workspace.json b/docs/generated/packages/workspace.json index 4475471915..8ecd334675 100644 --- a/docs/generated/packages/workspace.json +++ b/docs/generated/packages/workspace.json @@ -135,7 +135,7 @@ "linter": { "description": "The tool to use for running lint checks.", "type": "string", - "enum": ["tslint", "eslint"], + "enum": ["eslint"], "default": "eslint" }, "style": { @@ -340,7 +340,7 @@ "linter": { "description": "The tool to use for running lint checks.", "type": "string", - "enum": ["tslint", "eslint"], + "enum": ["eslint"], "default": "eslint" }, "packageManager": { diff --git a/packages/angular/src/generators/ng-add/schema.d.ts b/packages/angular/src/generators/ng-add/schema.d.ts index bcf0cd5a20..0bb8242b86 100644 --- a/packages/angular/src/generators/ng-add/schema.d.ts +++ b/packages/angular/src/generators/ng-add/schema.d.ts @@ -14,6 +14,6 @@ export interface GeneratorOptions { skipInstall?: boolean; skipPostInstall?: boolean; style?: Styles; - linter?: Exclude; + linter?: Linter; skipPackageJson?: boolean; } diff --git a/packages/express/src/generators/application/schema.json b/packages/express/src/generators/application/schema.json index 592b92a596..25814fe806 100644 --- a/packages/express/src/generators/application/schema.json +++ b/packages/express/src/generators/application/schema.json @@ -33,7 +33,7 @@ "linter": { "description": "The tool to use for running lint checks.", "type": "string", - "enum": ["eslint", "tslint"], + "enum": ["eslint"], "default": "eslint" }, "unitTestRunner": { diff --git a/packages/linter/src/executors/lint/schema.json b/packages/linter/src/executors/lint/schema.json index fd3d13999f..0de2da7043 100644 --- a/packages/linter/src/executors/lint/schema.json +++ b/packages/linter/src/executors/lint/schema.json @@ -8,14 +8,14 @@ "linter": { "description": "The tool to use for running lint checks.", "type": "string", - "enum": ["eslint", "tslint"], + "enum": ["eslint"], "default": "eslint" }, "config": { "type": "string", "description": "The name of the configuration file.", "x-completion-type": "file", - "x-completion-glob": "(tslint.json|.eslintrc.json)" + "x-completion-glob": ".eslintrc.json)" }, "tsConfig": { "description": "The name of the TypeScript configuration file.", @@ -57,7 +57,9 @@ "tap" ] }, - { "minLength": 1 } + { + "minLength": 1 + } ] }, "exclude": { diff --git a/packages/nest/src/generators/application/schema.d.ts b/packages/nest/src/generators/application/schema.d.ts index f7bfeac433..aa84089021 100644 --- a/packages/nest/src/generators/application/schema.d.ts +++ b/packages/nest/src/generators/application/schema.d.ts @@ -5,7 +5,7 @@ export interface ApplicationGeneratorOptions { name: string; directory?: string; frontendProject?: string; - linter?: Exclude; + linter?: Linter; skipFormat?: boolean; skipPackageJson?: boolean; standaloneConfig?: boolean; diff --git a/packages/nest/src/generators/library/schema.d.ts b/packages/nest/src/generators/library/schema.d.ts index 2da8db1ae7..2d70cc283a 100644 --- a/packages/nest/src/generators/library/schema.d.ts +++ b/packages/nest/src/generators/library/schema.d.ts @@ -8,7 +8,7 @@ export interface LibraryGeneratorOptions { directory?: string; global?: boolean; importPath?: string; - linter?: Exclude; + linter?: Linter; publishable?: boolean; service?: boolean; skipFormat?: boolean; diff --git a/packages/nx-plugin/src/generators/plugin/schema.json b/packages/nx-plugin/src/generators/plugin/schema.json index 600c785657..3ded3c7904 100644 --- a/packages/nx-plugin/src/generators/plugin/schema.json +++ b/packages/nx-plugin/src/generators/plugin/schema.json @@ -33,9 +33,8 @@ "linter": { "description": "The tool to use for running lint checks.", "type": "string", - "enum": ["eslint", "tslint"], - "default": "eslint", - "x-deprecated": "TSLint support is deprecated and will be removed" + "enum": ["eslint"], + "default": "eslint" }, "unitTestRunner": { "type": "string", diff --git a/packages/nx/src/utils/versions.ts b/packages/nx/src/utils/versions.ts index 9c0f61b4d3..a2832d6995 100644 --- a/packages/nx/src/utils/versions.ts +++ b/packages/nx/src/utils/versions.ts @@ -3,7 +3,6 @@ export const nxVersion = require('../../package.json').version; export const angularCliVersion = '~14.2.0'; export const typescriptVersion = '~4.8.2'; export const prettierVersion = '^2.6.2'; -export const tslintVersion = '~6.1.0'; export const typescriptESLintVersion = '^5.36.1'; export const eslintVersion = '~8.15.0'; export const eslintConfigPrettierVersion = '8.1.0'; diff --git a/packages/react-native/src/generators/storybook-configuration/schema.json b/packages/react-native/src/generators/storybook-configuration/schema.json index c9bc36ae29..0240b71a66 100644 --- a/packages/react-native/src/generators/storybook-configuration/schema.json +++ b/packages/react-native/src/generators/storybook-configuration/schema.json @@ -36,7 +36,7 @@ "linter": { "description": "The tool to use for running lint checks.", "type": "string", - "enum": ["eslint", "tslint"], + "enum": ["eslint"], "default": "eslint" }, "standaloneConfig": { diff --git a/packages/react/src/generators/host/schema.json b/packages/react/src/generators/host/schema.json index c27004797c..9ff31ea0fd 100644 --- a/packages/react/src/generators/host/schema.json +++ b/packages/react/src/generators/host/schema.json @@ -68,7 +68,7 @@ "linter": { "description": "The tool to use for running lint checks.", "type": "string", - "enum": ["eslint", "tslint"], + "enum": ["eslint"], "default": "eslint" }, "skipFormat": { diff --git a/packages/react/src/generators/remote/schema.json b/packages/react/src/generators/remote/schema.json index f9bcbd2d11..e1e8de6ed6 100644 --- a/packages/react/src/generators/remote/schema.json +++ b/packages/react/src/generators/remote/schema.json @@ -68,7 +68,7 @@ "linter": { "description": "The tool to use for running lint checks.", "type": "string", - "enum": ["eslint", "tslint"], + "enum": ["eslint"], "default": "eslint" }, "routing": { diff --git a/packages/react/src/generators/storybook-configuration/schema.json b/packages/react/src/generators/storybook-configuration/schema.json index 2b7827c4b2..bf8615fffd 100644 --- a/packages/react/src/generators/storybook-configuration/schema.json +++ b/packages/react/src/generators/storybook-configuration/schema.json @@ -52,7 +52,7 @@ "linter": { "description": "The tool to use for running lint checks.", "type": "string", - "enum": ["eslint", "tslint"], + "enum": ["eslint"], "default": "eslint" }, "standaloneConfig": { diff --git a/packages/web/src/generators/application/schema.json b/packages/web/src/generators/application/schema.json index ebea192298..a33e3dccf1 100644 --- a/packages/web/src/generators/application/schema.json +++ b/packages/web/src/generators/application/schema.json @@ -28,7 +28,10 @@ "message": "Which stylesheet format would you like to use?", "type": "list", "items": [ - { "value": "css", "label": "CSS" }, + { + "value": "css", + "label": "CSS" + }, { "value": "scss", "label": "SASS(.scss) [ http://sass-lang.com ]" @@ -59,7 +62,7 @@ "linter": { "description": "The tool to use for running lint checks.", "type": "string", - "enum": ["eslint", "tslint"], + "enum": ["eslint"], "default": "eslint" }, "skipFormat": { diff --git a/packages/workspace/src/generators/move/lib/update-eslintrc-json.spec.ts b/packages/workspace/src/generators/move/lib/update-eslintrc-json.spec.ts index 2f86a20a73..6c681afea5 100644 --- a/packages/workspace/src/generators/move/lib/update-eslintrc-json.spec.ts +++ b/packages/workspace/src/generators/move/lib/update-eslintrc-json.spec.ts @@ -30,7 +30,7 @@ describe('updateEslint', () => { it('should handle .eslintrc.json not existing', async () => { await libraryGenerator(tree, { name: 'my-lib', - linter: Linter.TsLint, + linter: Linter.None, standaloneConfig: false, }); diff --git a/packages/workspace/src/generators/new/new.ts b/packages/workspace/src/generators/new/new.ts index 40c4e36379..1a627e31be 100644 --- a/packages/workspace/src/generators/new/new.ts +++ b/packages/workspace/src/generators/new/new.ts @@ -6,10 +6,8 @@ import { getWorkspacePath as devkitGetWorkspacePath, installPackagesTask, names, - NxJsonConfiguration, PackageManager, Tree, - updateJson, } from '@nrwl/devkit'; import { join } from 'path'; @@ -19,6 +17,7 @@ import { workspaceGenerator } from '../workspace/workspace'; import { nxVersion } from '../../utils/versions'; import { Preset } from '../utils/presets'; import { getNpmPackageVersion } from '../utils/get-npm-package-version'; +import { Linter } from '../../utils/lint'; export interface Schema { cli: 'nx' | 'angular'; @@ -31,7 +30,7 @@ export interface Schema { nxCloud?: boolean; preset: string; defaultBase: string; - linter: 'tslint' | 'eslint'; + linter: Linter; packageManager?: PackageManager; } @@ -143,7 +142,6 @@ export async function newGenerator(host: Tree, options: Schema) { await workspaceGenerator(host, { ...options, nxCloud: undefined } as any); - setDefaultLinter(host, options); addPresetDependencies(host, options); addCloudDependencies(host, options); @@ -261,88 +259,3 @@ function normalizeOptions(options: NormalizedSchema): NormalizedSchema { return options; } - -function setDefaultLinter(host: Tree, options: Schema) { - const { linter, preset } = options; - // Don't do anything if someone doesn't pick angular - if (preset !== Preset.Angular && preset !== Preset.AngularWithNest) { - return; - } - - switch (linter) { - case 'eslint': { - setESLintDefault(host, options); - break; - } - case 'tslint': { - setTSLintDefault(host, options); - break; - } - } -} - -/** - * This sets ESLint as the default for any schematics that default to TSLint - */ -function setESLintDefault(host: Tree, options: Schema) { - updateJson( - host, - join(options.directory, 'nx.json'), - (json) => { - setDefault(json, '@nrwl/angular', 'application', 'linter', 'eslint'); - setDefault(json, '@nrwl/angular', 'library', 'linter', 'eslint'); - setDefault( - json, - '@nrwl/angular', - 'storybook-configuration', - 'linter', - 'eslint' - ); - return json; - } - ); -} - -/** - * This sets TSLint as the default for any schematics that default to ESLint - */ -function setTSLintDefault(host: Tree, options: Schema) { - updateJson( - host, - join(options.directory, 'nx.json'), - (json) => { - setDefault(json, '@nrwl/workspace', 'library', 'linter', 'tslint'); - setDefault(json, '@nrwl/cypress', 'cypress-project', 'linter', 'tslint'); - setDefault(json, '@nrwl/cypress', 'cypress-project', 'linter', 'tslint'); - setDefault(json, '@nrwl/node', 'application', 'linter', 'tslint'); - setDefault(json, '@nrwl/node', 'library', 'linter', 'tslint'); - setDefault(json, '@nrwl/nest', 'application', 'linter', 'tslint'); - setDefault(json, '@nrwl/nest', 'library', 'linter', 'tslint'); - setDefault(json, '@nrwl/express', 'application', 'linter', 'tslint'); - setDefault(json, '@nrwl/express', 'library', 'linter', 'tslint'); - - return json; - } - ); -} - -function setDefault( - json: NxJsonConfiguration, - collectionName: string, - generatorName: string, - key: string, - value: any -) { - if (!json.generators) json.generators = {}; - if ( - json.generators[collectionName] && - json.generators[collectionName][generatorName] - ) { - json.generators[collectionName][generatorName][key] = value; - } else if (json.generators[`${collectionName}:${generatorName}`]) { - json.generators[`${collectionName}:${generatorName}`][key] = value; - } else { - json.generators[collectionName] = json.generators[collectionName] || {}; - json.generators[collectionName][generatorName] = { [key]: value }; - } -} diff --git a/packages/workspace/src/generators/new/schema.json b/packages/workspace/src/generators/new/schema.json index a23442c272..224497bfc5 100644 --- a/packages/workspace/src/generators/new/schema.json +++ b/packages/workspace/src/generators/new/schema.json @@ -55,7 +55,7 @@ "linter": { "description": "The tool to use for running lint checks.", "type": "string", - "enum": ["tslint", "eslint"], + "enum": ["eslint"], "default": "eslint" }, "packageManager": { diff --git a/packages/workspace/src/generators/preset/schema.json b/packages/workspace/src/generators/preset/schema.json index 9fec155530..eadec1541c 100644 --- a/packages/workspace/src/generators/preset/schema.json +++ b/packages/workspace/src/generators/preset/schema.json @@ -25,7 +25,7 @@ "linter": { "description": "The tool to use for running lint checks.", "type": "string", - "enum": ["tslint", "eslint"], + "enum": ["eslint"], "default": "eslint" }, "style": { @@ -36,7 +36,10 @@ "message": "Which stylesheet format would you like to use?", "type": "list", "items": [ - { "value": "css", "label": "CSS" }, + { + "value": "css", + "label": "CSS" + }, { "value": "scss", "label": "SASS(.scss) [ http://sass-lang.com ]" diff --git a/packages/workspace/src/utils/lint.ts b/packages/workspace/src/utils/lint.ts index a323959928..b9cf53afcd 100644 --- a/packages/workspace/src/utils/lint.ts +++ b/packages/workspace/src/utils/lint.ts @@ -11,13 +11,10 @@ import { typescriptESLintVersion, eslintConfigPrettierVersion, nxVersion, - tslintVersion, - angularCliVersion, } from './versions'; import { offsetFromRoot } from '@nrwl/devkit'; export const enum Linter { - TsLint = 'tslint', EsLint = 'eslint', None = 'none', } @@ -28,15 +25,7 @@ export function generateProjectLint( linter: Linter, eslintFilePatterns: string[] ) { - if (linter === Linter.TsLint) { - return { - builder: '@angular-devkit/build-angular:tslint', - options: { - tsConfig: [tsConfigPath], - exclude: ['**/node_modules/**', `!${projectRoot}/**/*`], - }, - }; - } else if (linter === Linter.EsLint) { + if (linter === Linter.EsLint) { return { builder: '@nrwl/linter:eslint', options: { @@ -71,39 +60,6 @@ export function addLintFiles( const chainedCommands = []; - if (linter === 'tslint') { - chainedCommands.push((host: Tree) => { - if (!host.exists('/tslint.json')) { - host.create('/tslint.json', globalTsLint); - } - if (!options.onlyGlobal) { - host.create( - join(projectRoot as any, `tslint.json`), - JSON.stringify({ - extends: `${offsetFromRoot(projectRoot)}tslint.json`, - // Include project files to be linted since the global one excludes all files. - linterOptions: { - exclude: ['!**/*'], - }, - rules: {}, - }) - ); - } - }); - - chainedCommands.push( - addDepsToPackageJson( - {}, - { - tslint: tslintVersion, - '@angular-devkit/build-angular': angularCliVersion, - } - ) - ); - - return chain(chainedCommands); - } - if (linter === 'eslint') { if (!host.exists('/.eslintrc.json')) { host.create('/.eslintrc.json', globalESLint); @@ -210,74 +166,6 @@ export function addLintFiles( }; } -const globalTsLint = ` -{ - "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 globalESLint = JSON.stringify({ root: true, ignorePatterns: ['**/*'], diff --git a/packages/workspace/src/utils/versions.ts b/packages/workspace/src/utils/versions.ts index 22d679b1cc..e103d7cc47 100644 --- a/packages/workspace/src/utils/versions.ts +++ b/packages/workspace/src/utils/versions.ts @@ -3,7 +3,6 @@ export const nxVersion = require('../../package.json').version; export const angularCliVersion = '~14.2.0'; export const typescriptVersion = '~4.8.2'; export const prettierVersion = '^2.6.2'; -export const tslintVersion = '~6.1.0'; export const typescriptESLintVersion = '^5.36.1'; export const eslintVersion = '~8.15.0'; export const eslintConfigPrettierVersion = '8.1.0';