Port oxc react rules to TS and replace builtin usage
Summary
Ports the rules from oxc's bundled react plugin (Rust) into our oxlint JS plugin (TypeScript), and replaces our usage of the upstream defaults with these new local rules.
The 11 simpler rules in BUILTIN_REACT_RULES are now sourced from oxlint-plugin-react-doctor. react/rules-of-hooks stays as the upstream rule because it relies on full CFG analysis that we don't reproduce here — but a lexical / structural port (react-rules-of-hooks) is added alongside to catch the common violations.
Ported rules
Each rule lands under packages/oxlint-plugin-react-doctor/src/plugin/rules/<bucket>/react-*.ts and has an e2e test under packages/react-doctor/tests/regressions/react-rules/ whose pass / fail vectors mirror the corresponding oxc Rust unit test in oxc/crates/oxc_linter/src/rules/react/.
Correctness (correctness/):
react-no-children-prop— flags thechildren=...prop and the equivalentReact.createElementshape.react-jsx-no-duplicate-props— flags identically-named props on the same JSX element (case-sensitive, matching oxc).react-no-render-return-value— flagsvar x = ReactDOM.render(...)/return ReactDOM.render(...)/ arrow-expression body.react-no-is-mounted— flagsthis.isMounted()inside a class method orcreateReactClassproperty.react-no-string-refs— flags<div ref="..." />,ref={'...'}, andthis.refs.xreads inside a component body.react-no-direct-mutation-state— flagsthis.state.foo = .../this.state.foo++outside the constructor of a React class component.react-require-render-return— flags an emptyrender()body on an ES6 class component orcreateReactClassobject property (structural approximation of oxc's CFG-based check).react-jsx-key— flags missingkeyon JSX in.map/.flatMap/Array.from/ array literals, pluskey-after-{...spread}and duplicate sibling keys. ExemptsReact.Children.toArray(...)/Children.toArray(...).react-no-unknown-property— flagsclass/for/ kebab-cased SVG attributes / etc., plus invalid prop-on-tag combinations (crossOriginon<div>). Ports the three lookup tables (ATTRIBUTE_TAGS_MAP,DOM_PROPERTIES_NAMES,DOM_ATTRIBUTES_TO_CAMEL) verbatim from oxc's Rust source.react-rules-of-hooks— structural port that catches the common lexical violations (hooks called from non-component / non-hook functions, hooks called inside conditionals / loops / try-catch, hooks called in async functions). Misses CFG-only patterns (early-return after hook, deep callback nesting);react/rules-of-hooksfromreact-hooksstays enabled to cover those.
Security (security/):
react-no-danger— flagsdangerouslySetInnerHTMLon JSX orReact.createElementprops (XSS-shaped).react-jsx-no-script-url— flags<a href="javascript:..." />(case-insensitive, with whitespace tolerance to match oxc's regex). The optionalcomponentsconfig is omitted; bare<a>covers the vast majority of attack surface.
Replacing the builtin usage
packages/core/src/runners/oxlint/external-plugin-rules.ts:
BUILTIN_REACT_RULESshrinks from 12 entries to 1 (react/rules-of-hooksonly).- Inline note explains where the other 11 went and why
rules-of-hooksstays.
packages/core/src/runners/oxlint/config.ts:
- No structural changes — the
["react", "jsx-a11y"]plugin list and theBUILTIN_REACT_RULESspread stay so thatreact/rules-of-hookskeeps activating. Our 11 ported rules pick themselves up via the existing registry-driven loop (each new file lives in a bucket already wired intogenerate-rule-registry.mjs).
Notes / known gaps
- oxc supports a few options on these rules (
requireDataLowercase, thecomponentslist onjsx-no-script-url, etc.) that the JS plugin layer here doesn't thread through. The defaults match oxc's "no options" behavior. - The
aria-*validation inreact-no-unknown-propertyuses a permissivearia-<word>regex instead of oxc's curated globals list (avoids duplicating ~120 attribute names with marginal value). react-rules-of-hooksis intentionally a subset of upstream behavior; pairs with the existingreact-hooks-js/*(React Compiler frontend) andreact/rules-of-hooksfor full coverage.
Verification
pnpm typecheck— all 10 tasks pass.pnpm test— 95 test files / 946 tests pass. The 12 new test files (one per ported rule) are included.pnpm lint— 0 warnings, 0 errors.pnpm format:check— clean.
🔴 React Review — 0/100 (unchanged) · No new issues
Reviewed by react-review for commit 81f68972a84dda5052b1f5346a15bb05d6f8a80e. Configure here.
The latest updates on your projects. Learn more about Vercel for GitHub.
| Project | Deployment | Actions | Updated (UTC) |
|---|---|---|---|
| react-doctor-website | Preview, Comment | May 16, 2026 8:03am |

