jsx-uses-react
Disallow React to be incorrectly marked as unused
Next step
jsx-uses-react 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];
Classic-runtime JSX compiles to React.createElement, so a file that imports React for it uses it, though no identifier says so. This rule is part of eslint-plugin-react-features and follows eslint-plugin-react/jsx-uses-react 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 | Projects on the classic JSX runtime, with no-unused-vars on |
Rule Details
The rule never reports. It marks the JSX factory as used, so the core no-unused-vars rule does not flag an import React from 'react' that only JSX needs. The factory is React, the first name of a @jsx Foo.bar pragma comment, or settings.react.pragma; a fragment (<></>) uses settings.react.fragment (default Fragment).
Under the automatic runtime (@jsxRuntime automatic, React 17+) no import is needed and this rule has nothing to do.
Settings
The binding is read from, in order: a @jsx comment, settings.react.pragma, React. settings.react.fragment names the fragment binding.
// eslint.config.js
export default [
{
plugins: { react: reactFeatures },
settings: { react: { pragma: 'h', fragment: 'Fragment' } },
rules: { 'react/jsx-uses-react': 'error', 'no-unused-vars': 'error' },
},
];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-uses-react': 'error' }, },];npm install -D oxlint-plugin-react-features{ "jsPlugins": ["oxlint-plugin-react-features"], "rules": { "react-features/jsx-uses-react": "error" }}import { defineConfig } from 'vite-plus';export default defineConfig({ lint: { jsPlugins: ['oxlint-plugin-react-features'], rules: { 'react-features/jsx-uses-react': '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.