Do not respect newlines for object destructuring pattern (#981)
This was intended for object expressions. I tried to remove it for ObjectTypeAnnotation but it changes a ton of stuff as it's used all over the place in many different contexts. We should clean it up but in a later PR :) Fixes part of #975master
parent
0fc8584827
commit
36a1d12f47
|
@ -700,11 +700,12 @@ function genericPrintNoParens(path, options, print) {
|
||||||
const canHaveTrailingComma = !(lastElem &&
|
const canHaveTrailingComma = !(lastElem &&
|
||||||
lastElem.type === "RestProperty");
|
lastElem.type === "RestProperty");
|
||||||
|
|
||||||
const shouldBreak = util.hasNewlineInRange(
|
const shouldBreak = n.type !== "ObjectPattern" &&
|
||||||
options.originalText,
|
util.hasNewlineInRange(
|
||||||
util.locStart(n),
|
options.originalText,
|
||||||
util.locEnd(n)
|
util.locStart(n),
|
||||||
);
|
util.locEnd(n)
|
||||||
|
);
|
||||||
|
|
||||||
if (props.length === 0) {
|
if (props.length === 0) {
|
||||||
return group(
|
return group(
|
||||||
|
|
|
@ -1,5 +1,22 @@
|
||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`expand.js 1`] = `
|
||||||
|
"const Component1 = ({ props }) => (
|
||||||
|
<Text>Test</Text>
|
||||||
|
);
|
||||||
|
|
||||||
|
const Component2 = ({
|
||||||
|
props
|
||||||
|
}) => (
|
||||||
|
<Text>Test</Text>
|
||||||
|
);
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
const Component1 = ({ props }) => <Text>Test</Text>;
|
||||||
|
|
||||||
|
const Component2 = ({ props }) => <Text>Test</Text>;
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`expression.js 1`] = `
|
exports[`expression.js 1`] = `
|
||||||
"() => ({}\`\`);
|
"() => ({}\`\`);
|
||||||
({})\`\`;
|
({})\`\`;
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
const Component1 = ({ props }) => (
|
||||||
|
<Text>Test</Text>
|
||||||
|
);
|
||||||
|
|
||||||
|
const Component2 = ({
|
||||||
|
props
|
||||||
|
}) => (
|
||||||
|
<Text>Test</Text>
|
||||||
|
);
|
Loading…
Reference in New Issue