From d9bef62efb785aa7226c9da4bc3891261bd5a5ae Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Fri, 16 Dec 2022 13:36:05 -0500 Subject: [PATCH 1/3] feat(eslint-plugin): deprecate no-type-alias --- packages/eslint-plugin/docs/rules/no-type-alias.md | 14 ++++++++++++++ packages/eslint-plugin/src/rules/no-type-alias.ts | 1 + 2 files changed, 15 insertions(+) diff --git a/packages/eslint-plugin/docs/rules/no-type-alias.md b/packages/eslint-plugin/docs/rules/no-type-alias.md index a9774ebdde1a..d87465b7de00 100644 --- a/packages/eslint-plugin/docs/rules/no-type-alias.md +++ b/packages/eslint-plugin/docs/rules/no-type-alias.md @@ -6,6 +6,20 @@ description: 'Disallow type aliases.' > > See **https://typescript-eslint.io/rules/no-type-alias** for documentation. +:::danger Deprecated + +This rule has been deprecated in favour of the [`@typescript-eslint/consistent-type-definitions`](./consistent-type-definitions.md) rule. +TypeScript type aliases are a commonly necessary language feature; banning it altogether is oftentimes counterproductive. + +::: + +:::note + +If you want to ban certain classifications of type alias, consider using [`no-restricted-syntax`](https://eslint.org/docs/latest/rules/no-restricted-syntax). +See [Troubleshooting & FAQs](/linting/troubleshooting#how-can-i-ban-specific-language-feature). + +::: + In TypeScript, type aliases serve three purposes: - Aliasing other types so that we can refer to them using a simpler name. diff --git a/packages/eslint-plugin/src/rules/no-type-alias.ts b/packages/eslint-plugin/src/rules/no-type-alias.ts index a3edcd8a024c..f1faa8dc678c 100644 --- a/packages/eslint-plugin/src/rules/no-type-alias.ts +++ b/packages/eslint-plugin/src/rules/no-type-alias.ts @@ -42,6 +42,7 @@ interface TypeWithLabel { export default util.createRule({ name: 'no-type-alias', meta: { + deprecated: true, type: 'suggestion', docs: { description: 'Disallow type aliases', From 0db5d7ace5fc5544564157ecbef157717271d68e Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Fri, 16 Dec 2022 15:24:26 -0500 Subject: [PATCH 2/3] Fix configs/all --- packages/eslint-plugin/src/configs/all.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/eslint-plugin/src/configs/all.ts b/packages/eslint-plugin/src/configs/all.ts index 25c42ad0f390..de65915b5dea 100644 --- a/packages/eslint-plugin/src/configs/all.ts +++ b/packages/eslint-plugin/src/configs/all.ts @@ -97,7 +97,6 @@ export = { '@typescript-eslint/no-this-alias': 'error', 'no-throw-literal': 'off', '@typescript-eslint/no-throw-literal': 'error', - '@typescript-eslint/no-type-alias': 'error', '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error', '@typescript-eslint/no-unnecessary-condition': 'error', '@typescript-eslint/no-unnecessary-qualifier': 'error', From c7946492dd581f5e16a9f57710eb25ea3278f1f4 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 17 Dec 2022 11:31:56 -0500 Subject: [PATCH 3/3] Update packages/eslint-plugin/docs/rules/no-type-alias.md --- packages/eslint-plugin/docs/rules/no-type-alias.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-plugin/docs/rules/no-type-alias.md b/packages/eslint-plugin/docs/rules/no-type-alias.md index d87465b7de00..78bdf64c009d 100644 --- a/packages/eslint-plugin/docs/rules/no-type-alias.md +++ b/packages/eslint-plugin/docs/rules/no-type-alias.md @@ -15,7 +15,7 @@ TypeScript type aliases are a commonly necessary language feature; banning it al :::note -If you want to ban certain classifications of type alias, consider using [`no-restricted-syntax`](https://eslint.org/docs/latest/rules/no-restricted-syntax). +If you want to ban certain classifications of type aliases, consider using [`no-restricted-syntax`](https://eslint.org/docs/latest/rules/no-restricted-syntax). See [Troubleshooting & FAQs](/linting/troubleshooting#how-can-i-ban-specific-language-feature). :::