jsx-no-undef
Disallow undeclared variables in JSX
Next step
jsx-no-undef ships in eslint-plugin-react-features, with 11 of its 65 rules in the recommended preset.
npm install -D eslint-plugin-react-featuresimport { configs } from 'eslint-plugin-react-features';
export default [configs.recommended];
A JSX tag that names no binding is a ReferenceError at render time. This rule is part of eslint-plugin-react-features and follows eslint-plugin-react/jsx-no-undef in behaviour and options.
Quick Summary
| Aspect | Details |
|---|---|
| Severity | Error (correctness) |
| Auto-Fix | ❌ No auto-fix |
| Category | React |
| ESLint MCP | ✅ Optimized for ESLint MCP integration |
| Best For | All React/JSX projects |
Rule Details
<Foo /> compiles to a reference to Foo. When no import, declaration or configured global provides it, the page throws when it renders. The rule reports the tag (or, for <Foo.Bar />, the leftmost name) when nothing in scope declares it. Intrinsic elements (<div />) and namespaced tags (<svg:circle />) name no binding and are skipped.
Examples
❌ Incorrect
<Foo />
<Foo.Bar />✅ Correct
import Foo from './Foo';
<Foo />
<div />Options
| Option | Type | Default | Description |
|---|---|---|---|
allowGlobals | boolean | false | In a module, count a configured global (languageOptions.globals) as declared; by default only the module's own bindings count |
Use this rule
npm install -D eslint-plugin-react-featuresimport reactFeatures from 'eslint-plugin-react-features';export default [ { plugins: { 'react-features': reactFeatures }, rules: { 'react-features/jsx-no-undef': 'error' }, },];npm install -D oxlint-plugin-react-features{ "jsPlugins": ["oxlint-plugin-react-features"], "rules": { "react-features/jsx-no-undef": "error" }}import { defineConfig } from 'vite-plus';export default defineConfig({ lint: { jsPlugins: ['oxlint-plugin-react-features'], rules: { 'react-features/jsx-no-undef': 'error', }, },});oxlint-plugin-react-features re-exports eslint-plugin-react-features/oxlint: the same rules under the same IDs, and no ESLint install. Why oxlint.
Did this rule catch something? Star the repo to get new CWE coverage as we ship it — or follow the AI-code-security benchmarks behind these rules.