Break JSXOpeningElement between attributes (fixes #15)
parent
d91a28ef81
commit
b09a02084f
|
@ -1091,8 +1091,13 @@ function genericPrintNoParens(path, options, print) {
|
|||
concat([
|
||||
"<",
|
||||
path.call(print, "name"),
|
||||
concat(path.map(attr => concat([" ", print(attr)]), "attributes")),
|
||||
n.selfClosing ? " />" : ">"
|
||||
multilineGroup(concat([
|
||||
indent(options.tabWidth,
|
||||
concat(path.map(attr => concat([line, print(attr)]), "attributes"))
|
||||
),
|
||||
n.selfClosing ? line : softline,
|
||||
])),
|
||||
n.selfClosing ? "/>" : ">"
|
||||
])
|
||||
);
|
||||
case "JSXClosingElement":
|
||||
|
|
|
@ -70,15 +70,65 @@ const comp3 = (
|
|||
);
|
||||
|
||||
const comp4 = (
|
||||
<div style={
|
||||
styles
|
||||
} key=\"something\">Create wrapping parens and indent<strong>all the things</strong>.</div>
|
||||
<div
|
||||
style={styles}
|
||||
key=\"something\"
|
||||
>Create wrapping parens and indent<strong>all the things</strong>.</div>
|
||||
);
|
||||
|
||||
const comp5 = <div>Keep it on one line.</div>;
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test jsx-split-attrs.js 1`] = `
|
||||
"long_closed =
|
||||
<BaseForm url=\"/auth/google\" method=\"GET\" colour=\"blue\" size=\"large\" submitLabel=\"Sign in with Google\"/>
|
||||
|
||||
long_open =
|
||||
<BaseForm url=\"/auth/google\" method=\"GET\" colour=\"blue\" size=\"large\" submitLabel=\"Sign in with Google\">
|
||||
hello
|
||||
</BaseForm>
|
||||
|
||||
short_closed =
|
||||
<BaseForm url=\"/auth/google\" method=\"GET\"/>
|
||||
|
||||
short_open =
|
||||
<BaseForm url=\"/auth/google\" method=\"GET\">
|
||||
hello
|
||||
</BaseForm>
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
long_closed = (
|
||||
<BaseForm
|
||||
url=\"/auth/google\"
|
||||
method=\"GET\"
|
||||
colour=\"blue\"
|
||||
size=\"large\"
|
||||
submitLabel=\"Sign in with Google\"
|
||||
/>
|
||||
);
|
||||
|
||||
long_open = (
|
||||
<BaseForm
|
||||
url=\"/auth/google\"
|
||||
method=\"GET\"
|
||||
colour=\"blue\"
|
||||
size=\"large\"
|
||||
submitLabel=\"Sign in with Google\"
|
||||
>
|
||||
hello
|
||||
</BaseForm>
|
||||
);
|
||||
|
||||
short_closed = <BaseForm url=\"/auth/google\" method=\"GET\" />;
|
||||
|
||||
short_open = (
|
||||
<BaseForm url=\"/auth/google\" method=\"GET\">
|
||||
hello
|
||||
</BaseForm>
|
||||
);
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test jsx-stateless-arrow-fn.js 1`] = `
|
||||
"const render1 = ({ styles }) => (
|
||||
<div style={styles} key=\"something\">
|
||||
|
@ -115,9 +165,10 @@ const render3 = ({ styles }) => (
|
|||
);
|
||||
|
||||
const render4 = ({ styles }) => (
|
||||
<div style={
|
||||
styles
|
||||
} key=\"something\">Create wrapping parens and indent<strong>all the things</strong>.</div>
|
||||
<div
|
||||
style={styles}
|
||||
key=\"something\"
|
||||
>Create wrapping parens and indent<strong>all the things</strong>.</div>
|
||||
);
|
||||
|
||||
const render5 = ({ styles }) => <div>Keep it on one line.</div>;
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
long_closed =
|
||||
<BaseForm url="/auth/google" method="GET" colour="blue" size="large" submitLabel="Sign in with Google"/>
|
||||
|
||||
long_open =
|
||||
<BaseForm url="/auth/google" method="GET" colour="blue" size="large" submitLabel="Sign in with Google">
|
||||
hello
|
||||
</BaseForm>
|
||||
|
||||
short_closed =
|
||||
<BaseForm url="/auth/google" method="GET"/>
|
||||
|
||||
short_open =
|
||||
<BaseForm url="/auth/google" method="GET">
|
||||
hello
|
||||
</BaseForm>
|
Loading…
Reference in New Issue