From a0973dcb5af2597fdce608a635b0e61653447ca3 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Thu, 5 Dec 2024 04:23:14 +0000 Subject: [PATCH] refactor(linter): use `BigIntLiteral::raw` field (#7660) No need to slice source text to get raw value of `BigIntLiteral`. It already has a `raw` field. --- .../src/rules/unicorn/numeric_separators_style.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/oxc_linter/src/rules/unicorn/numeric_separators_style.rs b/crates/oxc_linter/src/rules/unicorn/numeric_separators_style.rs index 19a2fc157..48b8f2701 100644 --- a/crates/oxc_linter/src/rules/unicorn/numeric_separators_style.rs +++ b/crates/oxc_linter/src/rules/unicorn/numeric_separators_style.rs @@ -101,13 +101,11 @@ impl Rule for NumericSeparatorsStyle { } } AstKind::BigIntLiteral(number) => { - let raw = number.span.source_text(ctx.source_text()); - - if self.only_if_contains_separator && !raw.contains('_') { + if self.only_if_contains_separator && !number.raw.contains('_') { return; } - let formatted = self.format_bigint(number, raw); + let formatted = self.format_bigint(number, &number.raw); if formatted.len() != number.span.size() as usize { ctx.diagnostic_with_fix(