Skip to content

Rule proposal: No useless template string, or prefer String() #12866

@marcospgp

Description

@marcospgp

Please 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    archived due to ageThis issue has been archived; please open a new issue for any further discussionauto closedThe bot closed this issueenhancementThis change enhances an existing feature of ESLintevaluatingThe team will evaluate this issue to decide whether it meets the criteria for inclusionruleRelates to ESLint's core rules

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions