-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(eslint-plugin): [no-useless-template-literals] add new rule #7957
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): [no-useless-template-literals] add new rule #7957
Conversation
Thanks for the PR, @StyleShit! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
context.report({ | ||
node, | ||
messageId: 'noUselessTemplateLiteral', | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should probably add a fixer in another PR
will raise a new issue after this one is merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/eslint-plugin/tests/rules/no-useless-template-literals.test.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin/tests/rules/no-useless-template-literals.test.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin/src/rules/no-useless-template-literals.ts
Outdated
Show resolved
Hide resolved
IDK why prettier is failing, seems to be fine locally |
packages/eslint-plugin/src/rules/no-useless-template-literals.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting closer, fantastic! 🥳
Mostly requesting changes on making the rule not flag stylistic points. On deeper thought I think there's some more testing to be done too.
Thanks!
packages/eslint-plugin/src/rules/no-useless-template-literals.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin/src/rules/no-useless-template-literals.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin/src/rules/no-useless-template-literals.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin/src/rules/no-useless-template-literals.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin/src/rules/no-useless-template-literals.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin/docs/rules/no-useless-template-literals.md
Outdated
Show resolved
Hide resolved
packages/eslint-plugin/tests/rules/no-useless-template-literals.test.ts
Outdated
Show resolved
Hide resolved
no idea why the build is failing |
Btw @StyleShit I appreciate you answering every thread 🙂 but if it's easier for you, you can just mark them as resolved. That's the flow we usually use when it's a straightforward "yes"/"done". |
Yeah 🙁 not related to this PR. Should be fixed by #8048. I'll update the branch. |
@JoshuaKGoldberg We usually either answer with "done" or start a discussion about the review comment. |
I, yet again, am resentful that GitHub's PR process doesn't give a way to distinguish between "one of us in this conversation thinks it's resolved" and "both of us in this conversation think it's resolved"... 🙃 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok this is looking great! Thanks for keeping working on it. 🙌
Apologies for the late-breaking request: I think the only blocker (other than reverting unrelated changes) is also reporting on unnecessary non-string literals such as bigint
and number
. Or at least, resolving the conversation around them is.
packages/eslint-plugin/tests/rules/no-useless-template-literals.test.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin/tests/rules/no-useless-template-literals.test.ts
Outdated
Show resolved
Hide resolved
…eless-template-literals
…m/StyleShit/typescript-eslint into feat/no-useless-template-literals
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(just #7957 (comment) left)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎆 this is great, thanks for all your work on it!
Looking forward to getting this into recommended for v7 😄
filed a new issue as promised: |
Just tested this in |
thanks Style, this is a very nice rule! |
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) | devDependencies | minor | [`6.10.0` -> `6.15.0`](https://renovatebot.com/diffs/npm/@typescript-eslint%2feslint-plugin/6.10.0/6.15.0) | --- ### Release Notes <details> <summary>typescript-eslint/typescript-eslint (@​typescript-eslint/eslint-plugin)</summary> ### [`v6.15.0`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#6150-2023-12-18) [Compare Source](typescript-eslint/typescript-eslint@v6.14.0...v6.15.0) ##### Features - **eslint-plugin:** \[no-useless-template-literals] add new rule ([#​7957](typescript-eslint/typescript-eslint#7957)) ([ff75785](typescript-eslint/typescript-eslint@ff75785)), closes [#​2846](typescript-eslint/typescript-eslint#2846) - require-array-sort-compare + toSorted ([#​8052](typescript-eslint/typescript-eslint#8052)) ([c9661c8](typescript-eslint/typescript-eslint@c9661c8)) You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website. ### [`v6.14.0`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#6140-2023-12-11) [Compare Source](typescript-eslint/typescript-eslint@v6.13.2...v6.14.0) ##### Bug Fixes - **eslint-plugin:** add no-unsafe-unary-minus, prefer-destructuring to disable-type-checked ([#​8038](typescript-eslint/typescript-eslint#8038)) ([431cd15](typescript-eslint/typescript-eslint@431cd15)) - **eslint-plugin:** correct message for `no-unsafe-unary-minus` ([#​7998](typescript-eslint/typescript-eslint#7998)) ([705370a](typescript-eslint/typescript-eslint@705370a)) ##### Features - **eslint-plugin:** \[explicit-function-return-type] add support for typed class property definitions ([#​8027](typescript-eslint/typescript-eslint#8027)) ([bff47d7](typescript-eslint/typescript-eslint@bff47d7)) - **eslint-plugin:** \[require-await] allow yielding Promise in async generators ([#​8003](typescript-eslint/typescript-eslint#8003)) ([4c3e704](typescript-eslint/typescript-eslint@4c3e704)) You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website. #### [6.13.2](typescript-eslint/typescript-eslint@v6.13.1...v6.13.2) (2023-12-04) **Note:** Version bump only for package [@​typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/eslint-plugin) You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website. #### [6.13.1](typescript-eslint/typescript-eslint@v6.13.0...v6.13.1) (2023-11-28) **Note:** Version bump only for package [@​typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/eslint-plugin) You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website. ### [`v6.13.2`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#6132-2023-12-04) [Compare Source](typescript-eslint/typescript-eslint@v6.13.1...v6.13.2) **Note:** Version bump only for package [@​typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/eslint-plugin) You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website. ### [`v6.13.1`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#6131-2023-11-28) [Compare Source](typescript-eslint/typescript-eslint@v6.13.0...v6.13.1) **Note:** Version bump only for package [@​typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/eslint-plugin) You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website. ### [`v6.13.0`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#6130-2023-11-27) [Compare Source](typescript-eslint/typescript-eslint@v6.12.0...v6.13.0) **Note:** Version bump only for package [@​typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/eslint-plugin) You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website. ### [`v6.12.0`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#6120-2023-11-20) [Compare Source](typescript-eslint/typescript-eslint@v6.11.0...v6.12.0) ##### Bug Fixes - **eslint-plugin:** \[class-methods-use-this] detect a problematic case for private/protected members if `ignoreClassesThatImplementAnInterface` is set ([#​7705](typescript-eslint/typescript-eslint#7705)) ([155aa1f](typescript-eslint/typescript-eslint@155aa1f)) - **eslint-plugin:** \[no-unnecessary-condition] fix false positive with computed member access and branded key type ([#​7706](typescript-eslint/typescript-eslint#7706)) ([f151b26](typescript-eslint/typescript-eslint@f151b26)) - **eslint-plugin:** \[switch-exhaustiveness-check] enum members with new line or single quotes are not being fixed correctly ([#​7806](typescript-eslint/typescript-eslint#7806)) ([a034d0a](typescript-eslint/typescript-eslint@a034d0a)), closes [#​7768](typescript-eslint/typescript-eslint#7768) ##### Features - \[member-ordering] add accessor support for member-ordering ([#​7927](typescript-eslint/typescript-eslint#7927)) ([3c8312d](typescript-eslint/typescript-eslint@3c8312d)) - **eslint-plugin:** \[switch-exhaustiveness-check] add requireDefaultForNonUnion option ([#​7880](typescript-eslint/typescript-eslint#7880)) ([4cfcd45](typescript-eslint/typescript-eslint@4cfcd45)) You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website. ### [`v6.11.0`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#6110-2023-11-13) [Compare Source](typescript-eslint/typescript-eslint@v6.10.0...v6.11.0) ##### Bug Fixes - **eslint-plugin:** \[explicit-function-return-type] support JSX attributes in `allowTypedFunctionExpressions` ([#​7553](typescript-eslint/typescript-eslint#7553)) ([be2777c](typescript-eslint/typescript-eslint@be2777c)) - **eslint-plugin:** \[no-unnecessary-qualifier] handle nested namespace id ([#​7883](typescript-eslint/typescript-eslint#7883)) ([a668f5b](typescript-eslint/typescript-eslint@a668f5b)) ##### Features - add `no-unsafe-unary-minus` rule ([#​7390](typescript-eslint/typescript-eslint#7390)) ([c4709c2](typescript-eslint/typescript-eslint@c4709c2)) - add types for flat config files ([#​7273](typescript-eslint/typescript-eslint#7273)) ([66cd0c0](typescript-eslint/typescript-eslint@66cd0c0)) - allow typescript@5.3.0-RC as devDependency ([#​7821](typescript-eslint/typescript-eslint#7821)) ([b6c40b4](typescript-eslint/typescript-eslint@b6c40b4)) - **eslint-plugin:** no-unsafe-enum-comparison handles switch cases ([#​7898](typescript-eslint/typescript-eslint#7898)) ([72cb9e4](typescript-eslint/typescript-eslint@72cb9e4)) - **utils:** add ESLint `CodePath` selector types ([#​7551](typescript-eslint/typescript-eslint#7551)) ([99a026f](typescript-eslint/typescript-eslint@99a026f)) You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website. </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=--> Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/Droplet/pulls/242 Reviewed-by: Vylpes <ethan@vylpes.com> Co-authored-by: Renovate Bot <renovate@vylpes.com> Co-committed-by: Renovate Bot <renovate@vylpes.com>
Closes #2846