mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
add beautifier rule for space after close paren and destructure bracket (#21859)
This commit is contained in:
1 parent
02e7696759
commit
879cb69d6a
2 files changed
+18
No files matched your search
@@ -92,6 +92,9 @@ namespace ts.formatting {
|
||||
rule("SpaceBetweenCloseBraceAndWhile", SyntaxKind.CloseBraceToken, SyntaxKind.WhileKeyword, [isNonJsxSameLineTokenContext], RuleAction.Space),
|
||||
rule("NoSpaceBetweenEmptyBraceBrackets", SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken, [isNonJsxSameLineTokenContext, isObjectContext], RuleAction.Delete),
|
||||
|
||||
// Add a space after control dec context if the next character is an open bracket ex: 'if (false)[a, b] = [1, 2];' -> 'if (false) [a, b] = [1, 2];'
|
||||
rule("SpaceAfterConditionalClosingParen", SyntaxKind.CloseParenToken, SyntaxKind.OpenBracketToken, [isControlDeclContext], RuleAction.Space),
|
||||
|
||||
rule("NoSpaceBetweenFunctionKeywordAndStar", SyntaxKind.FunctionKeyword, SyntaxKind.AsteriskToken, [isFunctionDeclarationOrFunctionExpressionContext], RuleAction.Delete),
|
||||
rule("SpaceAfterStarInGeneratorDeclaration", SyntaxKind.AsteriskToken, [SyntaxKind.Identifier, SyntaxKind.OpenParenToken], [isFunctionDeclarationOrFunctionExpressionContext], RuleAction.Space),
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// let a, b;
|
||||
//// /*1*/if (false)[a, b] = [1, 2];
|
||||
//// /*2*/if (true) [a, b] = [1, 2];
|
||||
//// /*3*/var a = [1, 2, 3].map(num => num) [0];
|
||||
|
||||
format.document();
|
||||
|
||||
goTo.marker("1");
|
||||
verify.currentLineContentIs("if (false) [a, b] = [1, 2];");
|
||||
goTo.marker("2");
|
||||
verify.currentLineContentIs("if (true) [a, b] = [1, 2];");
|
||||
goTo.marker("3");
|
||||
verify.currentLineContentIs("var a = [1, 2, 3].map(num => num)[0];");
|
||||
Reference in new issue
Block a user