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
Fix: no-implicit-coercion string concat false positive (fixes #7057) #7060
Conversation
@kaicataldo, thanks for your PR! By analyzing the annotation information on this pull request, we identified @mysticatea, @ipanasenko and @vitorbal to be potential reviewers |
00270a5
to
eaf964d
Compare
LGTM |
Thanks for doing this! |
* string literal or not. | ||
*/ | ||
function isString(node) { | ||
return node.type === "Literal" && typeof node.value === "string"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using isStringLiteral
from ast-utils? (One significant difference, that function also checks for TemplateLiterals. I think that might be okay here, though.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh cool! Didn't know about this - thanks!
Left a suggestion about using an ast-utils method and adding a test. In addition: If you do follow my suggestion and use ast-utils' Thanks, otherwise looks great! |
eaf964d
to
23cbfac
Compare
Updated with suggested changes - thanks! |
23cbfac
to
dcaefe2
Compare
LGTM |
Thanks @kaicataldo! I was originally thinking of tests like this: foo + ``;
`` + foo; Maybe I'm missing something-- are empty TemplateLiterals syntactically invalid? |
This is something that the rule does not currently check - do we want to lump that change into this bug fix? |
6669531
to
229f208
Compare
Updated - this has become a sort of enhancement/secondary bug fix in addition to the bug I set out to fix, in that it is now updated to check ES6 |
229f208
to
ea2f408
Compare
LGTM |
Sorry, I didn't realize templates weren't flagged by this! On Sep 5, 2016 6:03 PM, "ESLint Bot" notifications@github.com wrote:
|
ea2f408
to
69e6776
Compare
Seems like a worthwhile update (I think this rule was written before ES6), just want to make sure it doesn't accidentally get snuck in without consideration. Merging this change would constitute a minor bump instead of a patch. Happy to revert the suggested changes and split this up into two PRs with a separate issue for adding @eslint/eslint-team Thoughts? |
69e6776
to
83665c9
Compare
LGTM |
It seems like the easier and less controversial approach would be to split this into two PRs. |
@kaicataldo Sorry, this came up because I wanted you to use ast-utils. 😄 If you want to revert that change so this PR remains a bugfix, please go ahead. I'll write an enhancement request issue for enforcing on template literals as well. |
No need to apologize :) Alright, let's split this up. Will revert to the original PR and we can discuss adding support for template strings in a separate issue. |
83665c9
to
2f0a740
Compare
Reverted to just the original bug fix (but still using |
be71e5b
to
ac8580e
Compare
ac8580e
to
8fd5ec3
Compare
LGTM |
@platinumazure How does this look now? Want to make sure I get your feedback since you commented on the original iteration! |
LGTM, thanks! |
LGTM |
LGTM. Thanks |
The rule was checking that the
Literal
is not a number in the case of+foo
(so it would not warn for+42
), but was not doing the same for strings.