Rule proposal: No useless template string, or prefer String()
See original GitHub issuePlease describe what the rule should do:
Disallow useless template strings, such as ${x}
. The thing is this can be used as a way to cast a variable to string, which means the rule could instead be “prefer String()” or “prefer .toString()”.
What category of rule is this? (place an “X” next to just one item)
[ ] Warns about a potential error (problem) [X] Suggests an alternate way of doing something (suggestion) [ ] Enforces code style (layout) [ ] Other (please specify:)
Provide 2-3 code examples that this rule will warn about:
const x = "soomething";
callAFunction(123, "mamamia", `${x}`);
const x = 19
callAFunction(123, "mamamia", `${x}`);
Why should this rule be included in ESLint (instead of a plugin)?
Because eslint already had tons of no-useless-something
rules, so this one would fit very well with the rest.
Are you willing to submit a pull request to implement this rule? No unless you point me to the right resources and ask nicely and I have enough free time this week
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:10 (6 by maintainers)
Top GitHub Comments
This should be reopened since there’s an active PR for it.
Hi @marcospgp , thanks for the rule proposal!
This might as well be a new option in no-implicit-coercion?