Registry / testing / eslint-plugin-react-x

eslint-plugin-react-x

JSON →
library4.2.3jsnpmunverified

A composable ESLint plugin for React libraries and frameworks, provided as part of the @eslint-react monorepo. Current stable version is 4.2.3, with active development on v5 beta releases (latest beta v5.5.1-beta.0). Requires Node >=22.0.0, ESLint ^10.0.0, and TypeScript as a peer dependency. Ships TypeScript types. Differentiators: covers modern React patterns (hooks, custom hooks, JSX), provides extensive rule set including new rules like `static-components` and `globals`, and aims to be a drop-in replacement for `eslint-plugin-react` with additional composability.

npm install eslint-plugin-react-x
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-REAC
E
eslint-plugin-react-x
testingjavascriptv4.2.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import eslintPluginReactX from 'eslint-plugin-react-x'
const eslintPluginReactX = require('eslint-plugin-react-x')
ESM-only; CJS require is not supported. Use dynamic import if needed.
rules
import { rules } from 'eslint-plugin-react-x'
const { rules } = require('eslint-plugin-react-x')
Named export available; recommended for selective rule access in configs.
configs
import { configs } from 'eslint-plugin-react-x'
const configs = require('eslint-plugin-react-x').configs
Configs include 'recommended', 'all', and framework-specific presets.
TSType
import type { TSType } from 'eslint-plugin-react-x'
import { TSType } from 'eslint-plugin-react-x'
Type-only export; should be imported with `import type` to avoid runtime issues in TypeScript projects.
RuleContext
import { RuleContext } from 'eslint-plugin-react-x'
import type { RuleContext } from 'eslint-plugin-react-x'
RuleContext is a type but also exported as a value for runtime checks in custom rules. Use `import type` only if purely for type usage.

Flat ESLint config using eslint-plugin-react-x with recommended rules and react-hooks plugin.

// eslint.config.js import eslintPluginReactX from 'eslint-plugin-react-x'; import eslintPluginReactHooks from 'eslint-plugin-react-hooks'; export default [ { files: ['**/*.{ts,tsx}'], plugins: { 'react-x': eslintPluginReactX, 'react-hooks': eslintPluginReactHooks, }, rules: { ...eslintPluginReactX.configs.recommended.rules, 'react-x/no-set-state': 'error', 'react-x/no-string-refs': 'error', 'react-x/jsx-no-duplicate-props': 'error', 'react-hooks/rules-of-hooks': 'error', 'react-hooks/exhaustive-deps': 'warn', }, }, ];
Debug
Known issues
breakingRemoval of `component-hook-factories` rule
fix
Remove any references to `react-x/component-hook-factories` from your ESLint config. This rule has been removed as the upstream equivalent was also removed.
affects: >=5.5.0-beta.0
deprecatedKit API Simplification: `initializedFromReact` and `initializedFromReactNative` renamed
fix
Replace `initializedFromReact` with `APIFromReact` and `initializedFromReactNative` with `APIFromReactNative`. Also, `is.memo()`, `is.lazy()`, etc. are removed in favor of `*Call` variants.
affects: >=5.0.2-beta.0
gotchaRequires Node >=22.0.0 and ESLint ^10.0.0
fix
Upgrade Node to v22+ and ESLint to v10+. Use older versions of the plugin if you cannot upgrade (e.g., v3.x for ESLint 8/9).
affects: >=4.0.0
gotchaCJS require() does not work; ESM-only package
fix
Use dynamic import (`import('eslint-plugin-react-x')`) or convert your project to ESM. Set `"type": "module"` in package.json.
affects: >=4.0.0
gotchaPeer dependency on TypeScript — even if not using TypeScript, plugin may attempt type resolution
fix
Install TypeScript as a devDependency. If no TypeScript files exist, consider setting `tsconfigRootDir` in ESLint config to avoid unnecessary type checking overhead.
affects: >=4.0.0
Errors
Common errors & fixes
ESLint: Failed to load plugin 'react-x' ... Cannot find module 'eslint-plugin-react-x'
Plugin is not installed or ESLint cannot resolve it in a monorepo or non-standard node_modules.
fix
Run `npm install eslint-plugin-react-x --save-dev` or ensure the plugin is in your root `node_modules`. Use `require.resolve` in ESLint config if needed.
Parsing error: The keyword 'export' is reserved
Using CommonJS `require()` to load the ESM-only plugin.
fix
Switch to ESM: add `"type": "module"` to your package.json and use `import` syntax in your ESLint config.
Cannot read properties of undefined (reading 'rules')
Incorrectly referencing config.rules without spreading the config object from the plugin.
fix
Use `eslintPluginReactX.configs.recommended.rules` instead of `eslintPluginReactX.configs.recommended.rules` if accessing manually, or spread the entire config.
TypeError: (0 , eslintPluginReactX.default) is not a function
Using default import incorrectly when plugin is not a function but an object.
fix
Use default import as `import eslintPluginReactX from 'eslint-plugin-react-x'` (the plugin is the default export) rather than calling it as a function.
Upgrade
Version history
4.2.3latest on npm
Audit
Dependencies
eslintrequiredPeer dependency; plugin runs within ESLint ^10.0.0.
typescriptrequiredPeer dependency; used for type-aware rules and type checking.
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-plugin-react-x — npm install eslint-plugin-react-x · libregistry