Skip to content

Commit

Permalink
Fix: wrong indent at tagged template in indent (fixes #12122) (#12596)
Browse files Browse the repository at this point in the history
* Fix: check tag in tagged template literal in indent (fixes #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
  • Loading branch information
yeonjuan authored and btmills committed Jan 17, 2020
1 parent d86a5bb commit de4fa7c
Show file tree
Hide file tree
Showing 2 changed files with 548 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/rules/indent.js
Expand Up @@ -933,7 +933,11 @@ module.exports = {

parameterParens.add(openingParen);
parameterParens.add(closingParen);
offsets.setDesiredOffset(openingParen, sourceCode.getTokenBefore(openingParen), 0);

const offsetAfterToken = node.callee.type === "TaggedTemplateExpression" ? sourceCode.getFirstToken(node.callee.quasi) : openingParen;
const offsetToken = sourceCode.getTokenBefore(offsetAfterToken);

offsets.setDesiredOffset(openingParen, offsetToken, 0);

addElementListIndent(node.arguments, openingParen, closingParen, options.CallExpression.arguments);
}
Expand Down

0 comments on commit de4fa7c

Please sign in to comment.