Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eslint-plugin): deprecate no-type-alias #6229

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/eslint-plugin/docs/rules/no-type-alias.md
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-plugin/src/configs/all.ts
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/rules/no-type-alias.ts
Expand Up @@ -42,6 +42,7 @@ interface TypeWithLabel {
export default util.createRule<Options, MessageIds>({
name: 'no-type-alias',
meta: {
deprecated: true,
type: 'suggestion',
docs: {
description: 'Disallow type aliases',
Expand Down