From 75b00b286871535ecdf757d6e23dd57952f54d02 Mon Sep 17 00:00:00 2001 From: seiya <20365512+seiyab@users.noreply.github.com> Date: Thu, 3 Aug 2023 22:46:02 +0900 Subject: [PATCH 1/9] add as-is test --- .../__snapshots__/jsfmt.spec.js.snap | 37 +++++++++++++++++++ .../js/assignment/await-discussion-15196.js | 9 +++++ 2 files changed, 46 insertions(+) create mode 100644 tests/format/js/assignment/await-discussion-15196.js diff --git a/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap b/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap index 0ff1d7b4c1e6..2f1e0930c10c 100644 --- a/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap @@ -1,5 +1,42 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`await-discussion-15196.js format 1`] = ` +====================================options===================================== +parsers: ["babel", "flow", "typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +async function f() { + const { section, rubric, authors, tags } = await utils.upsertCommonData(mainData); + + const loooooooooooooooooooooooooong1 = await looooooooooooooong.looooooooooooooong.loooooong; + const loooooooooooooooooooooooooong2 = await looooooooooooooong.looooooooooooooong.loooooong(); + const loooooooooooooooooooooooooong3 = await looooooooooooooooooooooooooooooooooooooooooooog(); + const loooooooooooooooooooooooooong4 = !await looooooooooooooong.looooooooooooooong.loooooong; + const loooooooooooooooooooooooooong5 = void !!await looooooooooooooong.looooooooooooooong.loooooong; +} + +=====================================output===================================== +async function f() { + const { section, rubric, authors, tags } = await utils.upsertCommonData( + mainData, + ); + + const loooooooooooooooooooooooooong1 = await looooooooooooooong + .looooooooooooooong.loooooong; + const loooooooooooooooooooooooooong2 = + await looooooooooooooong.looooooooooooooong.loooooong(); + const loooooooooooooooooooooooooong3 = + await looooooooooooooooooooooooooooooooooooooooooooog(); + const loooooooooooooooooooooooooong4 = !(await looooooooooooooong + .looooooooooooooong.loooooong); + const loooooooooooooooooooooooooong5 = void !!(await looooooooooooooong + .looooooooooooooong.loooooong); +} + +================================================================================ +`; + exports[`binaryish.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] diff --git a/tests/format/js/assignment/await-discussion-15196.js b/tests/format/js/assignment/await-discussion-15196.js new file mode 100644 index 000000000000..433846885215 --- /dev/null +++ b/tests/format/js/assignment/await-discussion-15196.js @@ -0,0 +1,9 @@ +async function f() { + const { section, rubric, authors, tags } = await utils.upsertCommonData(mainData); + + const loooooooooooooooooooooooooong1 = await looooooooooooooong.looooooooooooooong.loooooong; + const loooooooooooooooooooooooooong2 = await looooooooooooooong.looooooooooooooong.loooooong(); + const loooooooooooooooooooooooooong3 = await looooooooooooooooooooooooooooooooooooooooooooog(); + const loooooooooooooooooooooooooong4 = !await looooooooooooooong.looooooooooooooong.loooooong; + const loooooooooooooooooooooooooong5 = void !!await looooooooooooooong.looooooooooooooong.loooooong; +} From b389ea1ec41df3713745cdfd6072c6391b543804 Mon Sep 17 00:00:00 2001 From: seiya <20365512+seiyab@users.noreply.github.com> Date: Thu, 3 Aug 2023 22:50:18 +0900 Subject: [PATCH 2/9] break after equal on assignment if rhs is wait Discussion: #15196 --- src/language-js/print/assignment.js | 2 +- .../assignment/__snapshots__/jsfmt.spec.js.snap | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/language-js/print/assignment.js b/src/language-js/print/assignment.js index 8e8d032dd75a..11e2eb5ebb77 100644 --- a/src/language-js/print/assignment.js +++ b/src/language-js/print/assignment.js @@ -205,7 +205,7 @@ function shouldBreakAfterOperator(path, options, print, hasShortKey) { let node = rightNode; const propertiesForPath = []; for (;;) { - if (node.type === "UnaryExpression") { + if (node.type === "UnaryExpression" || node.type === "AwaitExpression") { node = node.argument; propertiesForPath.push("argument"); } else if (node.type === "TSNonNullExpression") { diff --git a/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap b/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap index 2f1e0930c10c..b8ae074d191f 100644 --- a/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap @@ -18,20 +18,19 @@ async function f() { =====================================output===================================== async function f() { - const { section, rubric, authors, tags } = await utils.upsertCommonData( - mainData, - ); + const { section, rubric, authors, tags } = + await utils.upsertCommonData(mainData); - const loooooooooooooooooooooooooong1 = await looooooooooooooong - .looooooooooooooong.loooooong; + const loooooooooooooooooooooooooong1 = + await looooooooooooooong.looooooooooooooong.loooooong; const loooooooooooooooooooooooooong2 = await looooooooooooooong.looooooooooooooong.loooooong(); const loooooooooooooooooooooooooong3 = await looooooooooooooooooooooooooooooooooooooooooooog(); - const loooooooooooooooooooooooooong4 = !(await looooooooooooooong - .looooooooooooooong.loooooong); - const loooooooooooooooooooooooooong5 = void !!(await looooooooooooooong - .looooooooooooooong.loooooong); + const loooooooooooooooooooooooooong4 = + !(await looooooooooooooong.looooooooooooooong.loooooong); + const loooooooooooooooooooooooooong5 = + void !!(await looooooooooooooong.looooooooooooooong.loooooong); } ================================================================================ From 7ce5fc74add2e66654c79523f4e015a77b998a32 Mon Sep 17 00:00:00 2001 From: seiya <20365512+seiyab@users.noreply.github.com> Date: Fri, 4 Aug 2023 22:10:19 +0900 Subject: [PATCH 3/9] rename test file --- .../__snapshots__/jsfmt.spec.js.snap | 72 +++++++++---------- ...iscussion-15196.js => discussion-15196.js} | 0 2 files changed, 36 insertions(+), 36 deletions(-) rename tests/format/js/assignment/{await-discussion-15196.js => discussion-15196.js} (100%) diff --git a/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap b/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap index b8ae074d191f..2d5f7061526b 100644 --- a/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap @@ -1,41 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`await-discussion-15196.js format 1`] = ` -====================================options===================================== -parsers: ["babel", "flow", "typescript"] -printWidth: 80 - | printWidth -=====================================input====================================== -async function f() { - const { section, rubric, authors, tags } = await utils.upsertCommonData(mainData); - - const loooooooooooooooooooooooooong1 = await looooooooooooooong.looooooooooooooong.loooooong; - const loooooooooooooooooooooooooong2 = await looooooooooooooong.looooooooooooooong.loooooong(); - const loooooooooooooooooooooooooong3 = await looooooooooooooooooooooooooooooooooooooooooooog(); - const loooooooooooooooooooooooooong4 = !await looooooooooooooong.looooooooooooooong.loooooong; - const loooooooooooooooooooooooooong5 = void !!await looooooooooooooong.looooooooooooooong.loooooong; -} - -=====================================output===================================== -async function f() { - const { section, rubric, authors, tags } = - await utils.upsertCommonData(mainData); - - const loooooooooooooooooooooooooong1 = - await looooooooooooooong.looooooooooooooong.loooooong; - const loooooooooooooooooooooooooong2 = - await looooooooooooooong.looooooooooooooong.loooooong(); - const loooooooooooooooooooooooooong3 = - await looooooooooooooooooooooooooooooooooooooooooooog(); - const loooooooooooooooooooooooooong4 = - !(await looooooooooooooong.looooooooooooooong.loooooong); - const loooooooooooooooooooooooooong5 = - void !!(await looooooooooooooong.looooooooooooooong.loooooong); -} - -================================================================================ -`; - exports[`binaryish.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] @@ -314,6 +278,42 @@ printWidth: 80 ================================================================================ `; +exports[`discussion-15196.js format 1`] = ` +====================================options===================================== +parsers: ["babel", "flow", "typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +async function f() { + const { section, rubric, authors, tags } = await utils.upsertCommonData(mainData); + + const loooooooooooooooooooooooooong1 = await looooooooooooooong.looooooooooooooong.loooooong; + const loooooooooooooooooooooooooong2 = await looooooooooooooong.looooooooooooooong.loooooong(); + const loooooooooooooooooooooooooong3 = await looooooooooooooooooooooooooooooooooooooooooooog(); + const loooooooooooooooooooooooooong4 = !await looooooooooooooong.looooooooooooooong.loooooong; + const loooooooooooooooooooooooooong5 = void !!await looooooooooooooong.looooooooooooooong.loooooong; +} + +=====================================output===================================== +async function f() { + const { section, rubric, authors, tags } = + await utils.upsertCommonData(mainData); + + const loooooooooooooooooooooooooong1 = + await looooooooooooooong.looooooooooooooong.loooooong; + const loooooooooooooooooooooooooong2 = + await looooooooooooooong.looooooooooooooong.loooooong(); + const loooooooooooooooooooooooooong3 = + await looooooooooooooooooooooooooooooooooooooooooooog(); + const loooooooooooooooooooooooooong4 = + !(await looooooooooooooong.looooooooooooooong.loooooong); + const loooooooooooooooooooooooooong5 = + void !!(await looooooooooooooong.looooooooooooooong.loooooong); +} + +================================================================================ +`; + exports[`issue-1419.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] diff --git a/tests/format/js/assignment/await-discussion-15196.js b/tests/format/js/assignment/discussion-15196.js similarity index 100% rename from tests/format/js/assignment/await-discussion-15196.js rename to tests/format/js/assignment/discussion-15196.js From 651099b932a4855174083b963e9039eb095309c5 Mon Sep 17 00:00:00 2001 From: seiya <20365512+seiyab@users.noreply.github.com> Date: Fri, 4 Aug 2023 22:12:06 +0900 Subject: [PATCH 4/9] add as-is test --- .../__snapshots__/jsfmt.spec.js.snap | 27 +++++++++++++++++++ .../format/js/assignment/discussion-15196.js | 10 +++++++ 2 files changed, 37 insertions(+) diff --git a/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap b/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap index 2d5f7061526b..7cb5b1b9b340 100644 --- a/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap @@ -294,6 +294,16 @@ async function f() { const loooooooooooooooooooooooooong5 = void !!await looooooooooooooong.looooooooooooooong.loooooong; } +function* g() { + const { section, rubric, authors, tags } = yield utils.upsertCommonData(mainData); + + const loooooooooooooooooooooooooong1 = yield looooooooooooooong.looooooooooooooong.loooooong; + const loooooooooooooooooooooooooong2 = yield looooooooooooooong.looooooooooooooong.loooooong(); + const loooooooooooooooooooooooooong3 = yield looooooooooooooooooooooooooooooooooooooooooooog(); + const loooooooooooooooooooooooooong4 = !(yield looooooooooooooong.looooooooooooooong.loooooong); + const loooooooooooooooooooooooooong5 = void !!(yield looooooooooooooong.looooooooooooooong.loooooong); +} + =====================================output===================================== async function f() { const { section, rubric, authors, tags } = @@ -311,6 +321,23 @@ async function f() { void !!(await looooooooooooooong.looooooooooooooong.loooooong); } +function* g() { + const { section, rubric, authors, tags } = yield utils.upsertCommonData( + mainData, + ); + + const loooooooooooooooooooooooooong1 = yield looooooooooooooong + .looooooooooooooong.loooooong; + const loooooooooooooooooooooooooong2 = + yield looooooooooooooong.looooooooooooooong.loooooong(); + const loooooooooooooooooooooooooong3 = + yield looooooooooooooooooooooooooooooooooooooooooooog(); + const loooooooooooooooooooooooooong4 = !(yield looooooooooooooong + .looooooooooooooong.loooooong); + const loooooooooooooooooooooooooong5 = void !!(yield looooooooooooooong + .looooooooooooooong.loooooong); +} + ================================================================================ `; diff --git a/tests/format/js/assignment/discussion-15196.js b/tests/format/js/assignment/discussion-15196.js index 433846885215..8579da77aa0c 100644 --- a/tests/format/js/assignment/discussion-15196.js +++ b/tests/format/js/assignment/discussion-15196.js @@ -7,3 +7,13 @@ async function f() { const loooooooooooooooooooooooooong4 = !await looooooooooooooong.looooooooooooooong.loooooong; const loooooooooooooooooooooooooong5 = void !!await looooooooooooooong.looooooooooooooong.loooooong; } + +function* g() { + const { section, rubric, authors, tags } = yield utils.upsertCommonData(mainData); + + const loooooooooooooooooooooooooong1 = yield looooooooooooooong.looooooooooooooong.loooooong; + const loooooooooooooooooooooooooong2 = yield looooooooooooooong.looooooooooooooong.loooooong(); + const loooooooooooooooooooooooooong3 = yield looooooooooooooooooooooooooooooooooooooooooooog(); + const loooooooooooooooooooooooooong4 = !(yield looooooooooooooong.looooooooooooooong.loooooong); + const loooooooooooooooooooooooooong5 = void !!(yield looooooooooooooong.looooooooooooooong.loooooong); +} From 19c26c0db73f6935a705082fbec35ebf6cc8a020 Mon Sep 17 00:00:00 2001 From: seiya <20365512+seiyab@users.noreply.github.com> Date: Fri, 4 Aug 2023 22:13:16 +0900 Subject: [PATCH 5/9] treat YieldExpression --- src/language-js/print/assignment.js | 6 +++++- .../assignment/__snapshots__/jsfmt.spec.js.snap | 17 ++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/language-js/print/assignment.js b/src/language-js/print/assignment.js index 11e2eb5ebb77..005df82c64c2 100644 --- a/src/language-js/print/assignment.js +++ b/src/language-js/print/assignment.js @@ -205,7 +205,11 @@ function shouldBreakAfterOperator(path, options, print, hasShortKey) { let node = rightNode; const propertiesForPath = []; for (;;) { - if (node.type === "UnaryExpression" || node.type === "AwaitExpression") { + if ( + node.type === "UnaryExpression" || + node.type === "AwaitExpression" || + node.type === "YieldExpression" + ) { node = node.argument; propertiesForPath.push("argument"); } else if (node.type === "TSNonNullExpression") { diff --git a/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap b/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap index 7cb5b1b9b340..9fa583a8c933 100644 --- a/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap @@ -322,20 +322,19 @@ async function f() { } function* g() { - const { section, rubric, authors, tags } = yield utils.upsertCommonData( - mainData, - ); + const { section, rubric, authors, tags } = + yield utils.upsertCommonData(mainData); - const loooooooooooooooooooooooooong1 = yield looooooooooooooong - .looooooooooooooong.loooooong; + const loooooooooooooooooooooooooong1 = + yield looooooooooooooong.looooooooooooooong.loooooong; const loooooooooooooooooooooooooong2 = yield looooooooooooooong.looooooooooooooong.loooooong(); const loooooooooooooooooooooooooong3 = yield looooooooooooooooooooooooooooooooooooooooooooog(); - const loooooooooooooooooooooooooong4 = !(yield looooooooooooooong - .looooooooooooooong.loooooong); - const loooooooooooooooooooooooooong5 = void !!(yield looooooooooooooong - .looooooooooooooong.loooooong); + const loooooooooooooooooooooooooong4 = + !(yield looooooooooooooong.looooooooooooooong.loooooong); + const loooooooooooooooooooooooooong5 = + void !!(yield looooooooooooooong.looooooooooooooong.loooooong); } ================================================================================ From 70ae55bc433eacf1a98e85062bdc4603a3639381 Mon Sep 17 00:00:00 2001 From: seiya <20365512+seiyab@users.noreply.github.com> Date: Fri, 4 Aug 2023 22:26:59 +0900 Subject: [PATCH 6/9] add tests --- .../__snapshots__/jsfmt.spec.js.snap | 29 +++++++++++++++++++ .../format/js/assignment/discussion-15196.js | 6 ++++ 2 files changed, 35 insertions(+) diff --git a/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap b/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap index 9fa583a8c933..5c0829564f04 100644 --- a/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap @@ -292,6 +292,9 @@ async function f() { const loooooooooooooooooooooooooong3 = await looooooooooooooooooooooooooooooooooooooooooooog(); const loooooooooooooooooooooooooong4 = !await looooooooooooooong.looooooooooooooong.loooooong; const loooooooooooooooooooooooooong5 = void !!await looooooooooooooong.looooooooooooooong.loooooong; + + const longlonglonglonglonglonglong1 = await new Promise((resolve, reject) => { setTimeout(() => { resolve('foo'); }, 300); }) + const longlonglonglonglonglonglong2 = await { then(onFulfilled, onRejected) { onFulfilled(1234567890) } }; } function* g() { @@ -302,6 +305,9 @@ function* g() { const loooooooooooooooooooooooooong3 = yield looooooooooooooooooooooooooooooooooooooooooooog(); const loooooooooooooooooooooooooong4 = !(yield looooooooooooooong.looooooooooooooong.loooooong); const loooooooooooooooooooooooooong5 = void !!(yield looooooooooooooong.looooooooooooooong.loooooong); + + const longlonglonglonglonglonglong1 = yield qwertyuiop(asdfghjkl, zxcvbnm, qwertyuiop, asdfghjkl); + const longlonglonglonglonglonglong2 = yield { qwertyuiop: 1234567890, asdfghjkl: 1234567890, zxcvbnm: 123456789 }; } =====================================output===================================== @@ -319,6 +325,17 @@ async function f() { !(await looooooooooooooong.looooooooooooooong.loooooong); const loooooooooooooooooooooooooong5 = void !!(await looooooooooooooong.looooooooooooooong.loooooong); + + const longlonglonglonglonglonglong1 = await new Promise((resolve, reject) => { + setTimeout(() => { + resolve("foo"); + }, 300); + }); + const longlonglonglonglonglonglong2 = await { + then(onFulfilled, onRejected) { + onFulfilled(1234567890); + }, + }; } function* g() { @@ -335,6 +352,18 @@ function* g() { !(yield looooooooooooooong.looooooooooooooong.loooooong); const loooooooooooooooooooooooooong5 = void !!(yield looooooooooooooong.looooooooooooooong.loooooong); + + const longlonglonglonglonglonglong1 = yield qwertyuiop( + asdfghjkl, + zxcvbnm, + qwertyuiop, + asdfghjkl, + ); + const longlonglonglonglonglonglong2 = yield { + qwertyuiop: 1234567890, + asdfghjkl: 1234567890, + zxcvbnm: 123456789, + }; } ================================================================================ diff --git a/tests/format/js/assignment/discussion-15196.js b/tests/format/js/assignment/discussion-15196.js index 8579da77aa0c..132c78021b5a 100644 --- a/tests/format/js/assignment/discussion-15196.js +++ b/tests/format/js/assignment/discussion-15196.js @@ -6,6 +6,9 @@ async function f() { const loooooooooooooooooooooooooong3 = await looooooooooooooooooooooooooooooooooooooooooooog(); const loooooooooooooooooooooooooong4 = !await looooooooooooooong.looooooooooooooong.loooooong; const loooooooooooooooooooooooooong5 = void !!await looooooooooooooong.looooooooooooooong.loooooong; + + const longlonglonglonglonglonglong1 = await new Promise((resolve, reject) => { setTimeout(() => { resolve('foo'); }, 300); }) + const longlonglonglonglonglonglong2 = await { then(onFulfilled, onRejected) { onFulfilled(1234567890) } }; } function* g() { @@ -16,4 +19,7 @@ function* g() { const loooooooooooooooooooooooooong3 = yield looooooooooooooooooooooooooooooooooooooooooooog(); const loooooooooooooooooooooooooong4 = !(yield looooooooooooooong.looooooooooooooong.loooooong); const loooooooooooooooooooooooooong5 = void !!(yield looooooooooooooong.looooooooooooooong.loooooong); + + const longlonglonglonglonglonglong1 = yield qwertyuiop(asdfghjkl, zxcvbnm, qwertyuiop, asdfghjkl); + const longlonglonglonglonglonglong2 = yield { qwertyuiop: 1234567890, asdfghjkl: 1234567890, zxcvbnm: 123456789 }; } From 16f94eb9d8a0e3146d83c59c9590ddf3e1599d21 Mon Sep 17 00:00:00 2001 From: seiya <20365512+seiyab@users.noreply.github.com> Date: Fri, 4 Aug 2023 22:40:40 +0900 Subject: [PATCH 7/9] add changelog --- changelog_unreleased/javascript/15204.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 changelog_unreleased/javascript/15204.md diff --git a/changelog_unreleased/javascript/15204.md b/changelog_unreleased/javascript/15204.md new file mode 100644 index 000000000000..b0bd8339e732 --- /dev/null +++ b/changelog_unreleased/javascript/15204.md @@ -0,0 +1,16 @@ +#### Break after `=` of assignment if RHS is poorly breakable AwaitExpression or YieldExpression (#15204 by @seiyab) + + +```js +// Input +const { section, rubric, authors, tags } = await utils.upsertCommonData(mainData); + +// Prettier stable +const { section, rubric, authors, tags } = await utils.upsertCommonData( + mainData, +); + +// Prettier main +const { section, rubric, authors, tags } = + await utils.upsertCommonData(mainData); +``` From 900f47f56614456aecc5270ab2f39b639c6b1bd7 Mon Sep 17 00:00:00 2001 From: seiya <20365512+seiyab@users.noreply.github.com> Date: Fri, 4 Aug 2023 23:01:22 +0900 Subject: [PATCH 8/9] fix a bug --- src/language-js/print/assignment.js | 2 +- tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap | 4 ++++ tests/format/js/assignment/discussion-15196.js | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/language-js/print/assignment.js b/src/language-js/print/assignment.js index 005df82c64c2..b775194889cb 100644 --- a/src/language-js/print/assignment.js +++ b/src/language-js/print/assignment.js @@ -208,7 +208,7 @@ function shouldBreakAfterOperator(path, options, print, hasShortKey) { if ( node.type === "UnaryExpression" || node.type === "AwaitExpression" || - node.type === "YieldExpression" + (node.type === "YieldExpression" && node.argument !== null) ) { node = node.argument; propertiesForPath.push("argument"); diff --git a/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap b/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap index 5c0829564f04..1c4f888825f8 100644 --- a/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap @@ -308,6 +308,8 @@ function* g() { const longlonglonglonglonglonglong1 = yield qwertyuiop(asdfghjkl, zxcvbnm, qwertyuiop, asdfghjkl); const longlonglonglonglonglonglong2 = yield { qwertyuiop: 1234567890, asdfghjkl: 1234567890, zxcvbnm: 123456789 }; + + const x = yield; } =====================================output===================================== @@ -364,6 +366,8 @@ function* g() { asdfghjkl: 1234567890, zxcvbnm: 123456789, }; + + const x = yield; } ================================================================================ diff --git a/tests/format/js/assignment/discussion-15196.js b/tests/format/js/assignment/discussion-15196.js index 132c78021b5a..e511bb329a65 100644 --- a/tests/format/js/assignment/discussion-15196.js +++ b/tests/format/js/assignment/discussion-15196.js @@ -22,4 +22,6 @@ function* g() { const longlonglonglonglonglonglong1 = yield qwertyuiop(asdfghjkl, zxcvbnm, qwertyuiop, asdfghjkl); const longlonglonglonglonglonglong2 = yield { qwertyuiop: 1234567890, asdfghjkl: 1234567890, zxcvbnm: 123456789 }; + + const x = yield; } From 6ac0033c91772b07ff67081fb197eaf915f8b1e2 Mon Sep 17 00:00:00 2001 From: seiya <20365512+seiyab@users.noreply.github.com> Date: Sat, 5 Aug 2023 21:53:21 +0900 Subject: [PATCH 9/9] add test for delegated yield --- tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap | 3 +++ tests/format/js/assignment/discussion-15196.js | 1 + 2 files changed, 4 insertions(+) diff --git a/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap b/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap index 1c4f888825f8..90ce454a1b6b 100644 --- a/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/js/assignment/__snapshots__/jsfmt.spec.js.snap @@ -305,6 +305,7 @@ function* g() { const loooooooooooooooooooooooooong3 = yield looooooooooooooooooooooooooooooooooooooooooooog(); const loooooooooooooooooooooooooong4 = !(yield looooooooooooooong.looooooooooooooong.loooooong); const loooooooooooooooooooooooooong5 = void !!(yield looooooooooooooong.looooooooooooooong.loooooong); + const loooooooooooooooooooooooooong6 = yield* looooooooooooooong.looooooooooooooong.loooooong; const longlonglonglonglonglonglong1 = yield qwertyuiop(asdfghjkl, zxcvbnm, qwertyuiop, asdfghjkl); const longlonglonglonglonglonglong2 = yield { qwertyuiop: 1234567890, asdfghjkl: 1234567890, zxcvbnm: 123456789 }; @@ -354,6 +355,8 @@ function* g() { !(yield looooooooooooooong.looooooooooooooong.loooooong); const loooooooooooooooooooooooooong5 = void !!(yield looooooooooooooong.looooooooooooooong.loooooong); + const loooooooooooooooooooooooooong6 = + yield* looooooooooooooong.looooooooooooooong.loooooong; const longlonglonglonglonglonglong1 = yield qwertyuiop( asdfghjkl, diff --git a/tests/format/js/assignment/discussion-15196.js b/tests/format/js/assignment/discussion-15196.js index e511bb329a65..b6836faaa239 100644 --- a/tests/format/js/assignment/discussion-15196.js +++ b/tests/format/js/assignment/discussion-15196.js @@ -19,6 +19,7 @@ function* g() { const loooooooooooooooooooooooooong3 = yield looooooooooooooooooooooooooooooooooooooooooooog(); const loooooooooooooooooooooooooong4 = !(yield looooooooooooooong.looooooooooooooong.loooooong); const loooooooooooooooooooooooooong5 = void !!(yield looooooooooooooong.looooooooooooooong.loooooong); + const loooooooooooooooooooooooooong6 = yield* looooooooooooooong.looooooooooooooong.loooooong; const longlonglonglonglonglonglong1 = yield qwertyuiop(asdfghjkl, zxcvbnm, qwertyuiop, asdfghjkl); const longlonglonglonglonglonglong2 = yield { qwertyuiop: 1234567890, asdfghjkl: 1234567890, zxcvbnm: 123456789 };