Allow to break after = for strings (#1142)
This is not a general fix but it solves some issues that people are seeing where prettier goes > 80 columns. Fixes #1141 Also fixes part of #1110
This commit is contained in:
1 parent
6b806d4411
commit
41dee70795
5 files changed
+19
-2
No files matched your search
+6
-1
@@ -3070,7 +3070,12 @@ function printAssignment(printedLeft, operator, rightNode, printedRight, options
|
||||
printed = indent(
|
||||
concat([hardline, printedRight])
|
||||
);
|
||||
} else if (isBinaryish(rightNode) && !shouldInlineLogicalExpression(rightNode)) {
|
||||
} else if (
|
||||
(isBinaryish(rightNode) && !shouldInlineLogicalExpression(rightNode)) ||
|
||||
rightNode.type === "StringLiteral" ||
|
||||
(rightNode.type === "Literal" &&
|
||||
typeof rightNode.value === "string")
|
||||
) {
|
||||
printed = indent(
|
||||
concat([line, printedRight])
|
||||
);
|
||||
|
||||
+2
-1
@@ -7,6 +7,7 @@ export var name: \\"subdir/custom_resolve_dir/testproj2\\" = \\"subdir/custom_re
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
|
||||
export var name: \\"subdir/custom_resolve_dir/testproj2\\" = \\"subdir/custom_resolve_dir/testproj2\\";
|
||||
export var name: \\"subdir/custom_resolve_dir/testproj2\\" =
|
||||
\\"subdir/custom_resolve_dir/testproj2\\";
|
||||
"
|
||||
`;
|
||||
@@ -0,0 +1,9 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`string.js 1`] = `
|
||||
"elements[0].innerHTML = '<div></div><div></div><div></div><div></div><div></div><div></div>';
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
elements[0].innerHTML =
|
||||
\\"<div></div><div></div><div></div><div></div><div></div><div></div>\\";
|
||||
"
|
||||
`;
|
||||
@@ -0,0 +1 @@
|
||||
run_spec(__dirname, null, ["babylon", "typescript"]);
|
||||
@@ -0,0 +1 @@
|
||||
elements[0].innerHTML = '<div></div><div></div><div></div><div></div><div></div><div></div>';
|
||||
Reference in new issue
Block a user