Fix idempotence issues caused by eol comments after = in assignments (#12349)
This commit is contained in:
1 parent
097dba9516
commit
20cc23ba35
5 files changed
+82
-4
No files matched your search
@@ -0,0 +1,23 @@
|
||||
#### Fix idempotence issues caused by line comments after `=` in assignments (#12349 by @thorn0)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
const kochabCooieGameOnOboleUnweave = // !!!
|
||||
rhubarbRhubarb(annularCooeedSplicesWalksWayWay);
|
||||
|
||||
// Prettier stable, first format
|
||||
const kochabCooieGameOnOboleUnweave = rhubarbRhubarb( // !!!
|
||||
annularCooeedSplicesWalksWayWay
|
||||
);
|
||||
|
||||
// Prettier stable, second format
|
||||
const kochabCooieGameOnOboleUnweave = rhubarbRhubarb(
|
||||
// !!!
|
||||
annularCooeedSplicesWalksWayWay
|
||||
);
|
||||
|
||||
// Prettier main
|
||||
const kochabCooieGameOnOboleUnweave = // !!!
|
||||
rhubarbRhubarb(annularCooeedSplicesWalksWayWay);
|
||||
```
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
const { isNonEmptyArray, getStringWidth } = require("../../common/util.js");
|
||||
const {
|
||||
builders: { line, group, indent, indentIfBreak },
|
||||
builders: { line, group, indent, indentIfBreak, lineSuffixBoundary },
|
||||
utils: { cleanDoc, willBreak, canBreak },
|
||||
} = require("../../document/index.js");
|
||||
const {
|
||||
@@ -50,6 +50,7 @@ function printAssignment(
|
||||
group(leftDoc),
|
||||
operator,
|
||||
group(indent(line), { id: groupId }),
|
||||
lineSuffixBoundary,
|
||||
indentIfBreak(rightDoc, { groupId }),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,47 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`call.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel", "flow", "typescript"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
if (true)
|
||||
if (true)
|
||||
if (true)
|
||||
if (true)
|
||||
if (true)
|
||||
longVariableName1 = // @ts-ignore
|
||||
(variable01 + veryLongVariableNameNumber2).method();
|
||||
|
||||
=====================================output=====================================
|
||||
if (true)
|
||||
if (true)
|
||||
if (true)
|
||||
if (true)
|
||||
if (true)
|
||||
longVariableName1 = // @ts-ignore
|
||||
(variable01 + veryLongVariableNameNumber2).method();
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`call2.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel", "flow", "typescript"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
const kochabCooieGameOnOboleUnweave = // ???
|
||||
rhubarbRhubarb(annularCooeedSplicesWalksWayWay);
|
||||
|
||||
=====================================output=====================================
|
||||
const kochabCooieGameOnOboleUnweave = // ???
|
||||
rhubarbRhubarb(annularCooeedSplicesWalksWayWay);
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`function.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel", "flow", "typescript"]
|
||||
@@ -82,7 +124,8 @@ f3 = (
|
||||
a = b //comment
|
||||
) => {};
|
||||
|
||||
f4 = () => {}; // Comment
|
||||
f4 = // Comment
|
||||
() => {};
|
||||
|
||||
f5 =
|
||||
// Comment
|
||||
@@ -109,7 +152,8 @@ let f3 = (
|
||||
a = b //comment
|
||||
) => {};
|
||||
|
||||
let f4 = () => {}; // Comment
|
||||
let f4 = // Comment
|
||||
() => {};
|
||||
|
||||
let f5 =
|
||||
// Comment
|
||||
@@ -141,7 +185,8 @@ const bifornCringerMoshedPerplexSawder = // !!!
|
||||
anodyneCondosMalateOverateRetinol;
|
||||
|
||||
=====================================output=====================================
|
||||
const kochabCooieGameOnOboleUnweave = annularCooeedSplicesWalksWayWay; // ???
|
||||
const kochabCooieGameOnOboleUnweave = // ???
|
||||
annularCooeedSplicesWalksWayWay;
|
||||
|
||||
const bifornCringerMoshedPerplexSawder = // !!!
|
||||
glimseGlyphsHazardNoopsTieTie +
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
if (true)
|
||||
if (true)
|
||||
if (true)
|
||||
if (true)
|
||||
if (true)
|
||||
longVariableName1 = // @ts-ignore
|
||||
(variable01 + veryLongVariableNameNumber2).method();
|
||||
@@ -0,0 +1,2 @@
|
||||
const kochabCooieGameOnOboleUnweave = // ???
|
||||
rhubarbRhubarb(annularCooeedSplicesWalksWayWay);
|
||||
Reference in new issue
Block a user