@@ -52,6 +52,10 @@ namespace ts.formatting {
5252 public SpaceBeforeCloseBrace : Rule ;
5353 public NoSpaceBetweenEmptyBraceBrackets : Rule ;
5454
55+ // No space after { and before } in JSX expression
56+ public NoSpaceAfterOpenBraceInJsxExpression : Rule ;
57+ public NoSpaceBeforeCloseBraceInJsxExpression : Rule ;
58+
5559 // Insert new line after { and before } in multi-line contexts.
5660 public NewLineAfterOpenBraceInBlockContext : Rule ;
5761
@@ -276,6 +280,10 @@ namespace ts.formatting {
276280 this . SpaceBeforeCloseBrace = new Rule ( RuleDescriptor . create2 ( Shared . TokenRange . Any , SyntaxKind . CloseBraceToken ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsSingleLineBlockContext ) , RuleAction . Space ) ) ;
277281 this . NoSpaceBetweenEmptyBraceBrackets = new Rule ( RuleDescriptor . create1 ( SyntaxKind . OpenBraceToken , SyntaxKind . CloseBraceToken ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsNonJsxSameLineTokenContext , Rules . IsObjectContext ) , RuleAction . Delete ) ) ;
278282
283+ // No space after { and before } in JSX expression
284+ this . NoSpaceAfterOpenBraceInJsxExpression = new Rule ( RuleDescriptor . create3 ( SyntaxKind . OpenBraceToken , Shared . TokenRange . Any ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsNonJsxSameLineTokenContext , Rules . isJsxExpressionContext ) , RuleAction . Delete ) ) ;
285+ this . NoSpaceBeforeCloseBraceInJsxExpression = new Rule ( RuleDescriptor . create2 ( Shared . TokenRange . Any , SyntaxKind . CloseBraceToken ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsNonJsxSameLineTokenContext , Rules . isJsxExpressionContext ) , RuleAction . Delete ) ) ;
286+
279287 // Insert new line after { and before } in multi-line contexts.
280288 this . NewLineAfterOpenBraceInBlockContext = new Rule ( RuleDescriptor . create3 ( SyntaxKind . OpenBraceToken , Shared . TokenRange . Any ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsMultilineBlockContext ) , RuleAction . NewLine ) ) ;
281289
@@ -395,6 +403,7 @@ namespace ts.formatting {
395403 this . SpaceAfterSubtractWhenFollowedByUnaryMinus , this . SpaceAfterSubtractWhenFollowedByPredecrement ,
396404 this . NoSpaceAfterCloseBrace ,
397405 this . SpaceAfterOpenBrace , this . SpaceBeforeCloseBrace , this . NewLineBeforeCloseBraceInBlockContext ,
406+ this . NoSpaceAfterOpenBraceInJsxExpression , this . NoSpaceBeforeCloseBraceInJsxExpression ,
398407 this . SpaceAfterCloseBrace , this . SpaceBetweenCloseBraceAndElse , this . SpaceBetweenCloseBraceAndWhile , this . NoSpaceBetweenEmptyBraceBrackets ,
399408 this . NoSpaceBetweenFunctionKeywordAndStar , this . SpaceAfterStarInGeneratorDeclaration ,
400409 this . SpaceAfterFunctionInFuncDecl , this . NewLineAfterOpenBraceInBlockContext , this . SpaceAfterGetSetInMember ,
@@ -727,6 +736,10 @@ namespace ts.formatting {
727736 return context . contextNode . kind !== SyntaxKind . JsxElement ;
728737 }
729738
739+ static isJsxExpressionContext ( context : FormattingContext ) : boolean {
740+ return context . contextNode . kind === SyntaxKind . JsxExpression ;
741+ }
742+
730743 static IsNotBeforeBlockInFunctionDeclarationContext ( context : FormattingContext ) : boolean {
731744 return ! Rules . IsFunctionDeclContext ( context ) && ! Rules . IsBeforeBlockContext ( context ) ;
732745 }
0 commit comments