Closed
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I have searched for related issues and found none that match my proposal.
- I have searched the current rule list and found no rules that match my proposal.
- I have read the FAQ and my problem is not listed.
My proposal is suitable for this project
- I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).
Link to the rule's documentation
https://typescript-eslint.io/rules/restrict-template-expressions/
Description
Related: #6279
I have added the allowArray
option to restrict-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
and Buffer
s, but there could be potential for others as well.
Some questions for discussion:
- Do we add a new option
ignoredTypeNames
? (I have created a draft PR feat: addallow
option forrestrict-template-expressions
#8556 implementing this) - What will be the default value for this option?
- What does this mean for the
no-base-to-string
rule, which is becoming increasingly similar to this rule?
Fail
declare const maybeParams: URLSearchParams | undefined;
fetch(`https://myapi.com?${maybeParams}`);
Pass
declare const definitelyParams: URLSearchParams;
fetch(`https://myapi.com?${definitelyParams}`);
Additional Info
No response