Skip to content

feat(eslint-plugin): remove no-useless-template-literals #9207

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

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to call out that this will probably cause merge conflicts when #8688 and #8673 get merged to main. But, the resolution is basically trivial (prefer this changeset over the other one), so I'm guessing there's no reason to consider blocking the PR or anything.

cc @JoshuaKGoldberg

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, agreed!

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
Loading