feat(prettier): print big int with lowercase (#1351)

This commit is contained in:
Boshen 2023-11-16 19:04:12 +08:00 committed by GitHub
parent 526db66984
commit bc302f4f8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

@ -613,7 +613,13 @@ impl<'a> Format<'a> for NumberLiteral<'a> {
impl<'a> Format<'a> for BigintLiteral {
fn format(&self, p: &mut Prettier<'a>) -> Doc<'a> {
Doc::Str(self.span.source_text(p.source_text))
let text = self.span.source_text(p.source_text);
// Perf: avoid a memory allocation from `to_ascii_lowercase`.
if text.contains(|c: char| c.is_lowercase()) {
p.str(&text.to_ascii_lowercase())
} else {
Doc::Str(text)
}
}
}

View file

@ -1,4 +1,4 @@
Compatibility: 8/173 (4.62%)
Compatibility: 9/173 (5.20%)
# Failed
@ -13,7 +13,6 @@ Compatibility: 8/173 (4.62%)
* async
* async-do-expressions
* babel-plugins
* big-int
* binary-expressions
* binary_math
* bind-expressions