From 07b7a29f514e691dbf4fac807406c55a68c9d4df Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Thu, 20 Aug 2026 18:54:58 +0800 Subject: [PATCH] Add test for comments in parameter/argument list (#19898) --- tests/format/js/comments/in-list/14723.js | 10 +++ tests/format/js/comments/in-list/9678.js | 16 +++++ .../in-list/__snapshots__/format.test.js.snap | 72 +++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 tests/format/js/comments/in-list/14723.js create mode 100644 tests/format/js/comments/in-list/9678.js diff --git a/tests/format/js/comments/in-list/14723.js b/tests/format/js/comments/in-list/14723.js new file mode 100644 index 000000000..9c4dbea68 --- /dev/null +++ b/tests/format/js/comments/in-list/14723.js @@ -0,0 +1,10 @@ +function doSomething(first, second) { + combineLatest([ + first.watchIt().pipe( + // tap(x => console.log(x)) + ), + second.watchIt().pipe( + tap((x) => console.log(x)) + ), + ]) +} diff --git a/tests/format/js/comments/in-list/9678.js b/tests/format/js/comments/in-list/9678.js new file mode 100644 index 000000000..6a65f3ed8 --- /dev/null +++ b/tests/format/js/comments/in-list/9678.js @@ -0,0 +1,16 @@ +class C11 { + constructor( + //a + //b + ){} + + method( + //a + //b + ){} + + get getter( + //a + //b + ){} +} diff --git a/tests/format/js/comments/in-list/__snapshots__/format.test.js.snap b/tests/format/js/comments/in-list/__snapshots__/format.test.js.snap index ddad5515d..4d231f67c 100644 --- a/tests/format/js/comments/in-list/__snapshots__/format.test.js.snap +++ b/tests/format/js/comments/in-list/__snapshots__/format.test.js.snap @@ -1,5 +1,77 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing +exports[`9678.js format 1`] = ` +====================================options===================================== +parsers: ["babel", "flow", "typescript"] + printWidth: 80 (default) | +=====================================input====================================== +class C11 { + constructor( + //a + //b + ){} + + method( + //a + //b + ){} + + get getter( + //a + //b + ){} +} + +=====================================output===================================== +class C11 { + constructor( + //a + //b + ) {} + + method( + //a + //b + ) {} + + get getter( + //a + //b + ) {} +} + +================================================================================ +`; + +exports[`14723.js format 1`] = ` +====================================options===================================== +parsers: ["babel", "flow", "typescript"] + printWidth: 80 (default) | +=====================================input====================================== +function doSomething(first, second) { + combineLatest([ + first.watchIt().pipe( + // tap(x => console.log(x)) + ), + second.watchIt().pipe( + tap((x) => console.log(x)) + ), + ]) +} + +=====================================output===================================== +function doSomething(first, second) { + combineLatest([ + first.watchIt().pipe( + // tap(x => console.log(x)) + ), + second.watchIt().pipe(tap((x) => console.log(x))), + ]); +} + +================================================================================ +`; + exports[`dangling-comment-in-list.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"]