fix(prettier): semi colon after class property (#2387)

This commit is contained in:
Boshen 2024-02-11 19:25:38 +08:00 committed by GitHub
parent 0df7e296f9
commit 871a73afdd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 2 deletions

View file

@ -2000,6 +2000,15 @@ impl<'a> ClassElement<'a> {
}
}
pub fn is_property(&self) -> bool {
matches!(
self,
Self::PropertyDefinition(_)
| Self::AccessorProperty(_)
| Self::TSAbstractPropertyDefinition(_)
)
}
pub fn is_ts_empty_body_function(&self) -> bool {
match self {
Self::PropertyDefinition(_)

View file

@ -35,6 +35,7 @@ pub(super) fn print_class_body<'a>(p: &mut Prettier<'a>, class_body: &ClassBody<
parts_inner.push(node.format(p));
if !p.options.semi
&& node.is_property()
&& should_print_semicolon_after_class_property(node, class_body.body.get(i + 1))
{
parts_inner.push(ss!(";"));

View file

@ -1,4 +1,4 @@
Compatibility: 239/562 (42.53%)
Compatibility: 240/562 (42.70%)
# Failed
@ -107,7 +107,6 @@ Compatibility: 239/562 (42.53%)
* classes/property.js
### classes-private-fields
* classes-private-fields/private_fields.js
* classes-private-fields/with_comments.js
### comments