Skip to content

Commit 3dfa876

Browse files
committedApr 6, 2025·
perf(linter): replace phf_set with array in eslint/no-import-assign (#10271)
Related to #10076
1 parent 4932495 commit 3dfa876

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed
 

‎crates/oxc_linter/src/rules/eslint/no_import_assign.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use oxc_macros::declare_oxc_lint;
44
use oxc_semantic::{NodeId, SymbolId};
55
use oxc_span::{GetSpan, Span};
66
use oxc_syntax::operator::UnaryOperator;
7-
use phf::phf_set;
87

98
use crate::{context::LintContext, rule::Rule};
109

@@ -44,11 +43,11 @@ declare_oxc_lint!(
4443
correctness
4544
);
4645

47-
const OBJECT_MUTATION_METHODS: phf::Set<&'static str> =
48-
phf_set!("assign", "defineProperty", "defineProperties", "freeze", "setPrototypeOf");
46+
const OBJECT_MUTATION_METHODS: [&str; 5] =
47+
["assign", "defineProperty", "defineProperties", "freeze", "setPrototypeOf"];
4948

50-
const REFLECT_MUTATION_METHODS: phf::Set<&'static str> =
51-
phf_set!("defineProperty", "deleteProperty", "set", "setPrototypeOf");
49+
const REFLECT_MUTATION_METHODS: [&str; 4] =
50+
["defineProperty", "deleteProperty", "set", "setPrototypeOf"];
5251

5352
impl Rule for NoImportAssign {
5453
fn run_on_symbol(&self, symbol_id: SymbolId, ctx: &LintContext<'_>) {
@@ -125,8 +124,8 @@ fn is_argument_of_well_known_mutation_function(node_id: NodeId, ctx: &LintContex
125124
return false;
126125
};
127126

128-
if ((ident.name == "Object" && OBJECT_MUTATION_METHODS.contains(property_name))
129-
|| (ident.name == "Reflect" && REFLECT_MUTATION_METHODS.contains(property_name)))
127+
if ((ident.name == "Object" && OBJECT_MUTATION_METHODS.contains(&property_name))
128+
|| (ident.name == "Reflect" && REFLECT_MUTATION_METHODS.contains(&property_name)))
130129
&& !ctx.scoping().has_binding(ident.reference_id())
131130
{
132131
return expr

0 commit comments

Comments
 (0)
Please sign in to comment.