File tree Expand file tree Collapse file tree 4 files changed +64
-9
lines changed
tasks/prettier_conformance/snapshots Expand file tree Collapse file tree 4 files changed +64
-9
lines changed Original file line number Diff line number Diff line change @@ -121,13 +121,7 @@ impl<'a> FormatWrite<'a> for AstNode<'a, MethodDefinition<'a>> {
121121 ) ?;
122122
123123 if let Some ( body) = & value. body ( ) {
124- // Handle block comments between method signature and body
125- // Example: method() /* comment */ {}
126- let comments = f. context ( ) . comments ( ) . comments_before ( body. span . start ) ;
127- if !comments. is_empty ( ) {
128- write ! ( f, [ space( ) , FormatTrailingComments :: Comments ( comments) ] ) ?;
129- }
130- write ! ( f, [ space( ) , body] ) ?;
124+ write ! ( f, body) ?;
131125 }
132126 if self . r#type ( ) . is_abstract ( )
133127 || matches ! ( value. r#type, FunctionType :: TSEmptyBodyFunctionExpression )
@@ -641,7 +635,7 @@ pub fn format_grouped_parameters_with_return_type<'a>(
641635 group ( & format_once ( |f| {
642636 let mut format_type_parameters = type_parameters. memoized ( ) ;
643637 let mut format_parameters = params. memoized ( ) ;
644- let mut format_return_type = return_type. memoized ( ) ;
638+ let mut format_return_type = return_type. map ( FormatNodeWithoutTrailingComments ) . memoized ( ) ;
645639
646640 // Inspect early, in case the `return_type` is formatted before `parameters`
647641 // in `should_group_function_parameters`.
Original file line number Diff line number Diff line change 1+ class A {
2+ m1 ( element : Element , key : string , undefined : undefined ) /* block comment */ {
3+ // method body
4+ }
5+ m2 ( element : Element , key : string , undefined : undefined ) : void /* block comment */ {
6+ // method body
7+ }
8+ m3 ( tagName : string , rect : number [ ] ) : void // line comment
9+ {
10+ // method body
11+ }
12+ m4 ( tagName : string , rect : number [ ] ) // line comment
13+ {
14+ // method body
15+ }
16+ }
Original file line number Diff line number Diff line change 1+ -- -
2+ source : crates / oxc_formatter / tests / fixtures / mod .rs
3+ -- -
4+ ==================== Input ====================
5+ class A {
6+ m1(element : Element , key : string , undefined : undefined ) /* block comment */ {
7+ // method body
8+ }
9+ m2(element : Element , key : string , undefined : undefined ): void /* block comment */ {
10+ // method body
11+ }
12+ m3(tagName : string , rect : number []): void // line comment
13+ {
14+ // method body
15+ }
16+ m4(tagName : string , rect : number []) // line comment
17+ {
18+ // method body
19+ }
20+ }
21+
22+ ==================== Output ====================
23+ class A {
24+ m1(element : Element , key : string , undefined : undefined ) /* block comment */ {
25+ // method body
26+ }
27+ m2(
28+ element : Element ,
29+ key : string ,
30+ undefined : undefined ,
31+ ): void /* block comment */ {
32+ // method body
33+ }
34+ m3(tagName : string , rect : number []): void {
35+ // line comment
36+ // method body
37+ }
38+ m4(tagName : string , rect : number []) {
39+ // line comment
40+ // method body
41+ }
42+ }
43+
44+ ===================== End =====================
Original file line number Diff line number Diff line change 1- js compatibility: 662 /699 (94.71 %)
1+ js compatibility: 661 /699 (94.56 %)
22
33# Failed
44
55| Spec path | Failed or Passed | Match ratio |
66| :-------- | :--------------: | :---------: |
7+ | js/class-comment/misc.js | 💥 | 72.73% |
78| js/comments/15661.js | 💥💥 | 55.17% |
89| js/comments/empty-statements.js | 💥💥 | 90.91% |
910| js/comments/function-declaration.js | 💥💥 | 92.80% |
You can’t perform that action at this time.
0 commit comments