Indent ternaries (#484)
parent
eaddd4b3e6
commit
72c9424c53
|
@ -771,10 +771,10 @@ function genericPrintNoParens(path, options, print) {
|
|||
concat([
|
||||
line,
|
||||
"? ",
|
||||
path.call(print, "consequent"),
|
||||
indent(options.tabWidth, path.call(print, "consequent")),
|
||||
line,
|
||||
": ",
|
||||
path.call(print, "alternate")
|
||||
indent(options.tabWidth, path.call(print, "alternate"))
|
||||
])
|
||||
)
|
||||
])
|
||||
|
|
|
@ -192,37 +192,37 @@ const renderTernary = props => (
|
|||
>
|
||||
{props.showTheThing
|
||||
? <BaseForm
|
||||
url=\"/auth/google\"
|
||||
method=\"GET\"
|
||||
colour=\"blue\"
|
||||
size=\"large\"
|
||||
submitLabel=\"Sign in with Google\"
|
||||
>
|
||||
Hello world
|
||||
</BaseForm>
|
||||
url=\"/auth/google\"
|
||||
method=\"GET\"
|
||||
colour=\"blue\"
|
||||
size=\"large\"
|
||||
submitLabel=\"Sign in with Google\"
|
||||
>
|
||||
Hello world
|
||||
</BaseForm>
|
||||
: \"hello \" + \"howdy! \"}
|
||||
{props.showTheThing
|
||||
? <BaseForm
|
||||
url=\"/auth/google\"
|
||||
method=\"GET\"
|
||||
colour=\"blue\"
|
||||
size=\"large\"
|
||||
submitLabel=\"Sign in with Google\"
|
||||
>
|
||||
Hello world
|
||||
</BaseForm>
|
||||
url=\"/auth/google\"
|
||||
method=\"GET\"
|
||||
colour=\"blue\"
|
||||
size=\"large\"
|
||||
submitLabel=\"Sign in with Google\"
|
||||
>
|
||||
Hello world
|
||||
</BaseForm>
|
||||
: null}
|
||||
{props.showTheThing
|
||||
? null
|
||||
: <BaseForm
|
||||
url=\"/auth/google\"
|
||||
method=\"GET\"
|
||||
colour=\"blue\"
|
||||
size=\"large\"
|
||||
submitLabel=\"Sign in with Google\"
|
||||
>
|
||||
Hello world
|
||||
</BaseForm>}
|
||||
url=\"/auth/google\"
|
||||
method=\"GET\"
|
||||
colour=\"blue\"
|
||||
size=\"large\"
|
||||
submitLabel=\"Sign in with Google\"
|
||||
>
|
||||
Hello world
|
||||
</BaseForm>}
|
||||
{props.showTheOtherThing ? <div>I am here</div> : <div attr=\"blah\" />}
|
||||
{props.showTheOtherThing ? <div>I am here!!</div> : null}
|
||||
</BaseForm>
|
||||
|
|
|
@ -156,15 +156,15 @@ exports[`test hug.js 1`] = `
|
|||
{__DEV__
|
||||
? this.renderDevApp()
|
||||
: <div>
|
||||
{routes.map(route => (
|
||||
<MatchAsync
|
||||
key={\`\${route.to}-async\`}
|
||||
pattern={route.to}
|
||||
exactly={route.to === \"/\"}
|
||||
getComponent={routeES6Modules[route.value]}
|
||||
/>
|
||||
))}
|
||||
</div>}
|
||||
{routes.map(route => (
|
||||
<MatchAsync
|
||||
key={\`\${route.to}-async\`}
|
||||
pattern={route.to}
|
||||
exactly={route.to === \"/\"}
|
||||
getComponent={routeES6Modules[route.value]}
|
||||
/>
|
||||
))}
|
||||
</div>}
|
||||
</div>;
|
||||
|
||||
<div>
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
exports[`test test.js 1`] = `
|
||||
"const obj0 = conditionIsTruthy ? shortThing : otherShortThing
|
||||
|
||||
const obj1 = conditionIsTruthy ? { some: \'long\', object: \'with\', lots: \'of\', stuff } : shortThing
|
||||
|
||||
const obj2 = conditionIsTruthy ? shortThing : { some: \'long\', object: \'with\', lots: \'of\', stuff }
|
||||
|
||||
const obj3 = conditionIsTruthy ? { some: \'eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger\', object: \'with\', lots: \'of\', stuff } : shortThing
|
||||
|
||||
const obj4 = conditionIsTruthy ? shortThing : { some: \'eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger\', object: \'with\', lots: \'of\', stuff }
|
||||
|
||||
const obj5 = conditionIsTruthy ? { some: \'long\', object: \'with\', lots: \'of\', stuff } : { some: \'eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger\', object: \'with\', lots: \'of\', stuff }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
const obj0 = conditionIsTruthy ? shortThing : otherShortThing;
|
||||
|
||||
const obj1 = conditionIsTruthy
|
||||
? { some: \"long\", object: \"with\", lots: \"of\", stuff }
|
||||
: shortThing;
|
||||
|
||||
const obj2 = conditionIsTruthy
|
||||
? shortThing
|
||||
: { some: \"long\", object: \"with\", lots: \"of\", stuff };
|
||||
|
||||
const obj3 = conditionIsTruthy
|
||||
? {
|
||||
some: \"eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger\",
|
||||
object: \"with\",
|
||||
lots: \"of\",
|
||||
stuff
|
||||
}
|
||||
: shortThing;
|
||||
|
||||
const obj4 = conditionIsTruthy
|
||||
? shortThing
|
||||
: {
|
||||
some: \"eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger\",
|
||||
object: \"with\",
|
||||
lots: \"of\",
|
||||
stuff
|
||||
};
|
||||
|
||||
const obj5 = conditionIsTruthy
|
||||
? { some: \"long\", object: \"with\", lots: \"of\", stuff }
|
||||
: {
|
||||
some: \"eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger\",
|
||||
object: \"with\",
|
||||
lots: \"of\",
|
||||
stuff
|
||||
};
|
||||
"
|
||||
`;
|
|
@ -0,0 +1 @@
|
|||
run_spec(__dirname);
|
|
@ -0,0 +1,11 @@
|
|||
const obj0 = conditionIsTruthy ? shortThing : otherShortThing
|
||||
|
||||
const obj1 = conditionIsTruthy ? { some: 'long', object: 'with', lots: 'of', stuff } : shortThing
|
||||
|
||||
const obj2 = conditionIsTruthy ? shortThing : { some: 'long', object: 'with', lots: 'of', stuff }
|
||||
|
||||
const obj3 = conditionIsTruthy ? { some: 'eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger', object: 'with', lots: 'of', stuff } : shortThing
|
||||
|
||||
const obj4 = conditionIsTruthy ? shortThing : { some: 'eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger', object: 'with', lots: 'of', stuff }
|
||||
|
||||
const obj5 = conditionIsTruthy ? { some: 'long', object: 'with', lots: 'of', stuff } : { some: 'eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger', object: 'with', lots: 'of', stuff }
|
Loading…
Reference in New Issue