-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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: wrong indent at tagged template in indent (fixes #12122) #12596
Conversation
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. Thank you!
I'm not sure... but I couldn't reproduce it on v6.7.2: online demo. |
I could reproduce it if an interpolation exists: online demo Therefore, I think that this bug exists around the logic of template literals rather than function calls. I'm suspecting that the indent rule doesn't set desired offsets to the tokens of |
oh yes, It's right. I think I should change the code in this pr. thanks! |
@mysticatea const a = 2,
template = `
multiline ${
expression} template literal`; // Error; so, what about just add logic within the function which checking function call(same as current pr)? |
I got it. In that case, I'm OK with fixing the logic of function calls. |
|
@kaicataldo tag`
${a}
`(() => {
tag`
${a}
`(() => {
});
}); But it had problems in cases if there are member expressions with a tagged template. tag
.member`
${a}
`(() => {
}); // expected indent, but no error. So, I changed the code to use a token before eslint/tests/lib/rules/indent.js Lines 5418 to 5438 in c780efb
eslint/tests/lib/rules/indent.js Lines 5518 to 5524 in c780efb
I re-request a review. Sorry for wasting your efforts. |
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.
Sorry for the delay. Still getting caught up on my notifications backlog from the holidays.
This mostly LGTM! Just one small comment about using a token to offset instead of the full node. Thank you for adding all these test cases 😃
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 for working on this!
…slint#12596) * Fix: check tag in tagged template literal in indent (fixes eslint#12122) * refactor, add test cases * rename variable name, delete comment * change test case * change offsetToken to token before the node.callee.quasi * refactor code, add more test cases * use token for consistency
What is the purpose of this pull request? (put an "X" next to item)
[ ] Documentation update
[x] Bug fix (template)
[ ] New rule (template)
[ ] 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)
Is there anything you'd like reviewers to focus on?