Skip to content

Commit

Permalink
feat(eslint-plugin): deprecate no-type-alias (#6229)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg committed Jan 30, 2023
1 parent 4528b8d commit 820bdf2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
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

0 comments on commit 820bdf2

Please sign in to comment.