feat(prettier) Print labeled statement (#1393)

This commit is contained in:
Cameron 2023-11-18 01:36:28 +00:00 committed by GitHub
parent ecbe0a4b98
commit db71974655
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View file

@ -355,7 +355,11 @@ impl<'a> Format<'a> for ReturnStatement<'a> {
impl<'a> Format<'a> for LabeledStatement<'a> {
fn format(&self, p: &mut Prettier<'a>) -> Doc<'a> {
Doc::Line
if matches!(self.body, Statement::EmptyStatement(_)) {
return array!(p, self.label.format(p), ss!(":;"));
}
array!(p, self.label.format(p), ss!(": "), format!(p, self.body))
}
}

View file

@ -1,4 +1,4 @@
Compatibility: 63/881 (7.15%)
Compatibility: 66/881 (7.49%)
# Failed
@ -653,9 +653,7 @@ Compatibility: 63/881 (7.15%)
* import-reflection/valid-module-as-default-binding.mjs
### label
* label/block-statement-and-regexp.js
* label/comment.js
* label/empty_label.js
### last-argument-expansion
* last-argument-expansion/arrow.js
@ -981,9 +979,6 @@ Compatibility: 63/881 (7.15%)
* shebang/shebang-newline.js
* shebang/shebang.js
### sloppy-mode
* sloppy-mode/labeled-function-declaration.js
### source-phase-imports
* source-phase-imports/default-binding.js
* source-phase-imports/import-source-attributes-declaration.js