-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Rule proposal: No useless template string, or prefer String() #12866
Comments
Hi @marcospgp , thanks for the rule proposal! This might as well be a new option in no-implicit-coercion? |
Hey @mdjermanovic , seems like a good fit. |
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
…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.
Reopening as there is an active PR for this #13579 |
+1 to have it as an option for |
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
This should be reopened since there’s an active PR for it. |
Reopened. There is an active PR #13579 |
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
This should be reopened. There's still an active PR that's awaiting feedback from the ESLint team. |
…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.
…13579) * Update: Add templateString option in no-implicit-coercion (fixes #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. * Fix no-implicit-coercion templateString examples * Skip tagged template strings in no-implicit-coercion * Add missing tests for no-implicit-coercion * Used cooked template string values * Add missing documentation for no-implicit-coercion Note that the `templateString` option isn’t affected by the `string` option. * Add missing tests for no-implicit-coercion templateString * Rename templateString to disallowTemplateString * Fix typo in no-implicit-coercion docs * Add tagged template string example for no-implicit-coercion * Update docs/rules/no-implicit-coercion.md Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com> Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
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:
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
The text was updated successfully, but these errors were encountered: