Skip to content

Commit 4e401ca

Browse files
committed
update string template rule and test
1 parent d9bc436 commit 4e401ca

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/services/formatting/rules.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,8 @@ namespace ts.formatting {
126126
rule("SpaceBetweenAsyncAndOpenParen", SyntaxKind.AsyncKeyword, SyntaxKind.OpenParenToken, [isArrowFunctionContext, isNonJsxSameLineTokenContext], RuleAction.Space),
127127
rule("SpaceBetweenAsyncAndFunctionKeyword", SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword, [isNonJsxSameLineTokenContext], RuleAction.Space),
128128

129-
// template string
130-
rule("NoSpaceBetweenTagAndTemplateString", SyntaxKind.Identifier, [SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead], [isNonJsxSameLineTokenContext], RuleAction.Delete),
131-
132-
// No space between closing parenthesis and template string
133-
rule("NoSpaceBetweenCloseParenAndTemplateString", SyntaxKind.CloseParenToken, SyntaxKind.NoSubstitutionTemplateLiteral, [isNonJsxSameLineTokenContext], RuleAction.Delete),
129+
// Template string
130+
rule("NoSpaceBetweenTagAndTemplateString", [SyntaxKind.Identifier, SyntaxKind.CloseParenToken], [SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead], [isNonJsxSameLineTokenContext], RuleAction.Delete),
134131

135132
// JSX opening elements
136133
rule("SpaceBeforeJsxAttribute", anyToken, SyntaxKind.Identifier, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], RuleAction.Space),

tests/cases/fourslash/formatNoSpaceBetweenClosingParenAndTemplateString.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
//// foo() `abc`;
44
//// bar()`def`;
5+
//// baz()`a${x}b`;
56

67
format.document();
78
verify.currentFileContentIs(
89
`foo()\`abc\`;
9-
bar()\`def\`;`
10+
bar()\`def\`;
11+
baz()\`a\${x}b\`;`
1012
);

0 commit comments

Comments
 (0)