Skip to main content
interlace
Plugin: react-featuresRules

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.

Install
npm install -D eslint-plugin-react-features
eslint.config.js
import { configs } from 'eslint-plugin-react-features';

export default [configs.recommended];

Plugin pagenpmSource on GitHub

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

AspectDetails
SeverityError (correctness)
Auto-Fix❌ No auto-fix
CategoryReact
ESLint MCP✅ Optimized for ESLint MCP integration
Best ForAll 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

OptionTypeDefaultDescription
allowGlobalsbooleanfalseIn 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-features
eslint.config.js
import 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
.oxlintrc.json
{  "jsPlugins": ["oxlint-plugin-react-features"],  "rules": {    "react-features/jsx-no-undef": "error"  }}
vite.config.ts
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.