-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Enhancement: [no-base-to-string] deprecate restrict-template-expression
into this rule
#9644
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
Comments
Yeah I've found it more and more confusing over the years when to use which rule. They're technically different rules but generally cover the same area of responsibility. I struggle to imagine a case where a project would strongly want one and not the other. 👍 from me with a request for more input from @typescript-eslint/triage-team. |
|
Yeah there's significant overlap but there's also distinction. Josh's description is apt. I think a good summary - It's often that I'd disable the latter but I'd rarely disable the former. |
Should we move them into the I think my root issue with the
Just confirming: it looks to me like the only part of I'm wondering now, if we remove the plus operand and template expression checking from |
It would, by principle, catch other things that do stringification, including #4314 and #3388.
No, because then you would not have a rule that only enforces "no |
Ah, gotcha, in that case we can consider my proposal to be explicit
Just for clarity, what do you see as the stylistic points beyond the correctness checking? I'm having a hard time conceptualizing why |
The point is that This proposal asks us to merge
I agree with you that |
😅 I'm having a hard time keeping track of the different areas of concerns across:
...given that this impacts at least:
I also personally am focusing on other work around project services and Promises over this issue area. It'd be useful if someone could summarize all the things that we would want to lint for, along with whether they're logical or stylistic, and which rule(s) catch them now. |
This is a stylistic case: const obj = { toString: () => "foo" };
`${obj}`; // restrict-template-expressions
`${obj.toString()}`; // all happy
obj + ""; // restrict-plus-operands
obj.toString(); // all happy This is a correctness case: const obj = {};
`${obj}`; // restrict-template-expressions + no-base-to-string
`${obj.toString()}`; // no-base-to-string
obj + ""; // restrict-plus-operands + no-base-to-string
obj.toString(); // no-base-to-string This is a stylistic (arguably) case: const obj = 1;
`${obj}`; // restrict-template-expressions
`${obj.toString()}`; // all happy
obj + ""; // restrict-plus-operands
obj.toString(); // all happy TLDR is that |
This delineation I like. I also like the delineation from #9644 (comment) as one area being logical, the other stylistic. Proposal @typescript-eslint/triage-team: let's mark this as accepting PRs for our next breaking-changes-allowed major to:
? |
We chatted internally. There doesn't seem to be consensus on a best way to delineate these rules' areas of functionality. It's not really clearly split between "logical" and "stylistic". I'm out of ideas and pretty much fine having them remain as-is. We're pretty certain that if something does happen, it won't be a rule deprecation. If anybody else has a clear proposal for how to do things, please do feel free to file a new issue. This one is getting long 😅. Thanks all for the discussion! |
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/no-base-to-string/
Description
The description of
no-base-to-string
from the docs isand the description for
restrict-template-expressions
isIt seems to me that, especially with the
allowArray
option I recently added torestrict-template-expressions
and the upcomingallow
option in #8556,restrict-template-expressions
is becoming much more similar tono-base-to-string
except thatrestrict-template-expressions
only applies to interpolation whileno-base-to-string
covers interpolation, concatenation, and explicittoString
calls.From @JoshuaKGoldberg on #8556:
Fail
Pass
Additional Info
No response
The text was updated successfully, but these errors were encountered: