Skip to content

Commit

Permalink
feat(eslint-plugin): remove no-useless-template-literals (typescript-…
Browse files Browse the repository at this point in the history
…eslint#9207)

* remove no-useless-template-literals rule

* fix no-useless-template-literals docs

* revert removal

* keep as tombstone page

* fix doc

* fix docs test

* fix doc
  • Loading branch information
y-hsgw authored Jun 4, 2024
1 parent b4fbf6d commit 7b6b8bc
Show file tree
Hide file tree
Showing 10 changed files with 3 additions and 908 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ This rule reports template literals that contain substitution expressions (also
:::info[Migration from `no-useless-template-literals`]

This rule was formerly known as [`no-useless-template-literals`](./no-useless-template-literals.mdx).
We encourage users to migrate to the new name, `no-unnecessary-template-expression`, as the old name will be removed in a future major version of typescript-eslint.

The new name is a drop-in replacement with identical functionality.

:::
Expand Down
22 changes: 2 additions & 20 deletions packages/eslint-plugin/docs/rules/no-useless-template-literals.mdx
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
---
description: 'Disallow unnecessary template literals.'
---
:::danger Deprecated

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
This rule has been renamed to [`no-unnecessary-template-expression`](./no-unnecessary-template-expression.mdx). See [#8544](https://github.com/typescript-eslint/typescript-eslint/issues/8544) for more information.

> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/no-useless-template-literals** for documentation.
This rule reports template literals that contain substitution expressions (also variously referred to as embedded expressions or string interpolations) that are unnecessary and can be simplified.

:::warning
This rule is being renamed to [`no-unnecessary-template-expression`](./no-unnecessary-template-expression.mdx).
The current name, `no-useless-template-literals`, will be removed in a future major version of typescript-eslint.

After the creation of this rule, it was realized that the name `no-useless-template-literals` could be misleading, seeing as this rule only targets template literals with substitution expressions.
In particular, it does _not_ aim to flag useless template literals that look like `` `this` `` and could be simplified to `"this"`.
If you are looking for such a rule, you can configure the [`@stylistic/ts/quotes`](https://eslint.style/rules/ts/quotes) rule to do this.
:::

{/* Intentionally Omitted: When Not To Use It */}
1 change: 0 additions & 1 deletion packages/eslint-plugin/src/configs/disable-type-checked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export = {
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-unary-minus': 'off',
'@typescript-eslint/no-useless-template-literals': 'off',
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
'@typescript-eslint/only-throw-error': 'off',
'@typescript-eslint/prefer-destructuring': 'off',
Expand Down
2 changes: 0 additions & 2 deletions packages/eslint-plugin/src/rules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ import noUnusedVars from './no-unused-vars';
import noUseBeforeDefine from './no-use-before-define';
import noUselessConstructor from './no-useless-constructor';
import noUselessEmptyExport from './no-useless-empty-export';
import noUselessTemplateLiterals from './no-useless-template-literals';
import noVarRequires from './no-var-requires';
import nonNullableTypeAssertionStyle from './non-nullable-type-assertion-style';
import onlyThrowError from './only-throw-error';
Expand Down Expand Up @@ -210,7 +209,6 @@ export default {
'no-use-before-define': noUseBeforeDefine,
'no-useless-constructor': noUselessConstructor,
'no-useless-empty-export': noUselessEmptyExport,
'no-useless-template-literals': noUselessTemplateLiterals,
'no-var-requires': noVarRequires,
'non-nullable-type-assertion-style': nonNullableTypeAssertionStyle,
'only-throw-error': onlyThrowError,
Expand Down
176 changes: 0 additions & 176 deletions packages/eslint-plugin/src/rules/no-useless-template-literals.ts

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions packages/eslint-plugin/tests/docs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ describe('Validating rule docs', () => {
// comments in the files for more information.
'no-duplicate-imports.mdx',
'no-parameter-properties.mdx',
'no-useless-template-literals.mdx',
...oldStylisticRules,
]);

Expand Down
Loading

0 comments on commit 7b6b8bc

Please sign in to comment.