// Custom oxlint JS plugin (oxlint's alpha plugin API — ESLint-compatible
// visitor + context.report shape). Live-tested against oxlint 1.73.0.
// Rule: no-unnecessary-react-import
// React 19's automatic JSX runtime never needs `import React from 'react'`
// unless the file actually references the `React` namespace (React.useRef,
// React.FC, etc). Flags the import when it does not.
meta: { name: 'local-react' },
'no-unnecessary-react-import': {
let reactImportNode = null;
let usesReactNamespace = false;
ImportDeclaration(node) {
if (node.source.value !== 'react') return;
const defaultSpec = node.specifiers.find(
(s) => s.type === 'ImportDefaultSpecifier' || s.type === 'ImportNamespaceSpecifier'
if (defaultSpec && defaultSpec.local.name === 'React') {
if (node.object.type === 'Identifier' && node.object.name === 'React') {
usesReactNamespace = true;
if (reactImportNode && !usesReactNamespace) {
"Unnecessary default import of React — React 19's automatic JSX runtime doesn't need it unless you reference React.* somewhere in this file.",