Registry / testing / eslint-config-xo-react

eslint-config-xo-react

JSON →
library0.30.1jsnpmunverified

ESLint shareable config for React projects, designed to be used with eslint-config-xo. Current stable version is 0.30.1, released in early 2025. This package enforces a strict, opinionated set of React and JSX rules including hooks, prop types, accessibility, and security. It supports both React and Preact, and requires Node.js >=18.18 and ESLint >=9.18.0. Unlike generic React ESLint configs, it integrates tightly with the XO style guide and provides options for spaces vs tabs in JSX. Ships TypeScript types, but is ESLint 9 (flat config) only from v0.30.0.

npm install eslint-config-xo-react
INSTALL
IMPORT
SIG · ESLINT-CONFIG-XO-R
E
eslint-config-xo-react
testingjavascriptv0.30.1
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 (eslintConfigXoReact)
import eslintConfigXoReact from 'eslint-config-xo-react';
const eslintConfigXoReact = require('eslint-config-xo-react');
ESM-only since v0.30.0 (flat config). CommonJS require() will fail.
Options type
import type { EslintConfigXoReactOptions } from 'eslint-config-xo-react';
TypeScript users should import the options type for strong typing.
Spread usage with options
export default [ ...eslintConfigXoReact({ space: true }) ];
export default [ eslintConfigXoReact({ space: true }) ];
The function returns an array of config objects; you must spread it into the flat config array. Failure to spread will cause 'undefined' or invalid config errors.

Sets up ESLint flat config for React with XO style guide, using spaces for JSX indentation.

// Install: npm install --save-dev eslint-config-xo eslint-config-xo-react eslint-plugin-react eslint-plugin-react-hooks // eslint.config.js import eslintConfigXo from 'eslint-config-xo'; import eslintConfigXoReact from 'eslint-config-xo-react'; export default [ ...eslintConfigXo(), ...eslintConfigXoReact({ space: true }), // Use 2 spaces for JSX ];
Debug
Known issues
breakingIn v0.30.0, the config moved from subexports to options. The import path changed; subexports like 'eslint-config-xo-react/react' no longer work.
fix
Use default import: import eslintConfigXoReact from 'eslint-config-xo-react' and pass options as object.
affects: >=0.30.0
breakingv0.30.0 requires ESLint >=9.18.0 (flat config only). Legacy ESLint 8 .eslintrc formats are not supported.
fix
Upgrade ESLint to 9.x and migrate to eslint.config.js flat config.
affects: >=0.30.0
breakingv0.27.0 requires function declarations for named React components (enforced by react/function-component-definition rule). Arrow function components will be flagged.
fix
Use function declarations for named components: function MyComponent() { ... } instead of const MyComponent = () => { ... }.
affects: >=0.27.0
gotchaThis config is meant to be used together with eslint-config-xo. If used alone, many base rules from XO (e.g., indent, quotes) will be missing, causing conflicts.
fix
Always include eslint-config-xo in your ESLint flat config array before eslint-config-xo-react.
affects: all
deprecatedXO style via package.json 'xo' key is deprecated in favor of ESLint flat config. The README tip about XO integration is outdated.
fix
Use ESLint flat config with eslint-config-xo and eslint-config-xo-react directly.
affects: >=0.30.0
Errors
Common errors & fixes
Error: ESLint configuration in eslint.config.js is invalid: config[1] is not a valid config object.
Forgot to spread the result of eslintConfigXoReact() into the flat config array.
fix
Use ...eslintConfigXoReact() instead of eslintConfigXoReact() alone.
Error: Cannot find module 'eslint-config-xo-react' or its corresponding type declarations.
Using CommonJS require() with an ESM-only package (v0.30.0+).
fix
Convert to ESM: use import and set "type": "module" in package.json, or use dynamic import().
Parsing error: The keyword 'export' is reserved
ESLint is still using .eslintrc format (env/parserOptions) instead of flat config.
fix
Upgrade to ESLint 9 and use eslint.config.js with flat config. Remove .eslintrc files.
Definition for rule 'react/function-component-definition' was not found
Missing eslint-plugin-react peer dependency.
fix
Install eslint-plugin-react: npm install --save-dev eslint-plugin-react
Upgrade
Version history
0.30.1latest on npm
Audit
Dependencies
eslintrequiredpeer dependency; version >=9.18.0 required as of v0.30.0 (flat config)
eslint-plugin-reactrequiredprovides React-specific lint rules; installed automatically as a dependency
eslint-plugin-react-hooksrequiredprovides hooks rules (e.g., rules-of-hooks, exhaustive-deps); installed automatically
eslint-config-xooptionalrequires base XO config as a foundation; peers not enforced but recommended
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-config-xo-react — npm install eslint-config-xo-react · libregistry