feat(linter): deprecate tslint (#18464)

This commit is contained in:
Miroslav Jonaš 2023-08-10 15:39:23 +02:00 committed by GitHub
parent ecbfe73092
commit ab9019df1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 60 additions and 17 deletions

View File

@ -343,7 +343,7 @@ Including the issue number that the PR relates to also helps with tracking.
```plain ```plain
feat(angular): add an option to generate lazy-loadable modules feat(angular): add an option to generate lazy-loadable modules
`nx generate lib mylib --lazy` provisions the mylib project in tslint.json `nx generate lib mylib --lazy` provisions the mylib project in .eslintrc.json
Closes #157 Closes #157
``` ```

View File

@ -7,6 +7,7 @@
"cli": "nx", "cli": "nx",
"title": "Convert an Angular project from TSLint to ESLint", "title": "Convert an Angular project from TSLint to ESLint",
"description": "Convert an Angular project from TSLint to ESLint. NOTE: Does not work in `--dry-run mode`.", "description": "Convert an Angular project from TSLint to ESLint. NOTE: Does not work in `--dry-run mode`.",
"x-deprecated": "This generator is deprecated and will be removed in a future version of Nx. Migrate to ESLint.",
"examples": [ "examples": [
{ {
"command": "nx g convert-tslint-to-eslint myapp", "command": "nx g convert-tslint-to-eslint myapp",
@ -54,6 +55,7 @@
"presets": [] "presets": []
}, },
"description": "Converts a project from TSLint to ESLint.", "description": "Converts a project from TSLint to ESLint.",
"x-deprecated": "This generator is deprecated and will be removed in a future version of Nx. Migrate to ESLint.",
"implementation": "/packages/angular/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint#conversionGenerator.ts", "implementation": "/packages/angular/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint#conversionGenerator.ts",
"aliases": [], "aliases": [],
"hidden": false, "hidden": false,

View File

@ -28,7 +28,7 @@ nx lint my-lib
## Utils ## Utils
- [convert-tslint-to-eslint](/packages/angular/generators/convert-tslint-to-eslint) - Converts a project linter from [TSLint](https://palantir.github.io/tslint/) to [ESLint](https://eslint.org/) - **Deprecated** [convert-tslint-to-eslint](/packages/angular/generators/convert-tslint-to-eslint) - Converts a project linter from [TSLint](https://palantir.github.io/tslint/) to [ESLint](https://eslint.org/)
## ESLint plugin ## ESLint plugin

View File

@ -6,6 +6,7 @@
"$id": "nest-convert-tslint-to-eslint", "$id": "nest-convert-tslint-to-eslint",
"cli": "nx", "cli": "nx",
"title": "Convert a NestJS project from TSLint to ESLint", "title": "Convert a NestJS project from TSLint to ESLint",
"x-deprecated": "This generator is deprecated and will be removed in a future version of Nx. Migrate to ESLint.",
"description": "Convert a NestJS project from TSLint to ESLint. \n_NOTE: Does not work in `--dry-run` mode_.", "description": "Convert a NestJS project from TSLint to ESLint. \n_NOTE: Does not work in `--dry-run` mode_.",
"examples": [ "examples": [
{ {
@ -44,6 +45,7 @@
"presets": [] "presets": []
}, },
"description": "Convert a project from TSLint to ESLint.", "description": "Convert a project from TSLint to ESLint.",
"x-deprecated": "This generator is deprecated and will be removed in a future version of Nx. Migrate to ESLint.",
"implementation": "/packages/nest/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint#conversionGenerator.ts", "implementation": "/packages/nest/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint#conversionGenerator.ts",
"aliases": [], "aliases": [],
"hidden": false, "hidden": false,

View File

@ -191,7 +191,7 @@ Read more about workspace generators in the Workspace Generators guide.
### Workspace Lint Checks ### Workspace Lint Checks
Custom lint checks is another great way to enforce best practices. We can create custom lint checks in the `tools/lint` Custom lint checks is another great way to enforce best practices. We can create custom lint checks in the `tools/lint`
directory and then register them in `tslint.json` or `.eslintrc.json`. directory and then register them in `.eslintrc.json`.
## Developer Workflow ## Developer Workflow

View File

@ -28,7 +28,7 @@ nx lint my-lib
## Utils ## Utils
- [convert-tslint-to-eslint](/packages/angular/generators/convert-tslint-to-eslint) - Converts a project linter from [TSLint](https://palantir.github.io/tslint/) to [ESLint](https://eslint.org/) - **Deprecated** [convert-tslint-to-eslint](/packages/angular/generators/convert-tslint-to-eslint) - Converts a project linter from [TSLint](https://palantir.github.io/tslint/) to [ESLint](https://eslint.org/)
## ESLint plugin ## ESLint plugin

View File

@ -617,7 +617,7 @@ The default value of this property. Example:
"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"
} }
} }

View File

@ -1,4 +1,3 @@
/* tslint:disable */
/** /**
* This file was automatically generated by json-schema-to-typescript. * This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,

View File

@ -42,7 +42,8 @@
"convert-tslint-to-eslint": { "convert-tslint-to-eslint": {
"factory": "./src/generators/convert-tslint-to-eslint/compat", "factory": "./src/generators/convert-tslint-to-eslint/compat",
"schema": "./src/generators/convert-tslint-to-eslint/schema.json", "schema": "./src/generators/convert-tslint-to-eslint/schema.json",
"description": "Converts a project from TSLint to ESLint." "description": "Converts a project from TSLint to ESLint.",
"x-deprecated": "This generator is deprecated and will be removed in a future version of Nx. Migrate to ESLint."
}, },
"init": { "init": {
"factory": "./src/generators/init/init.compat#initSchematic", "factory": "./src/generators/init/init.compat#initSchematic",
@ -194,7 +195,8 @@
"convert-tslint-to-eslint": { "convert-tslint-to-eslint": {
"factory": "./src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint#conversionGenerator", "factory": "./src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint#conversionGenerator",
"schema": "./src/generators/convert-tslint-to-eslint/schema.json", "schema": "./src/generators/convert-tslint-to-eslint/schema.json",
"description": "Converts a project from TSLint to ESLint." "description": "Converts a project from TSLint to ESLint.",
"x-deprecated": "This generator is deprecated and will be removed in a future version of Nx. Migrate to ESLint."
}, },
"directive": { "directive": {
"factory": "./src/generators/directive/directive", "factory": "./src/generators/directive/directive",

View File

@ -2,6 +2,9 @@ import { convertNxGenerator } from '@nx/devkit';
import { warnForSchematicUsage } from '../utils/warn-for-schematic-usage'; import { warnForSchematicUsage } from '../utils/warn-for-schematic-usage';
import { conversionGenerator } from './convert-tslint-to-eslint'; import { conversionGenerator } from './convert-tslint-to-eslint';
/**
* @deprecated This generator will be removed in v17
*/
export const conversionSchematic = warnForSchematicUsage( export const conversionSchematic = warnForSchematicUsage(
convertNxGenerator(conversionGenerator) convertNxGenerator(conversionGenerator)
); );

View File

@ -5,6 +5,9 @@ import type { Linter } from 'eslint';
import type { AngularProjectConfiguration } from '../../utils/types'; import type { AngularProjectConfiguration } from '../../utils/types';
import { addLintingGenerator } from '../add-linting/add-linting'; import { addLintingGenerator } from '../add-linting/add-linting';
/**
* @deprecated This generator will be removed in v17
*/
export async function conversionGenerator( export async function conversionGenerator(
host: Tree, host: Tree,
options: ConvertTSLintToESLintSchema options: ConvertTSLintToESLintSchema

View File

@ -4,6 +4,7 @@
"cli": "nx", "cli": "nx",
"title": "Convert an Angular project from TSLint to ESLint", "title": "Convert an Angular project from TSLint to ESLint",
"description": "Convert an Angular project from TSLint to ESLint. NOTE: Does not work in `--dry-run mode`.", "description": "Convert an Angular project from TSLint to ESLint. NOTE: Does not work in `--dry-run mode`.",
"x-deprecated": "This generator is deprecated and will be removed in a future version of Nx. Migrate to ESLint.",
"examples": [ "examples": [
{ {
"command": "nx g convert-tslint-to-eslint myapp", "command": "nx g convert-tslint-to-eslint myapp",

View File

@ -168,7 +168,7 @@ function _addSymbolToDecoratorMetadata(
decoratorName: DecoratorName decoratorName: DecoratorName
): ts.SourceFile { ): ts.SourceFile {
const nodes = getDecoratorMetadata(source, decoratorName, '@angular/core'); const nodes = getDecoratorMetadata(source, decoratorName, '@angular/core');
let node: any = nodes[0]; // tslint:disable-line:no-any let node: any = nodes[0];
// Find the decorator declaration. // Find the decorator declaration.
if (!node) { if (!node) {
@ -326,7 +326,7 @@ export function removeFromNgModule(
property: string property: string
): ts.SourceFile { ): ts.SourceFile {
const nodes = getDecoratorMetadata(source, 'NgModule', '@angular/core'); const nodes = getDecoratorMetadata(source, 'NgModule', '@angular/core');
let node: any = nodes[0]; // tslint:disable-line:no-any let node: any = nodes[0];
// Find the decorator declaration. // Find the decorator declaration.
if (!node) { if (!node) {
@ -598,7 +598,7 @@ function getMatchingProperty(
module: string module: string
): ts.ObjectLiteralElement { ): ts.ObjectLiteralElement {
const nodes = getDecoratorMetadata(source, identifier, module); const nodes = getDecoratorMetadata(source, identifier, module);
let node: any = nodes[0]; // tslint:disable-line:no-any let node: any = nodes[0];
if (!node) return null; if (!node) return null;

View File

@ -9,5 +9,6 @@ export const cypressComponentConfiguration = componentConfigurationGenerator;
export { configurationGenerator as cypressE2EConfigurationGenerator }; export { configurationGenerator as cypressE2EConfigurationGenerator };
export { cypressProjectGenerator } from './src/generators/cypress-project/cypress-project'; export { cypressProjectGenerator } from './src/generators/cypress-project/cypress-project';
export { cypressInitGenerator } from './src/generators/init/init'; export { cypressInitGenerator } from './src/generators/init/init';
/** @deprecated This generator will be removed in v17 */
export { conversionGenerator } from './src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint'; export { conversionGenerator } from './src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint';
export { migrateCypressProject } from './src/generators/migrate-to-cypress-11/migrate-to-cypress-11'; export { migrateCypressProject } from './src/generators/migrate-to-cypress-11/migrate-to-cypress-11';

View File

@ -12,6 +12,9 @@ import {
import { addLinterToCyProject } from '../../utils/add-linter'; import { addLinterToCyProject } from '../../utils/add-linter';
import type { Linter as ESLinter } from 'eslint'; import type { Linter as ESLinter } from 'eslint';
/**
* @deprecated This generator will be removed in v17
*/
export async function conversionGenerator( export async function conversionGenerator(
host: Tree, host: Tree,
options: ConvertTSLintToESLintSchema options: ConvertTSLintToESLintSchema

View File

@ -4,6 +4,7 @@
"cli": "nx", "cli": "nx",
"title": "Convert a Cypress project from TSLint to ESLint", "title": "Convert a Cypress project from TSLint to ESLint",
"description": "Convert a Cypress project from TSLint to ESLint.\n_NOTE: Does not work in `--dry-run` mode_.", "description": "Convert a Cypress project from TSLint to ESLint.\n_NOTE: Does not work in `--dry-run` mode_.",
"x-deprecated": "This generator is deprecated and will be removed in a future version of Nx. Migrate to ESLint.",
"examples": [ "examples": [
{ {
"command": "nx g convert-tslint-to-eslint myapp", "command": "nx g convert-tslint-to-eslint myapp",

View File

@ -38,6 +38,9 @@ export function updateWorkspace(
}, },
}; };
/**
* @deprecated this will be removed in the v17
*/
const isUsingTSLint = const isUsingTSLint =
projectConfig.targets.lint?.executor === projectConfig.targets.lint?.executor ===
'@angular-devkit/build-angular:tslint'; '@angular-devkit/build-angular:tslint';

View File

@ -1,6 +1,7 @@
export { lintProjectGenerator } from './src/generators/lint-project/lint-project'; export { lintProjectGenerator } from './src/generators/lint-project/lint-project';
export { lintInitGenerator } from './src/generators/init/init'; export { lintInitGenerator } from './src/generators/init/init';
export { Linter } from './src/generators/utils/linter'; export { Linter } from './src/generators/utils/linter';
/** @deprecated This will be removed in v17 */
export * from './src/utils/convert-tslint-to-eslint'; export * from './src/utils/convert-tslint-to-eslint';
// @nx/angular needs it for the Angular CLI workspace migration to Nx to // @nx/angular needs it for the Angular CLI workspace migration to Nx to

View File

@ -26,6 +26,9 @@ function convertTSLintRuleSeverity(
const NX_TSLINT_RULE_NAME = 'nx-enforce-module-boundaries'; const NX_TSLINT_RULE_NAME = 'nx-enforce-module-boundaries';
/**
* @deprecated This converter will be removed in v17
*/
export function convertTslintNxRuleToEslintNxRule( export function convertTslintNxRuleToEslintNxRule(
tslintJson: Record<string, unknown> tslintJson: Record<string, unknown>
): { ): {

View File

@ -49,6 +49,9 @@ function getConvertToEslintConfig() {
return tslintToEslint; return tslintToEslint;
} }
/**
* @deprecated This will be removed in v17
*/
export async function convertToESLintConfig( export async function convertToESLintConfig(
pathToTslintJson: string, pathToTslintJson: string,
tslintJson: Record<string, unknown>, tslintJson: Record<string, unknown>,
@ -196,6 +199,9 @@ function likelyContainsTSLintComment(fileContent: string): boolean {
return fileContent.includes('tslint:'); return fileContent.includes('tslint:');
} }
/**
* @deprecated This will be removed in v17
*/
export function convertTSLintDisableCommentsForProject( export function convertTSLintDisableCommentsForProject(
tree: Tree, tree: Tree,
projectName: string projectName: string

View File

@ -24,6 +24,8 @@ import {
/** /**
* Common schema used by all implementations of convert-tslint-to-eslint generators * Common schema used by all implementations of convert-tslint-to-eslint generators
*
* @deprecated This will be removed in v17
*/ */
export interface ConvertTSLintToESLintSchema { export interface ConvertTSLintToESLintSchema {
project: string; project: string;
@ -34,6 +36,7 @@ export interface ConvertTSLintToESLintSchema {
} }
/** /**
*
* When we convert a TSLint setup to an ESLint setup for a particular project, there are a number of * When we convert a TSLint setup to an ESLint setup for a particular project, there are a number of
* shared/common concerns (implemented as library utilities within @nx/linter), and a few things * shared/common concerns (implemented as library utilities within @nx/linter), and a few things
* which are specific to this package and the types of projects it produces. * which are specific to this package and the types of projects it produces.
@ -49,6 +52,8 @@ export interface ConvertTSLintToESLintSchema {
* *
* - The user's project-level tslint.json file will be converted into a corresponding .eslintrc.json file * - The user's project-level tslint.json file will be converted into a corresponding .eslintrc.json file
* and it will extend from the root workspace .eslintrc.json file as normal. * and it will extend from the root workspace .eslintrc.json file as normal.
*
* @deprecated This will be removed in v17
*/ */
export class ProjectConverter { export class ProjectConverter {
private readonly projectConfig: ProjectConfiguration; private readonly projectConfig: ProjectConfiguration;

View File

@ -60,6 +60,9 @@ function warnInCaseOfUnconvertedRules(
} }
} }
/**
* @deprecated This will be removed in v17
*/
export async function convertTSLintConfig( export async function convertTSLintConfig(
rawTSLintJson: any, rawTSLintJson: any,
tslintJsonPath: string, tslintJsonPath: string,

View File

@ -3,5 +3,6 @@ export const nxVersion = require('../../package.json').version;
export const eslintVersion = '~8.46.0'; export const eslintVersion = '~8.46.0';
export const eslintrcVersion = '^2.1.1'; export const eslintrcVersion = '^2.1.1';
export const eslintConfigPrettierVersion = '8.1.0'; export const eslintConfigPrettierVersion = '8.1.0';
/** @deprecated This will be removed in v17 */
export const tslintToEslintConfigVersion = '^2.13.0'; export const tslintToEslintConfigVersion = '^2.13.0';
export const typescriptESLintVersion = '^5.60.1'; export const typescriptESLintVersion = '^5.60.1';

View File

@ -13,7 +13,8 @@
"convert-tslint-to-eslint": { "convert-tslint-to-eslint": {
"factory": "./src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint#conversionSchematic", "factory": "./src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint#conversionSchematic",
"schema": "./src/generators/convert-tslint-to-eslint/schema.json", "schema": "./src/generators/convert-tslint-to-eslint/schema.json",
"description": "Convert a project from TSLint to ESLint." "description": "Convert a project from TSLint to ESLint.",
"x-deprecated": "This generator is deprecated and will be removed in a future version of Nx. Migrate to ESLint."
}, },
"init": { "init": {
"factory": "./src/generators/init/init#initSchematic", "factory": "./src/generators/init/init#initSchematic",
@ -116,7 +117,8 @@
"convert-tslint-to-eslint": { "convert-tslint-to-eslint": {
"factory": "./src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint#conversionGenerator", "factory": "./src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint#conversionGenerator",
"schema": "./src/generators/convert-tslint-to-eslint/schema.json", "schema": "./src/generators/convert-tslint-to-eslint/schema.json",
"description": "Convert a project from TSLint to ESLint." "description": "Convert a project from TSLint to ESLint.",
"x-deprecated": "This generator is deprecated and will be removed in a future version of Nx. Migrate to ESLint."
}, },
"init": { "init": {
"factory": "./src/generators/init/init", "factory": "./src/generators/init/init",

View File

@ -1,6 +1,7 @@
export { applicationGenerator } from './src/generators/application/application'; export { applicationGenerator } from './src/generators/application/application';
export { classGenerator } from './src/generators/class/class'; export { classGenerator } from './src/generators/class/class';
export { controllerGenerator } from './src/generators/controller/controller'; export { controllerGenerator } from './src/generators/controller/controller';
/** @deprecated This generator will be removed in v17 */
export { conversionGenerator } from './src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint'; export { conversionGenerator } from './src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint';
export { decoratorGenerator } from './src/generators/decorator/decorator'; export { decoratorGenerator } from './src/generators/decorator/decorator';
export { filterGenerator } from './src/generators/filter/filter'; export { filterGenerator } from './src/generators/filter/filter';

View File

@ -15,6 +15,9 @@ import {
} from '@nx/js/src/generators/library/library'; } from '@nx/js/src/generators/library/library';
import type { Linter } from 'eslint'; import type { Linter } from 'eslint';
/**
* @deprecated This generator will be removed in v17
*/
export async function conversionGenerator( export async function conversionGenerator(
host: Tree, host: Tree,
options: ConvertTSLintToESLintSchema options: ConvertTSLintToESLintSchema

View File

@ -3,6 +3,7 @@
"$id": "nest-convert-tslint-to-eslint", "$id": "nest-convert-tslint-to-eslint",
"cli": "nx", "cli": "nx",
"title": "Convert a NestJS project from TSLint to ESLint", "title": "Convert a NestJS project from TSLint to ESLint",
"x-deprecated": "This generator is deprecated and will be removed in a future version of Nx. Migrate to ESLint.",
"description": "Convert a NestJS project from TSLint to ESLint. \n_NOTE: Does not work in `--dry-run` mode_.", "description": "Convert a NestJS project from TSLint to ESLint. \n_NOTE: Does not work in `--dry-run` mode_.",
"examples": [ "examples": [
{ {

View File

@ -1,4 +1,3 @@
/* tslint:disable */
/* eslint-disable */ /* eslint-disable */
/* auto-generated by NAPI-RS */ /* auto-generated by NAPI-RS */

View File

@ -19,9 +19,7 @@ function _getEnumFromValue<E, T extends E[keyof E]>(
} }
if (Object.values(enumeration).indexOf(value) !== -1) { if (Object.values(enumeration).indexOf(value) !== -1) {
// TODO: this should be unknown return value as unknown as T;
// tslint:disable-next-line:no-any
return value as any as T;
} }
return defaultValue; return defaultValue;