-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(eslint-plugin): [no-useless-template-literals] rename to no-useless-template-expression
(deprecate no-useless-template-literals
)
#8821
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
Conversation
Thanks for the PR, @kirkwaiblinger! 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. |
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.
LGTM in general! Just requesting changes on some docs touchups (the suggestions). Nothing functionally blocking from me. Thanks! ✨
packages/eslint-plugin/docs/rules/no-useless-template-literals.mdx
Outdated
Show resolved
Hide resolved
packages/eslint-plugin/src/rules/no-useless-template-expression.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin/src/rules/no-useless-template-expression.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin/src/rules/no-useless-template-literals.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
@JoshuaKGoldberg |
I'm up for the |
@@ -16,10 +16,10 @@ This rule restricts what can be thrown as an exception. | |||
|
|||
:::warning | |||
This rule is being renamed to [`only-throw-error`](./only-throw-error.mdx). | |||
When it was first created, it only prevented literals from being thrown (hence the name), but it has now been expanded to only allow expressions which have a possibility of being an `Error` object. | |||
With the `allowThrowingAny` and `allowThrowingUnknown` options, it can be configured to only allow throwing values which are guaranteed to be an instance of `Error`. | |||
The current name, `no-throw-literal`, will be removed in a future major version of typescript-eslint. |
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.
since this PR changes multiple rules, maybe we should also change its title?
(so it'll also be squashed with the proper commit message)
or maybe split tp multiple PRs?
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 comes out of #8821 (comment).
I think it makes sense to include in this change set since it's such a small (and related) change.
|
||
## When Not To Use It | ||
|
||
When you want to allow string expressions inside 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.
IIRC, it's not only for strings, it's also for other literals such as numbers, booleans, null, etc.
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.
Yeah, true. That part of the PR is just unchanged code moved from the existing page, though. See on main:
typescript-eslint/packages/eslint-plugin/docs/rules/no-useless-template-literals.mdx
Lines 55 to 58 in f248e68
## When Not To Use It | |
When you want to allow string expressions inside template literals. | |
I don't feel strongly about it, so I would prefer not to bother changing it in this PR 🙃. Feel free to submit a separate PR to change that line if you like! 🙂
:::info | ||
This rule does not aim to flag template literals without substitution expressions that could have been written as an ordinary string. | ||
That is to say, this rule will not help you turn `` `this` `` into `"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. | ||
::: |
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.
Like it!
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8821 +/- ##
==========================================
- Coverage 88.04% 87.39% -0.66%
==========================================
Files 410 256 -154
Lines 14187 12522 -1665
Branches 4136 3927 -209
==========================================
- Hits 12491 10943 -1548
+ Misses 1391 1304 -87
+ Partials 305 275 -30
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
🚀 sorry for the delay, this is great!
I'm happy for you to merge whenever you're comfortable with it.
no-useless-template-expression
(deprecate no-useless-template-literals
)
PR Checklist
Overview
Copy old rule to new rule.
Deprecate rule under old name.
Lots of documentation updating.