-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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: improve fixer of prefer-template
rule
#15230
Conversation
prefer-template
prefer-template
rule
e5fdb7c
to
35ee14a
Compare
55df3b3
to
00d053c
Compare
7b0e9d9
to
db2c7b6
Compare
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.
LGTM, thanks!
I think this is a good improvement over the current behavior. A further improvement we could think about in the future could be to not change string literals that don't have to be converted to template literals.
I'll leave this open for a couple more days in case anyone else wants to review it.
@snitin315 @mdjermanovic thank you guys for the fix, do you plan to fix also the additional empty space after opening bracket so instead of var foo = Hello world ${ test} it would generate var foo = Hello world ${test} Shell I create a new issue for it? |
No, that works as intended for this rule because it doesn't know preferences about spacing in |
(see the Fixed Code tab) |
@mdjermanovic thank you for the crazy fast response and one more rule to our collection :) thank you |
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[x] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add auto fixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
Resolve #15083
Before
code:
var foo = "Hello " + "world " + test
=> fixed code: var foo =${"Hello " + "world "}${test}
After
code:
var foo = "Hello " + "world " + test
=> fixed code: var foo =Hello world ${ test}
Is there anything you'd like reviewers to focus on?
No