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

Update: Add disallowTemplateShorthand option in no-implicit-coercion #13579

Merged

Conversation

remcohaszing
Copy link
Contributor

@remcohaszing remcohaszing commented Aug 17, 2020

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[x] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

This adds the templateString option to no-implicit-coercion. This makes the
rule report the following code:

`${foo}`

For backwards compatibility, this was added as a separate option instead of as
default behaviour.

Is there anything you'd like reviewers to focus on?

Closes #12866

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Aug 17, 2020
@kaicataldo kaicataldo added evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion feature This change adds a new feature to ESLint rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Aug 18, 2020
@kaicataldo
Copy link
Member

Since the linked issue wasn't accepted, we'll need to go through the acceptance process in this PR. I've added my support for the proposal.

@remcohaszing
Copy link
Contributor Author

This also resolves a race condition in the fixers of prefer-template and no-implicit-coercion.

Input

'' + foo;

Output when autofixed by prefer-template:

`${foo}`;

Output by no-implicit-coercion

String(foo);

This option will still trigger no-implicit-coercion after prefer-template has run its autofixer, meaning there is only one correct way to write this string conversion if both rules are enabled.

@remcohaszing
Copy link
Contributor Author

I’m not getting a lot of feedback. As far as I can tell this pull request can be merged. Does this require any actions from my side?

@mdjermanovic
Copy link
Member

@remcohaszing this enhancement hasn't been accepted yet, per our process it still needs a champion from the team.

@mdjermanovic mdjermanovic added enhancement This change enhances an existing feature of ESLint and removed feature This change adds a new feature to ESLint labels Nov 3, 2020
@mdjermanovic
Copy link
Member

I can champion this.

@mdjermanovic mdjermanovic self-assigned this Mar 26, 2021
@btmills btmills 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 Mar 26, 2021
docs/rules/no-implicit-coercion.md Outdated Show resolved Hide resolved
docs/rules/no-implicit-coercion.md Outdated Show resolved Hide resolved
docs/rules/no-implicit-coercion.md Outdated Show resolved Hide resolved
docs/rules/no-implicit-coercion.md Show resolved Hide resolved
docs/rules/no-implicit-coercion.md Outdated Show resolved Hide resolved
docs/rules/no-implicit-coercion.md Outdated Show resolved Hide resolved
lib/rules/no-implicit-coercion.js Show resolved Hide resolved
tests/lib/rules/no-implicit-coercion.js Show resolved Hide resolved
lib/rules/no-implicit-coercion.js Outdated Show resolved Hide resolved
lib/rules/no-implicit-coercion.js Outdated Show resolved Hide resolved
…nt#12866)

This adds the `templateString` option to `no-implicit-coercion`. This makes the
rule report the following code:

```js
`${foo}`
```

For backwards compatibility, this was added as a separate option instead of as
default behaviour.
@remcohaszing remcohaszing force-pushed the no-implicit-coercion-template-string branch from 6f9144d to bdfe13e Compare April 5, 2021 08:43
@mdjermanovic mdjermanovic changed the title Update: Add templateString option in no-implicit-coercion (fixes #12866) Update: Add disallowTemplateShorthand option in no-implicit-coercion Apr 6, 2021
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@remcohaszing thanks for the quick responses! This looks good, I have only some small suggestions about the documentation.

docs/rules/no-implicit-coercion.md Outdated Show resolved Hide resolved
docs/rules/no-implicit-coercion.md Show resolved Hide resolved
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@mdjermanovic mdjermanovic merged commit f06ecdf into eslint:master Apr 9, 2021
@mdjermanovic
Copy link
Member

Thanks for contributing!

@remcohaszing
Copy link
Contributor Author

Thanks for your code reviews!

@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Oct 7, 2021
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Oct 7, 2021
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

Successfully merging this pull request may close these issues.

Rule proposal: No useless template string, or prefer String()
4 participants