Fix rule of fill violations in utils and tests (#16656)
This commit is contained in:
1 parent
1bb69dfd13
commit
14d7f1536f
3 files changed
+5
-15
No files matched your search
@@ -72,18 +72,6 @@ describe("API", () => {
|
||||
await formatDoc(fill(["foo", hardline, "bar", literalline, "baz"])),
|
||||
).toBe('fill(["foo", hardline, "bar", literalline, "baz"])');
|
||||
|
||||
/*
|
||||
This is not really `cleanDoc` from `src/document/utils.js`
|
||||
But if we pass array to it, it will flat array
|
||||
*/
|
||||
const cleanDoc = (parts) => parts.flat();
|
||||
expect(
|
||||
await formatDoc(
|
||||
// The argument of fill must not be passed to cleanDoc because it's not a doc
|
||||
fill(cleanDoc(["foo", literalline, "bar"])), // invalid fill
|
||||
),
|
||||
).toBe('fill(["foo", literallineWithoutBreakParent, breakParent, "bar"])');
|
||||
|
||||
expect(
|
||||
await formatDoc(indentIfBreak(group(["1", line, "2"]), { groupId: "Q" })),
|
||||
).toBe('indentIfBreak(group(["1", line, "2"]), { groupId: "Q" })');
|
||||
|
||||
@@ -5,6 +5,7 @@ const {
|
||||
literalline,
|
||||
group,
|
||||
fill,
|
||||
line,
|
||||
lineSuffix,
|
||||
breakParent,
|
||||
ifBreak,
|
||||
@@ -33,7 +34,7 @@ describe("doc builders", () => {
|
||||
expandedStates: undefined,
|
||||
},
|
||||
],
|
||||
["fill", fill(["1", "2"]), { type: "fill", parts: ["1", "2"] }],
|
||||
["fill", fill(["1", line, "2"]), { type: "fill", parts: ["1", line, "2"] }],
|
||||
[
|
||||
"line-suffix",
|
||||
lineSuffix(["1"]),
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
group,
|
||||
ifBreak,
|
||||
indent,
|
||||
line,
|
||||
lineSuffix,
|
||||
} from "../../../src/document/builders.js";
|
||||
import { cleanDoc } from "../../../src/document/utils.js";
|
||||
@@ -12,8 +13,8 @@ describe("cleanDoc", () => {
|
||||
test.each([
|
||||
[
|
||||
"fill",
|
||||
[fill(["", ""]), fill([]), fill(["1"]), fill(["2", "3"])],
|
||||
[fill(["1"]), fill(["2", "3"])],
|
||||
[fill([""]), fill([]), fill(["1"]), fill(["2", line, "3"])],
|
||||
[fill(["1"]), fill(["2", line, "3"])],
|
||||
],
|
||||
["nested group", group(group("_")), group("_")],
|
||||
[
|
||||
|
||||
Reference in new issue
Block a user