Skip to content

Commit

Permalink
feat(linter): deprecate tslint (#18464)
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Aug 10, 2023
1 parent ecbfe73 commit ab9019d
Show file tree
Hide file tree
Showing 29 changed files with 60 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ Including the issue number that the PR relates to also helps with tracking.
```plain
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
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"cli": "nx",
"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`.",
"x-deprecated": "This generator is deprecated and will be removed in a future version of Nx. Migrate to ESLint.",
"examples": [
{
"command": "nx g convert-tslint-to-eslint myapp",
Expand Down Expand Up @@ -54,6 +55,7 @@
"presets": []
},
"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",
"aliases": [],
"hidden": false,
Expand Down
2 changes: 1 addition & 1 deletion docs/generated/packages/linter/documents/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ nx lint my-lib

## 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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"$id": "nest-convert-tslint-to-eslint",
"cli": "nx",
"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_.",
"examples": [
{
Expand Down Expand Up @@ -44,6 +45,7 @@
"presets": []
},
"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",
"aliases": [],
"hidden": false,
Expand Down
2 changes: 1 addition & 1 deletion docs/shared/monorepo-nx-enterprise.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Read more about workspace generators in the Workspace Generators guide.
### Workspace Lint Checks

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

Expand Down
2 changes: 1 addition & 1 deletion docs/shared/packages/linter/linter-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ nx lint my-lib

## 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

Expand Down
2 changes: 1 addition & 1 deletion docs/shared/recipes/generators/generator-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ The default value of this property. Example:
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "tslint"],
"enum": ["eslint"],
"default": "eslint"
}
}
Expand Down
1 change: 0 additions & 1 deletion nx-dev/models-package/src/lib/json-schema.models.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint:disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
Expand Down
6 changes: 4 additions & 2 deletions packages/angular/generators.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"convert-tslint-to-eslint": {
"factory": "./src/generators/convert-tslint-to-eslint/compat",
"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": {
"factory": "./src/generators/init/init.compat#initSchematic",
Expand Down Expand Up @@ -194,7 +195,8 @@
"convert-tslint-to-eslint": {
"factory": "./src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint#conversionGenerator",
"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": {
"factory": "./src/generators/directive/directive",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { convertNxGenerator } from '@nx/devkit';
import { warnForSchematicUsage } from '../utils/warn-for-schematic-usage';
import { conversionGenerator } from './convert-tslint-to-eslint';

/**
* @deprecated This generator will be removed in v17
*/
export const conversionSchematic = warnForSchematicUsage(
convertNxGenerator(conversionGenerator)
);
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import type { Linter } from 'eslint';
import type { AngularProjectConfiguration } from '../../utils/types';
import { addLintingGenerator } from '../add-linting/add-linting';

/**
* @deprecated This generator will be removed in v17
*/
export async function conversionGenerator(
host: Tree,
options: ConvertTSLintToESLintSchema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"cli": "nx",
"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`.",
"x-deprecated": "This generator is deprecated and will be removed in a future version of Nx. Migrate to ESLint.",
"examples": [
{
"command": "nx g convert-tslint-to-eslint myapp",
Expand Down
6 changes: 3 additions & 3 deletions packages/angular/src/utils/nx-devkit/ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ function _addSymbolToDecoratorMetadata(
decoratorName: DecoratorName
): ts.SourceFile {
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.
if (!node) {
Expand Down Expand Up @@ -326,7 +326,7 @@ export function removeFromNgModule(
property: string
): ts.SourceFile {
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.
if (!node) {
Expand Down Expand Up @@ -598,7 +598,7 @@ function getMatchingProperty(
module: string
): ts.ObjectLiteralElement {
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;

Expand Down
1 change: 1 addition & 0 deletions packages/cypress/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ export const cypressComponentConfiguration = componentConfigurationGenerator;
export { configurationGenerator as cypressE2EConfigurationGenerator };
export { cypressProjectGenerator } from './src/generators/cypress-project/cypress-project';
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 { migrateCypressProject } from './src/generators/migrate-to-cypress-11/migrate-to-cypress-11';
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {
import { addLinterToCyProject } from '../../utils/add-linter';
import type { Linter as ESLinter } from 'eslint';

/**
* @deprecated This generator will be removed in v17
*/
export async function conversionGenerator(
host: Tree,
options: ConvertTSLintToESLintSchema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"cli": "nx",
"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_.",
"x-deprecated": "This generator is deprecated and will be removed in a future version of Nx. Migrate to ESLint.",
"examples": [
{
"command": "nx g convert-tslint-to-eslint myapp",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export function updateWorkspace(
},
};

/**
* @deprecated this will be removed in the v17
*/
const isUsingTSLint =
projectConfig.targets.lint?.executor ===
'@angular-devkit/build-angular:tslint';
Expand Down
1 change: 1 addition & 0 deletions packages/linter/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export { lintProjectGenerator } from './src/generators/lint-project/lint-project';
export { lintInitGenerator } from './src/generators/init/init';
export { Linter } from './src/generators/utils/linter';
/** @deprecated This will be removed in v17 */
export * from './src/utils/convert-tslint-to-eslint';

// @nx/angular needs it for the Angular CLI workspace migration to Nx to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ function convertTSLintRuleSeverity(

const NX_TSLINT_RULE_NAME = 'nx-enforce-module-boundaries';

/**
* @deprecated This converter will be removed in v17
*/
export function convertTslintNxRuleToEslintNxRule(
tslintJson: Record<string, unknown>
): {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ function getConvertToEslintConfig() {
return tslintToEslint;
}

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

/**
* @deprecated This will be removed in v17
*/
export function convertTSLintDisableCommentsForProject(
tree: Tree,
projectName: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {

/**
* Common schema used by all implementations of convert-tslint-to-eslint generators
*
* @deprecated This will be removed in v17
*/
export interface ConvertTSLintToESLintSchema {
project: string;
Expand All @@ -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
* 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.
Expand All @@ -49,6 +52,8 @@ export interface ConvertTSLintToESLintSchema {
*
* - 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.
*
* @deprecated This will be removed in v17
*/
export class ProjectConverter {
private readonly projectConfig: ProjectConfiguration;
Expand Down
3 changes: 3 additions & 0 deletions packages/linter/src/utils/convert-tslint-to-eslint/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ function warnInCaseOfUnconvertedRules(
}
}

/**
* @deprecated This will be removed in v17
*/
export async function convertTSLintConfig(
rawTSLintJson: any,
tslintJsonPath: string,
Expand Down
1 change: 1 addition & 0 deletions packages/linter/src/utils/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ export const nxVersion = require('../../package.json').version;
export const eslintVersion = '~8.46.0';
export const eslintrcVersion = '^2.1.1';
export const eslintConfigPrettierVersion = '8.1.0';
/** @deprecated This will be removed in v17 */
export const tslintToEslintConfigVersion = '^2.13.0';
export const typescriptESLintVersion = '^5.60.1';
6 changes: 4 additions & 2 deletions packages/nest/generators.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"convert-tslint-to-eslint": {
"factory": "./src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint#conversionSchematic",
"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": {
"factory": "./src/generators/init/init#initSchematic",
Expand Down Expand Up @@ -116,7 +117,8 @@
"convert-tslint-to-eslint": {
"factory": "./src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint#conversionGenerator",
"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."

This comment has been minimized.

Copy link
@robertIsaac

robertIsaac Aug 13, 2023

Contributor

why in some places you have future version of Nx and in others it's just v17
shouldn't it be v17 in all?

},
"init": {
"factory": "./src/generators/init/init",
Expand Down
1 change: 1 addition & 0 deletions packages/nest/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export { applicationGenerator } from './src/generators/application/application';
export { classGenerator } from './src/generators/class/class';
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 { decoratorGenerator } from './src/generators/decorator/decorator';
export { filterGenerator } from './src/generators/filter/filter';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import {
} from '@nx/js/src/generators/library/library';
import type { Linter } from 'eslint';

/**
* @deprecated This generator will be removed in v17
*/
export async function conversionGenerator(
host: Tree,
options: ConvertTSLintToESLintSchema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"$id": "nest-convert-tslint-to-eslint",
"cli": "nx",
"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_.",
"examples": [
{
Expand Down
1 change: 0 additions & 1 deletion packages/nx/src/native/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint:disable */
/* eslint-disable */

/* auto-generated by NAPI-RS */
Expand Down
4 changes: 1 addition & 3 deletions scripts/documentation/json-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ function _getEnumFromValue<E, T extends E[keyof E]>(
}

if (Object.values(enumeration).indexOf(value) !== -1) {
// TODO: this should be unknown
// tslint:disable-next-line:no-any
return value as any as T;
return value as unknown as T;
}

return defaultValue;
Expand Down

1 comment on commit ab9019d

@vercel
Copy link

@vercel vercel bot commented on ab9019d Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx-dev-nrwl.vercel.app
nx.dev

Please sign in to comment.