diff --git a/crates/oxc_transformer/src/utils.rs b/crates/oxc_transformer/src/utils.rs index d04458b70..0d700ec26 100644 --- a/crates/oxc_transformer/src/utils.rs +++ b/crates/oxc_transformer/src/utils.rs @@ -3,7 +3,7 @@ use std::mem; use oxc_allocator::Vec; use oxc_ast::ast::*; use oxc_span::{Atom, Span}; -use oxc_syntax::unicode_id_start::{is_id_continue, is_id_start}; +use oxc_syntax::identifier::is_identifier_name; use crate::context::TransformerCtx; @@ -129,26 +129,6 @@ pub const KEYWORDS: phf::Set<&str> = phf::phf_set![ "delete", ]; -/// https://github.com/babel/babel/blob/ff3481746a830e0e94626de4c4cb075ea5f2f5dc/packages/babel-helper-validator-identifier/src/identifier.ts#L85-L109 -pub fn is_identifier_name(name: &Atom) -> bool { - let string = name.as_str(); - if string.is_empty() { - return false; - } - let mut is_first = true; - for ch in string.chars() { - if is_first { - is_first = false; - if !is_id_start(ch) { - return false; - } - } else if !is_id_continue(ch) { - return false; - } - } - true -} - pub fn is_valid_identifier(name: &Atom, reserved: bool) -> bool { if reserved && (KEYWORDS.contains(name.as_str()) || is_strict_reserved_word(name, true)) { return false;