Skip to content
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

no-implicit-coercion does not check template literals #7062

Closed
kaicataldo opened this issue Sep 6, 2016 · 7 comments
Closed

no-implicit-coercion does not check template literals #7062

kaicataldo opened this issue Sep 6, 2016 · 7 comments
Assignees
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules

Comments

@kaicataldo
Copy link
Member

The version of ESLint you are using
Master

The problem you want to solve.
While working on #7060 I noticed that no-implicit-coercion does not check for implicit coercion using template literals. While this isn't a common practice, I think we should add it for the sake of completeness.

Your take on the correct solution to problem.
no-implicit-coercion should warn when it finds the following patterns:

`` + foo; // Error: use `String(foo)` instead.
foo + ``; //  Error: use `String(foo)` instead.
foo += ``; // Error: use `foo = String(foo)` instead.

I have a local branch with an implementation and tests and am happy to make a PR once #7060 has been merged.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Sep 6, 2016
@kaicataldo kaicataldo added enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Sep 6, 2016
@kaicataldo kaicataldo self-assigned this Sep 6, 2016
@platinumazure
Copy link
Member

👍 from me.

@vitorbal
Copy link
Member

vitorbal commented Sep 6, 2016

👍!!

@kaicataldo
Copy link
Member Author

@eslint/eslint-team Any other thoughts on this? Could use one more supporter/would love to hear any arguments against.

@mikesherov
Copy link
Contributor

It's a bug if it's not checking Template Literals. Should probably also check tagged template literals too.

👍

@mikesherov
Copy link
Contributor

Err, I guess not for tagged template expressions because those could return non strings. Nvm.

@kaicataldo kaicataldo added accepted There is consensus among the team that this change meets the criteria for inclusion enhancement This change enhances an existing feature of ESLint and removed enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Sep 11, 2016
@ilyavolodin
Copy link
Member

👍

@kaicataldo
Copy link
Member Author

Thanks all - I'll put together a PR

@nzakas nzakas closed this as completed in a876673 Sep 13, 2016
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

6 participants