diff --git a/src/doc-builders.js b/src/doc-builders.js
index d25cd06a1bc8..1e5087b2e9e5 100644
--- a/src/doc-builders.js
+++ b/src/doc-builders.js
@@ -71,6 +71,7 @@ function lineSuffix(contents) {
return { type: "line-suffix", contents };
}
+const infiniteWidth = { type: "infinite-width" };
const breakParent = { type: "break-parent" };
const line = { type: "line" };
const softline = { type: "line", soft: true };
@@ -106,5 +107,6 @@ module.exports = {
lineSuffix,
breakParent,
ifBreak,
+ infiniteWidth,
indent
};
diff --git a/src/doc-printer.js b/src/doc-printer.js
index 1e1bf276459e..82e35c5ea405 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 e78ec9718059..0772b10c3d76 100644
--- a/src/printer.js
+++ b/src/printer.js
@@ -18,6 +18,7 @@ var indent = docBuilders.indent;
var conditionalGroup = docBuilders.conditionalGroup;
var ifBreak = docBuilders.ifBreak;
var breakParent = docBuilders.breakParent;
+var infiniteWidth = docBuilders.infiniteWidth;
var docUtils = require("./doc-utils");
var willBreak = docUtils.willBreak;
@@ -650,10 +651,10 @@ function genericPrintNoParens(path, options, print) {
),
ifBreak(canHaveTrailingComma && options.trailingComma ? "," : ""),
options.bracketSpacing ? line : softline,
+ shouldBreak ? infiniteWidth : "",
rightBrace,
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..56e94b62a0ad
--- /dev/null
+++ b/tests/infinite_width/__snapshots__/jsfmt.spec.js.snap
@@ -0,0 +1,136 @@
+exports[`test 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 86427b5313f1..35db084bb52e 100644
--- a/tests/method-chain/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/method-chain/__snapshots__/jsfmt.spec.js.snap
@@ -37,18 +37,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\"
+ })
+ )
);
};
@@ -137,14 +139,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\"
+ });
}
});
});