mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-26 10:43:51 -05:00
Merge pull request #9361 from SaschaNaz/noFormatInJsxElement
Fix formatting on JsxElement/JsxExpression
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
//// </div>
|
||||
//// )
|
||||
////}
|
||||
////
|
||||
////
|
||||
////function foo1() {
|
||||
//// return (
|
||||
//// <div className="commentBox" data-id="test">
|
||||
@@ -45,8 +45,8 @@
|
||||
//// class3= {/*5*/
|
||||
//// }/>/*6*/
|
||||
//// )
|
||||
////}
|
||||
////
|
||||
////}
|
||||
////
|
||||
////(function () {
|
||||
//// return <div
|
||||
////className=""/*attrAutoformat*/
|
||||
@@ -64,7 +64,14 @@
|
||||
/////*childJsxElementIndent*/
|
||||
////<span></span>/*grandchildJsxElementAutoformat*/
|
||||
////</span>/*containedClosingTagAutoformat*/
|
||||
////</h5>
|
||||
////</h5>;
|
||||
////
|
||||
////<div>,{integer}</div>;/*commaInJsxElement*/
|
||||
////<div>, {integer}</div>;/*commaInJsxElement2*/
|
||||
////<span>)</span>;/*closingParenInJsxElement*/
|
||||
////<span>) </span>;/*closingParenInJsxElement2*/
|
||||
////<Router routes={ 3 } />;/*jsxExpressionSpaces*/
|
||||
////<Router routes={ (3) } />;/*jsxExpressionSpaces2*/
|
||||
|
||||
format.document();
|
||||
goTo.marker("autoformat");
|
||||
@@ -114,7 +121,7 @@ verify.indentationIs(12);
|
||||
|
||||
goTo.marker("danglingBracketAutoformat")
|
||||
// TODO: verify.currentLineContentIs(" >");
|
||||
verify.currentLineContentIs(" >");
|
||||
verify.currentLineContentIs(" >");
|
||||
goTo.marker("closingTagAutoformat");
|
||||
verify.currentLineContentIs(" </div>");
|
||||
|
||||
@@ -125,4 +132,17 @@ verify.indentationIs(8);
|
||||
goTo.marker("grandchildJsxElementAutoformat");
|
||||
verify.currentLineContentIs(" <span></span>");
|
||||
goTo.marker("containedClosingTagAutoformat");
|
||||
verify.currentLineContentIs(" </span>");
|
||||
verify.currentLineContentIs(" </span>");
|
||||
|
||||
goTo.marker("commaInJsxElement");
|
||||
verify.currentLineContentIs("<div>,{integer}</div>;");
|
||||
goTo.marker("commaInJsxElement2");
|
||||
verify.currentLineContentIs("<div>, {integer}</div>;");
|
||||
goTo.marker("closingParenInJsxElement");
|
||||
verify.currentLineContentIs("<span>)</span>;");
|
||||
goTo.marker("closingParenInJsxElement2");
|
||||
verify.currentLineContentIs("<span>) </span>;");
|
||||
goTo.marker("jsxExpressionSpaces");
|
||||
verify.currentLineContentIs("<Router routes={3} />;");
|
||||
goTo.marker("jsxExpressionSpaces2");
|
||||
verify.currentLineContentIs("<Router routes={(3)} />;");
|
||||
32
tests/cases/fourslash/formattingOptionsChangeJsx.ts
Normal file
32
tests/cases/fourslash/formattingOptionsChangeJsx.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
///<reference path="fourslash.ts"/>
|
||||
|
||||
//@Filename: file.tsx
|
||||
/////*InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces*/<Madoka homu={ true } saya={ (true) } />;
|
||||
|
||||
runTest("InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces", "<Madoka homu={ true } saya={ (true) } />;", "<Madoka homu={true} saya={(true)} />;");
|
||||
|
||||
|
||||
function runTest(propertyName: string, expectedStringWhenTrue: string, expectedStringWhenFalse: string) {
|
||||
// Go to the correct file
|
||||
goTo.marker(propertyName);
|
||||
|
||||
// Set the option to false first
|
||||
format.setOption(propertyName, false);
|
||||
|
||||
// Format
|
||||
format.document();
|
||||
|
||||
// Verify
|
||||
goTo.marker(propertyName);
|
||||
verify.currentLineContentIs(expectedStringWhenFalse);
|
||||
|
||||
// Set the option to true
|
||||
format.setOption(propertyName, true);
|
||||
|
||||
// Format
|
||||
format.document();
|
||||
|
||||
// Verify
|
||||
goTo.marker(propertyName);
|
||||
verify.currentLineContentIs(expectedStringWhenTrue);
|
||||
}
|
||||
Reference in New Issue
Block a user