From 820bdf2a3934d4186d51186693ced02df64a57ce Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 29 Jan 2023 20:42:59 -0500 Subject: [PATCH] feat(eslint-plugin): deprecate no-type-alias (#6229) --- packages/eslint-plugin/docs/rules/no-type-alias.md | 14 ++++++++++++++ packages/eslint-plugin/src/configs/all.ts | 1 - packages/eslint-plugin/src/rules/no-type-alias.ts | 1 + 3 files changed, 15 insertions(+), 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 a9774ebdde1..78bdf64c009 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 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). + +::: + 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/configs/all.ts b/packages/eslint-plugin/src/configs/all.ts index 25c42ad0f39..de65915b5de 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', diff --git a/packages/eslint-plugin/src/rules/no-type-alias.ts b/packages/eslint-plugin/src/rules/no-type-alias.ts index a3edcd8a024..f1faa8dc678 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',