Preserve blank lines between JSX attributes (#19161)

This commit is contained in:
Igor authored and GitHub committed 2026-06-03 15:40:52 +08:00
1 parent d9e261f836
commit 0a825b05dc
8 files changed
+328 -1

No files matched your search

@@ -0,0 +1,171 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`attribute-blank-lines.js - {"singleAttributePerLine":true} format 1`] = `
====================================options=====================================
parsers: ["flow", "babel", "typescript"]
singleAttributePerLine: true
printWidth: 80 (default) |
=====================================input======================================
const basic = (
<Component
first={1}
second={2}
third={3}
/>
);
const multipleBlankLines = (
<Component
first={1}
second={2}
/>
);
const spreadAttributes = (
<Component
first={1}
{...props}
second={2}
/>
);
const noBlankLines = (
<Component
first={1}
second={2}
third={3}
/>
);
const inlineAttributes = <Component first={1} second={2} />;
=====================================output=====================================
const basic = (
<Component
first={1}
second={2}
third={3}
/>
);
const multipleBlankLines = (
<Component
first={1}
second={2}
/>
);
const spreadAttributes = (
<Component
first={1}
{...props}
second={2}
/>
);
const noBlankLines = (
<Component
first={1}
second={2}
third={3}
/>
);
const inlineAttributes = (
<Component
first={1}
second={2}
/>
);
================================================================================
`;
exports[`attribute-blank-lines.js format 1`] = `
====================================options=====================================
parsers: ["flow", "babel", "typescript"]
printWidth: 80 (default) |
=====================================input======================================
const basic = (
<Component
first={1}
second={2}
third={3}
/>
);
const multipleBlankLines = (
<Component
first={1}
second={2}
/>
);
const spreadAttributes = (
<Component
first={1}
{...props}
second={2}
/>
);
const noBlankLines = (
<Component
first={1}
second={2}
third={3}
/>
);
const inlineAttributes = <Component first={1} second={2} />;
=====================================output=====================================
const basic = (
<Component
first={1}
second={2}
third={3}
/>
);
const multipleBlankLines = (
<Component
first={1}
second={2}
/>
);
const spreadAttributes = (
<Component
first={1}
{...props}
second={2}
/>
);
const noBlankLines = <Component first={1} second={2} third={3} />;
const inlineAttributes = <Component first={1} second={2} />;
================================================================================
`;
@@ -0,0 +1,38 @@
const basic = (
<Component
first={1}
second={2}
third={3}
/>
);
const multipleBlankLines = (
<Component
first={1}
second={2}
/>
);
const spreadAttributes = (
<Component
first={1}
{...props}
second={2}
/>
);
const noBlankLines = (
<Component
first={1}
second={2}
third={3}
/>
);
const inlineAttributes = <Component first={1} second={2} />;
@@ -0,0 +1,4 @@
runFormatTest(import.meta, ["flow", "babel", "typescript"]);
runFormatTest(import.meta, ["flow", "babel", "typescript"], {
singleAttributePerLine: true,
});
@@ -4988,21 +4988,29 @@ singleQuote: false
<div
single="foo"
single2={"foo"}
double="bar"
double2={"bar"}
singleDouble='"'
singleDouble2={'"'}
doubleSingle="'"
doubleSingle2={"'"}
singleEscaped={"'"}
singleEscaped2="'"
doubleEscaped={'"'}
doubleEscaped2='"'
singleBothEscaped={"'\\""}
singleBothEscaped2="'&quot;"
singleBoth="' &quot;"
singleBoth2={"' \\""}
singleBoth3="' ' &quot;"
doubleBoth="&quot; '"
doubleBoth2={"\\" '"}
doubleBoth3="&quot; ' '"
@@ -5077,21 +5085,29 @@ singleQuote: false
<div
single='foo'
single2={"foo"}
double='bar'
double2={"bar"}
singleDouble='"'
singleDouble2={'"'}
doubleSingle="'"
doubleSingle2={"'"}
singleEscaped={"'"}
singleEscaped2="'"
doubleEscaped={'"'}
doubleEscaped2='"'
singleBothEscaped={"'\\""}
singleBothEscaped2='&apos;"'
singleBoth='&apos; "'
singleBoth2={"' \\""}
singleBoth3="' ' &quot;"
doubleBoth='" &apos;'
doubleBoth2={"\\" '"}
doubleBoth3="&quot; ' '"
@@ -5166,21 +5182,29 @@ singleQuote: true
<div
single="foo"
single2={'foo'}
double="bar"
double2={'bar'}
singleDouble='"'
singleDouble2={'"'}
doubleSingle="'"
doubleSingle2={"'"}
singleEscaped={"'"}
singleEscaped2="'"
doubleEscaped={'"'}
doubleEscaped2='"'
singleBothEscaped={'\\'"'}
singleBothEscaped2="'&quot;"
singleBoth="' &quot;"
singleBoth2={'\\' "'}
singleBoth3="' ' &quot;"
doubleBoth="&quot; '"
doubleBoth2={'" \\''}
doubleBoth3="&quot; ' '"
@@ -5255,21 +5279,29 @@ singleQuote: true
<div
single='foo'
single2={'foo'}
double='bar'
double2={'bar'}
singleDouble='"'
singleDouble2={'"'}
doubleSingle="'"
doubleSingle2={"'"}
singleEscaped={"'"}
singleEscaped2="'"
doubleEscaped={'"'}
doubleEscaped2='"'
singleBothEscaped={'\\'"'}
singleBothEscaped2='&apos;"'
singleBoth='&apos; "'
singleBoth2={'\\' "'}
singleBoth3="' ' &quot;"
doubleBoth='" &apos;'
doubleBoth2={'" \\''}
doubleBoth3="&quot; ' '"
@@ -1,5 +1,30 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`attribute-blank-lines.tsx format 1`] = `
====================================options=====================================
parsers: ["typescript"]
printWidth: 80 (default) |
=====================================input======================================
const element = (
<Component<Props>
first={1}
second={2}
/>
);
=====================================output=====================================
const element = (
<Component<Props>
first={1}
second={2}
/>
);
================================================================================
`;
exports[`generic-component.tsx format 1`] = `
====================================options=====================================
parsers: ["typescript"]
@@ -0,0 +1,7 @@
const element = (
<Component<Props>
first={1}
second={2}
/>
);