perf(plugin): early-exit sweep — cheap discriminators before expensive walks - #1047
Merged
Conversation
…e walks Reorders ~23 rules/utils so trivial name/type/substring checks run before subtree walks, scope traces, parent climbs, and settings parses; adds whole-file no-op gates (zod import gate, recycler-package import gate, JSX-presence gate for rn-no-raw-text, crypto-token gate for insecure-crypto-risk) and prunes containsFetchCall after the first match. Findings #6 #11 #18 #19 #42 #56 #100 #121 #129 #193 #205 #206 #217 #236-#238 #259 #299 #308 #327 #385-#387 #428 from the perf audit catalog; behavior verified identical via the 291-diagnostic equivalence corpus. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The multi-agent perf audit's largest cross-cutting theme: ~24 rules ran subtree walks, scope traces, parent climbs, or settings parses before a trivial name/type/substring check that usually fails. This sweep reorders them and adds whole-file no-op gates where a Program-level fact (no zod import, no recycler-list import, no JSX) makes the rule inert. Findings: #6 #11 #18 #19 #42 #56 #100 #121 #129 #193 #205 #206 #217 #236 #237 #238 #259 #299 #308(partial) #327 #385 #386 #387 #428.
Before / After: pure predicate reorders and gates — the reported diagnostic set is provably unchanged (every gate is an ANDed condition of the existing report path).
What changed
getElementType/generated-image climbs (alt-text, anchor-is-valid, img-redundant-alt, interactive-supports-focus, role-supports-aria-props) via a newhas-jsx-a11y-settingsutil (safe: without settings the alias sets are empty)."zod"import (the detectors cannot fire without one — verified), react-native list rules on recycler package imports, rn-no-raw-text on JSX presence, nextjs-no-side-effect-in-get-handler on filename at Program.charCodeAtuppercase check + hoisted Set (no-unstable-nested-components), first-match early exits (containsFetchCall, is-create-element-call).Test plan
Note: touches
interactive-supports-focus.tsandrn-no-raw-text.ts, which the set-membership sweep PR also touches — whichever merges second needs a trivial rebase.🤖 Generated with Claude Code
Note
Low Risk
Changes are predicate reordering and conservative skip gates only; PR claims byte-identical corpus diagnostics, so behavioral risk is low aside from any missed edge case in gate logic.
Overview
Performance-only refactor across ~23 oxlint rules: cheap checks and whole-file gates run before AST walks, scope lookups, settings parsing, and regex-heavy
classNamework. Reported diagnostics are intended to stay identical (gates are conservative AND conditions on existing report paths).Whole-file gates at
Program: Zod v4 rules skip files without a"zod"import; FlashList/LegendList rules skip without recycler package imports (RECYCLABLE_LIST_PACKAGE_SOURCES);rn-no-raw-textskips wrapper classification when the file has no JSX;nextjs-no-side-effect-in-get-handlerhoists route filename checks once per file.a11y: New
hasJsxA11ySettingsletsalt-textandanchor-is-validbail on raw JSX tag names beforegetElementType. Other a11y rules reorder checks (e.g.role-supports-aria-propscollectsaria-*first;interactive-supports-focusrequiresrole+ handlers earlier).Misc: Tailwind design rules add substring guards before regex;
insecure-crypto-riskpre-filters raw content;containsFetchCallandis-create-element-callstop after first match; assorted predicate reordering (no-render-in-render,js-hoist-intl,prefer-stable-empty-fallback,no-unstable-nested-components,server-cache-with-object-literal,no-create-context-in-renderimport helpers).Reviewed by Cursor Bugbot for commit 4f82a61. Bugbot is set up for automated code reviews on this repo. Configure here.