-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Enhancement: [restrict-template-expressions] More permissive type check #8722
Comments
Quick response:
Nope. We do not want loose "type name a string" options. TL;DR - if you configure declare const x: Date;
`${x}` // will result in '<..date time string here..>' and interface Date { prop: string }
declare const x: Date;
`${x}` // will result in '[object Object]' If we add a general purpose option - it needs to follow the same spec as described in #6017 and implemented in the related PRs in other rules. |
@bradzacher Does this mean that |
At some point in the future - sure. It's just low on the list of list of priorities given its already implemented and would be a large breaking change for users to change. |
What do you guys think about the comments on #6279? (which, really, I don't think should be closed, since it hasn't really been fixed?) In that issue, it seems like @bradzacher supports such an option. |
I'm personally in favor of adding the standard format of "allow specifically these types" to |
A 👍 from another team member and a past "I'm ok with adding" from #6279 (comment). Marking as accepting PRs! |
Before You File a Proposal Please Confirm You Have Done The Following...
My proposal is suitable for this project
Link to the rule's documentation
https://typescript-eslint.io/rules/restrict-template-expressions/
Description
Related: #6279
I have added the
allowArray
option torestrict-template-expressions
in #8389.Now, I'd like to discuss other things that may be useful to put in a string. The most common case for me is stringifying
URLSearchParams
,Date
andBuffer
s, but there could be potential for others as well.Some questions for discussion:
ignoredTypeNames
? (I have created a draft PR feat: addignoredTypeNames
option forrestrict-template-expressions
#8556 implementing this)no-base-to-string
rule, which is becoming increasingly similar to this rule?Fail
Pass
Additional Info
No response
The text was updated successfully, but these errors were encountered: