Description
Running npx react-doctor@latest . crashes with:
Lint did not run: Failed to run oxlint: TypeError: Cannot read properties of undefined (reading 'match')
at parseRuleCode (file:///.../node_modules/react-doctor/dist/record-metric-CJxSHfJD.js:75822:21)
at file:///.../node_modules/react-doctor/dist/record-metric-CJxSHfJD.js:75926:28
at Array.flatMap ()
at parseOxlintOutput (file:///.../node_modules/react-doctor/dist/record-metric-CJxSHfJD.js:75923:68)
at spawnLintBatch (file:///.../node_modules/react-doctor/dist/record-metric-CJxSHfJD.js:76206:12)
Root Cause
The error occurs at parseRuleCode in the bundled oxlint output parser:
const parseRuleCode = (code) => {
const match = code.match(/^(.+)\((.+)\)$/); // ← crashes when code is undefined
if (!match) return { plugin: "unknown", rule: code };
return { plugin: match[1].replace(/^eslint-plugin-/, ""), rule: match[2] };
};
Some oxlint diagnostics don't include a code field, so diagnostic.code is undefined. When parseRuleCode(undefined) is called, .match() throws.
Fix
Add a null check before calling .match():
const parseRuleCode = (code) => {
if (!code) return { plugin: "unknown", rule: "unknown" };
const match = code.match(/^(.+)\((.+)\)$/);
// ...
};
Environment
- react-doctor: 0.9.11
- Node.js: v24.15.0
- OS: macOS (Darwin)
- Project: Astro SSR + React islands (TypeScript 6.0.3)
- Command: npx react-doctor@latest . --verbose --diff
Description
Running
npx react-doctor@latest .crashes with:Lint did not run: Failed to run oxlint: TypeError: Cannot read properties of undefined (reading 'match')
at parseRuleCode (file:///.../node_modules/react-doctor/dist/record-metric-CJxSHfJD.js:75822:21)
at file:///.../node_modules/react-doctor/dist/record-metric-CJxSHfJD.js:75926:28
at Array.flatMap ()
at parseOxlintOutput (file:///.../node_modules/react-doctor/dist/record-metric-CJxSHfJD.js:75923:68)
at spawnLintBatch (file:///.../node_modules/react-doctor/dist/record-metric-CJxSHfJD.js:76206:12)
Root Cause
The error occurs at
parseRuleCodein the bundled oxlint output parser:Some oxlint diagnostics don't include a code field, so diagnostic.code is undefined. When parseRuleCode(undefined) is called, .match() throws.
Fix
Add a null check before calling .match():
Environment