feat(prettier): print es5 comma for object expression (#1574)

This commit is contained in:
Boshen 2023-11-29 13:36:28 +08:00 committed by GitHub
parent c5b138f006
commit a9f0206805
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 4 deletions

View file

@ -100,7 +100,9 @@ pub(super) fn print_object_properties<'a>(
}
indent_parts
}));
parts.push(if_break!(p, ",", "", None));
if p.should_print_es5_comma() {
parts.push(if_break!(p, ",", "", None));
}
parts.push(if p.options.bracket_spacing { line!() } else { softline!() });
parts.push(ss!("}"));

View file

@ -121,7 +121,7 @@ impl<'a> Prettier<'a> {
unsafe { std::mem::transmute(t) }
}
fn should_print_es5_comma(&self) -> bool {
pub fn should_print_es5_comma(&self) -> bool {
self.should_print_comma_impl(false)
}

View file

@ -1,4 +1,4 @@
Compatibility: 193/580 (33.28%)
Compatibility: 194/580 (33.45%)
# Failed
@ -550,7 +550,6 @@ Compatibility: 193/580 (33.28%)
* trailing-comma/es5.js
* trailing-comma/function-calls.js
* trailing-comma/jsx.js
* trailing-comma/object.js
* trailing-comma/trailing_whitespace.js
### try