mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
feat(prettier): print inner comment in PropertyKey (#1479)
This commit is contained in:
parent
4dbe17c33a
commit
c762a85fcc
4 changed files with 10 additions and 6 deletions
|
|
@ -58,6 +58,7 @@ impl<'a> Prettier<'a> {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
parts
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ fn print_call_expression_arguments<'a>(
|
|||
let arguments = expression.arguments();
|
||||
let should_break = !is_commons_js_or_amd_call(expression.callee(), arguments);
|
||||
|
||||
if arguments.len() == 0 {
|
||||
if arguments.is_empty() {
|
||||
parts.extend(p.print_inner_comment(Span::new(callee.span().end, expression.span().end)));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ use std::borrow::Cow;
|
|||
|
||||
use oxc_allocator::{Box, Vec};
|
||||
use oxc_ast::{ast::*, AstKind};
|
||||
use oxc_span::GetSpan;
|
||||
use oxc_span::{GetSpan, Span};
|
||||
|
||||
use crate::{
|
||||
array,
|
||||
|
|
@ -1422,6 +1422,12 @@ impl<'a> Format<'a> for ObjectProperty<'a> {
|
|||
}
|
||||
} else {
|
||||
parts.push(format!(p, self.key));
|
||||
let comments =
|
||||
p.print_inner_comment(Span::new(self.key.span().end, self.value.span().start));
|
||||
if !comments.is_empty() {
|
||||
parts.push(ss!(" "));
|
||||
parts.extend(comments);
|
||||
}
|
||||
parts.push(ss!(": "));
|
||||
parts.push(format!(p, self.value));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
Compatibility: 133/601 (22.13%)
|
||||
Compatibility: 134/601 (22.30%)
|
||||
|
||||
# Failed
|
||||
|
||||
|
|
@ -484,9 +484,6 @@ Compatibility: 133/601 (22.13%)
|
|||
* object-prop-break-in/short-keys.js
|
||||
* object-prop-break-in/test.js
|
||||
|
||||
### object-property-comment
|
||||
* object-property-comment/after-key.js
|
||||
|
||||
### object-property-ignore
|
||||
* object-property-ignore/ignore.js
|
||||
* object-property-ignore/issue-5678.js
|
||||
|
|
|
|||
Loading…
Reference in a new issue