perf(linter/eslint/no-iterator): narrow member dispatch (#28363)

Exclude private-field expressions, whose static property names cannot
match. Reduce fixture callbacks from 95,297 to 94,090.


---

<sub>Stack created with <a
href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a
href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Cam McHenryandCopilot authored and GitHub committed 2026-10-28 22:28:49 -04:00
1 parent bc5e94d391
commit a777fa6552
3 files changed
+7 -4

No files matched your search

-1
View File
@@ -794,7 +794,6 @@ impl RuleRunner for crate::rules::eslint::no_irregular_whitespace::NoIrregularWh
impl RuleRunner for crate::rules::eslint::no_iterator::NoIterator {
const NODE_TYPES: Option<&AstTypesBitset> = Some(&AstTypesBitset::from_types(&[
AstType::ComputedMemberExpression,
AstType::PrivateFieldExpression,
AstType::StaticMemberExpression,
]));
const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run;
@@ -1,3 +1,4 @@
use oxc_ast::{AstKind, MemberExpressionKind};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
@@ -63,8 +64,10 @@ declare_oxc_lint!(
impl Rule for NoIterator {
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
let Some(member_expression) = node.kind().as_member_expression_kind() else {
return;
let member_expression = match node.kind() {
AstKind::StaticMemberExpression(expr) => MemberExpressionKind::Static(expr),
AstKind::ComputedMemberExpression(expr) => MemberExpressionKind::Computed(expr),
_ => return,
};
if let Some(static_property_name) = member_expression.static_property_name()
&& static_property_name == "__iterator__"
@@ -87,6 +90,7 @@ fn test() {
"var __iterator__ = null;",
"foo[`__iterator`] = null;",
"foo[`__iterator__\n`] = null;",
"class C { #__iterator__; read() { return this.#__iterator__; } }",
];
let fail = vec![
@@ -80,7 +80,7 @@ eslint/no-inline-comments | 7
eslint/no-inner-declarations | 45646
eslint/no-invalid-regexp | 64027
eslint/no-irregular-whitespace | 63961
eslint/no-iterator | 95297
eslint/no-iterator | 94090
eslint/no-label-var | 5
eslint/no-labels | 841
eslint/no-lone-blocks | 14946