diff --git a/src/doc-builders.js b/src/doc-builders.js
index 82c7221bbe06..2172016bbb8c 100644
--- a/src/doc-builders.js
+++ b/src/doc-builders.js
@@ -68,6 +68,7 @@ function lineSuffix(contents) {
}
const lineSuffixBoundary = { type: "line-suffix-boundary" };
+const infiniteWidth = { type: "infinite-width" };
const breakParent = { type: "break-parent" };
const line = { type: "line" };
const softline = { type: "line", soft: true };
@@ -104,5 +105,6 @@ module.exports = {
lineSuffixBoundary,
breakParent,
ifBreak,
+ infiniteWidth,
indent
};
diff --git a/src/doc-printer.js b/src/doc-printer.js
index 82b493026d3e..dde771669046 100644
--- a/src/doc-printer.js
+++ b/src/doc-printer.js
@@ -28,6 +28,10 @@ function fits(next, restCommands, width) {
width -= doc.length;
} else {
switch (doc.type) {
+ case "infinite-width":
+ width = -1;
+
+ break;
case "concat":
for (var i = doc.parts.length - 1; i >= 0; i--) {
cmds.push([ind, mode, doc.parts[i]]);
@@ -101,6 +105,8 @@ function printDocToString(doc, width, newLine) {
pos += doc.length;
} else {
switch (doc.type) {
+ case "infinite-width":
+ break;
case "concat":
for (var i = doc.parts.length - 1; i >= 0; i--) {
cmds.push([ind, mode, doc.parts[i]]);
diff --git a/src/printer.js b/src/printer.js
index 875448b1b47e..17798ed12e3b 100644
--- a/src/printer.js
+++ b/src/printer.js
@@ -19,6 +19,7 @@ var conditionalGroup = docBuilders.conditionalGroup;
var ifBreak = docBuilders.ifBreak;
var breakParent = docBuilders.breakParent;
var lineSuffixBoundary = docBuilders.lineSuffixBoundary;
+var infiniteWidth = docBuilders.infiniteWidth;
var docUtils = require("./doc-utils");
var willBreak = docUtils.willBreak;
@@ -711,9 +712,9 @@ function genericPrintNoParens(path, options, print) {
parentIsUnionTypeAnnotation ? 2 : 0,
concat([options.bracketSpacing ? line : softline, rightBrace])
),
+ shouldBreak ? infiniteWidth : "",
path.call(print, "typeAnnotation")
- ]),
- { shouldBreak }
+ ])
);
}
diff --git a/tests/infinite_width/__snapshots__/jsfmt.spec.js.snap b/tests/infinite_width/__snapshots__/jsfmt.spec.js.snap
new file mode 100644
index 000000000000..66cec0ea9532
--- /dev/null
+++ b/tests/infinite_width/__snapshots__/jsfmt.spec.js.snap
@@ -0,0 +1,138 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`infinite.js 1`] = `
+"function f() {
+ if (position)
+ return {name: pair};
+ else
+ return {name: pair.substring(0, position), value: pair.substring(position + 1)};
+}
+
+function f() {
+ if (position) return { name: pair };
+ else return {
+ name: pair.substring(0, position),
+ value: pair.substring(position + 1)
+ };
+}
+
+function f() {
+ if (position)
+ return { name: pair };
+ else
+ return {
+ name: pair.substring(0, position),
+ value: pair.substring(position + 1)
+ };
+}
+
+function render() {
+ return (
+
+ this.setState({progress: Math.round(100 * e.nativeEvent.loaded / e.nativeEvent.total)})}
+ />
+
+ );
+}
+
+function render() {
+ return (
+
+
+ this.setState({
+ progress: Math.round(
+ 100 * e.nativeEvent.loaded / e.nativeEvent.total,
+ ),
+ })}
+ />
+
+ );
+}
+
+function render() {
+ return (
+
+
+ this.setState({
+ progress: Math.round(
+ 100 * e.nativeEvent.loaded / e.nativeEvent.total,
+ ),
+ })}
+ />
+
+ );
+}
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+function f() {
+ if (position) return { name: pair };
+ else return {
+ name: pair.substring(0, position),
+ value: pair.substring(position + 1)
+ };
+}
+
+function f() {
+ if (position) return { name: pair };
+ else return {
+ name: pair.substring(0, position),
+ value: pair.substring(position + 1)
+ };
+}
+
+function f() {
+ if (position) return { name: pair };
+ else return {
+ name: pair.substring(0, position),
+ value: pair.substring(position + 1)
+ };
+}
+
+function render() {
+ return (
+
+
+ this.setState({
+ progress: Math.round(
+ 100 * e.nativeEvent.loaded / e.nativeEvent.total
+ )
+ })}
+ />
+
+ );
+}
+
+function render() {
+ return (
+
+
+ this.setState({
+ progress: Math.round(
+ 100 * e.nativeEvent.loaded / e.nativeEvent.total
+ )
+ })}
+ />
+
+ );
+}
+
+function render() {
+ return (
+
+
+ this.setState({
+ progress: Math.round(
+ 100 * e.nativeEvent.loaded / e.nativeEvent.total
+ )
+ })}
+ />
+
+ );
+}
+"
+`;
diff --git a/tests/infinite_width/infinite.js b/tests/infinite_width/infinite.js
new file mode 100644
index 000000000000..1bf8d1843856
--- /dev/null
+++ b/tests/infinite_width/infinite.js
@@ -0,0 +1,64 @@
+function f() {
+ if (position)
+ return {name: pair};
+ else
+ return {name: pair.substring(0, position), value: pair.substring(position + 1)};
+}
+
+function f() {
+ if (position) return { name: pair };
+ else return {
+ name: pair.substring(0, position),
+ value: pair.substring(position + 1)
+ };
+}
+
+function f() {
+ if (position)
+ return { name: pair };
+ else
+ return {
+ name: pair.substring(0, position),
+ value: pair.substring(position + 1)
+ };
+}
+
+function render() {
+ return (
+
+ this.setState({progress: Math.round(100 * e.nativeEvent.loaded / e.nativeEvent.total)})}
+ />
+
+ );
+}
+
+function render() {
+ return (
+
+
+ this.setState({
+ progress: Math.round(
+ 100 * e.nativeEvent.loaded / e.nativeEvent.total,
+ ),
+ })}
+ />
+
+ );
+}
+
+function render() {
+ return (
+
+
+ this.setState({
+ progress: Math.round(
+ 100 * e.nativeEvent.loaded / e.nativeEvent.total,
+ ),
+ })}
+ />
+
+ );
+}
diff --git a/tests/infinite_width/jsfmt.spec.js b/tests/infinite_width/jsfmt.spec.js
new file mode 100644
index 000000000000..989047bccc52
--- /dev/null
+++ b/tests/infinite_width/jsfmt.spec.js
@@ -0,0 +1 @@
+run_spec(__dirname);
diff --git a/tests/method-chain/__snapshots__/jsfmt.spec.js.snap b/tests/method-chain/__snapshots__/jsfmt.spec.js.snap
index 604d125a15f0..8dfc0506bd24 100644
--- a/tests/method-chain/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/method-chain/__snapshots__/jsfmt.spec.js.snap
@@ -39,18 +39,20 @@ it('should group messages with same created time', () => {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export default store => {
return callApi(endpoint, schema).then(
- response => next(
- actionWith({
- response,
- type: successType
- })
- ),
- error => next(
- actionWith({
- type: failureType,
- error: error.message || \\"Something bad happened\\"
- })
- )
+ response =>
+ next(
+ actionWith({
+ response,
+ type: successType
+ })
+ ),
+ error =>
+ next(
+ actionWith({
+ type: failureType,
+ error: error.message || \\"Something bad happened\\"
+ })
+ )
);
};
@@ -171,18 +173,21 @@ function f() {
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export default function theFunction(action$, store) {
- return action$.ofType(THE_ACTION).switchMap(action => Observable.webSocket({
- url: THE_URL,
- more: stuff(),
- evenMore: stuff({
- value1: true,
- value2: false,
- value3: false
- })
- })
- .filter(data => theFilter(data))
- .map(({ theType, ...data }) => theMap(theType, data))
- .retryWhen(errors => errors));
+ return action$
+ .ofType(THE_ACTION)
+ .switchMap(action =>
+ Observable.webSocket({
+ url: THE_URL,
+ more: stuff(),
+ evenMore: stuff({
+ value1: true,
+ value2: false,
+ value3: false
+ })
+ })
+ .filter(data => theFilter(data))
+ .map(({ theType, ...data }) => theMap(theType, data))
+ .retryWhen(errors => errors));
}
function f() {
@@ -227,14 +232,16 @@ if (testConfig.ENABLE_ONLINE_TESTS === \\"true\\") {
describe(\\"POST /users/me/pet\\", function() {
it(\\"saves pet\\", function() {
function assert(pet) {
- expect(pet).to.have.property(\\"OwnerAddress\\").that.deep.equals({
- AddressLine1: \\"Alexanderstrasse\\",
- AddressLine2: \\"\\",
- PostalCode: \\"10999\\",
- Region: \\"Berlin\\",
- City: \\"Berlin\\",
- Country: \\"DE\\"
- });
+ expect(pet).to.have
+ .property(\\"OwnerAddress\\")
+ .that.deep.equals({
+ AddressLine1: \\"Alexanderstrasse\\",
+ AddressLine2: \\"\\",
+ PostalCode: \\"10999\\",
+ Region: \\"Berlin\\",
+ City: \\"Berlin\\",
+ Country: \\"DE\\"
+ });
}
});
});