@@ -90,7 +90,7 @@ export function getAllRules(): RuleSpec[] {
90
90
rule ( "IgnoreAfterLineComment" , SyntaxKind . SingleLineCommentTrivia , anyToken , anyContext , RuleAction . StopProcessingSpaceActions ) ,
91
91
92
92
rule ( "NotSpaceBeforeColon" , anyToken , SyntaxKind . ColonToken , [ isNonJsxSameLineTokenContext , isNotBinaryOpContext , isNotTypeAnnotationContext ] , RuleAction . DeleteSpace ) ,
93
- rule ( "SpaceAfterColon" , SyntaxKind . ColonToken , anyToken , [ isNonJsxSameLineTokenContext , isNotBinaryOpContext ] , RuleAction . InsertSpace ) ,
93
+ rule ( "SpaceAfterColon" , SyntaxKind . ColonToken , anyToken , [ isNonJsxSameLineTokenContext , isNotBinaryOpContext , isNextTokenParentNotJsxNamespacedName ] , RuleAction . InsertSpace ) ,
94
94
rule ( "NoSpaceBeforeQuestionMark" , anyToken , SyntaxKind . QuestionToken , [ isNonJsxSameLineTokenContext , isNotBinaryOpContext , isNotTypeAnnotationContext ] , RuleAction . DeleteSpace ) ,
95
95
// insert space after '?' only when it is used in conditional operator
96
96
rule ( "SpaceAfterQuestionMarkInConditionalOperator" , SyntaxKind . QuestionToken , anyToken , [ isNonJsxSameLineTokenContext , isConditionalOperatorContext ] , RuleAction . InsertSpace ) ,
@@ -179,6 +179,8 @@ export function getAllRules(): RuleSpec[] {
179
179
rule ( "NoSpaceBeforeGreaterThanTokenInJsxOpeningElement" , SyntaxKind . SlashToken , SyntaxKind . GreaterThanToken , [ isJsxSelfClosingElementContext , isNonJsxSameLineTokenContext ] , RuleAction . DeleteSpace ) ,
180
180
rule ( "NoSpaceBeforeEqualInJsxAttribute" , anyToken , SyntaxKind . EqualsToken , [ isJsxAttributeContext , isNonJsxSameLineTokenContext ] , RuleAction . DeleteSpace ) ,
181
181
rule ( "NoSpaceAfterEqualInJsxAttribute" , SyntaxKind . EqualsToken , anyToken , [ isJsxAttributeContext , isNonJsxSameLineTokenContext ] , RuleAction . DeleteSpace ) ,
182
+ rule ( "NoSpaceBeforeJsxNamespaceColon" , SyntaxKind . Identifier , SyntaxKind . ColonToken , [ isNextTokenParentJsxNamespacedName ] , RuleAction . DeleteSpace ) ,
183
+ rule ( "NoSpaceAfterJsxNamespaceColon" , SyntaxKind . ColonToken , SyntaxKind . Identifier , [ isNextTokenParentJsxNamespacedName ] , RuleAction . DeleteSpace ) ,
182
184
183
185
// TypeScript-specific rules
184
186
// Use of module as a function call. e.g.: import m2 = module("m2");
@@ -749,13 +751,23 @@ function isJsxExpressionContext(context: FormattingContext): boolean {
749
751
}
750
752
751
753
function isNextTokenParentJsxAttribute ( context : FormattingContext ) : boolean {
752
- return context . nextTokenParent . kind === SyntaxKind . JsxAttribute ;
754
+ return context . nextTokenParent . kind === SyntaxKind . JsxAttribute || (
755
+ context . nextTokenParent . kind === SyntaxKind . JsxNamespacedName && context . nextTokenParent . parent . kind === SyntaxKind . JsxAttribute
756
+ ) ;
753
757
}
754
758
755
759
function isJsxAttributeContext ( context : FormattingContext ) : boolean {
756
760
return context . contextNode . kind === SyntaxKind . JsxAttribute ;
757
761
}
758
762
763
+ function isNextTokenParentNotJsxNamespacedName ( context : FormattingContext ) : boolean {
764
+ return context . nextTokenParent . kind !== SyntaxKind . JsxNamespacedName ;
765
+ }
766
+
767
+ function isNextTokenParentJsxNamespacedName ( context : FormattingContext ) : boolean {
768
+ return context . nextTokenParent . kind === SyntaxKind . JsxNamespacedName ;
769
+ }
770
+
759
771
function isJsxSelfClosingElementContext ( context : FormattingContext ) : boolean {
760
772
return context . contextNode . kind === SyntaxKind . JsxSelfClosingElement ;
761
773
}
0 commit comments