eslint-config-xo-react
ESLint shareable config for React to be used with eslint-config-xo
Last updated 2 months ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install eslint-config-xo-react 
SYNC missed versions from official npm registry.

eslint-config-xo-react

ESLint shareable config for React to be used with eslint-config-xo

Install

npm install --save-dev eslint-config-xo eslint-config-xo-react

[!NOTE] This config is built on ESLint React, which requires typescript as a peer dependency even in JavaScript-only projects. npm and pnpm install it for you, but Yarn does not, so install it yourself there.

Usage

// eslint.config.js
import eslintConfigXo from 'eslint-config-xo';
import eslintConfigXoReact from 'eslint-config-xo-react';
import {defineConfig} from 'eslint/config';

export default defineConfig([
	...eslintConfigXo(),
	...eslintConfigXoReact(),
]);

Options

space

Type: boolean | number
Default: false

Use spaces for indentation instead of tabs for JSX props. Set to true for 2 spaces, or a number for a custom count.

export default defineConfig([
	...eslintConfigXo({space: true}),
	...eslintConfigXoReact({space: true}),
]);

prettier

Type: boolean | 'compat'
Default: false

Integrate Prettier by turning off the JSX formatting rules that conflict with it. Rules owned by eslint-config-xo are left alone, so you no longer need to add eslint-config-prettier yourself.

export default defineConfig([
	...eslintConfigXo({prettier: 'compat'}),
	...eslintConfigXoReact({prettier: 'compat'}),
]);

This config never runs Prettier, so any truthy value only turns off the conflicting rules. Running Prettier itself is handled by the prettier option in eslint-config-xo. Pass the same value you pass there.

Use with XO

XO comes bundled with eslint-config-xo, so you only need this config:

npm install --save-dev eslint-config-xo-react
// xo.config.js
import eslintConfigXoReact from 'eslint-config-xo-react';
import {defineConfig} from 'eslint/config';

export default defineConfig([
	...eslintConfigXoReact(),
]);

Pass the same space and prettier values you use in your XO config.

Included plugins

Accessibility

Accessibility rules come from eslint-plugin-jsx-a11y-x, a maintained fork of eslint-plugin-jsx-a11y. The rules are prefixed with jsx-a11y-x/.

Only the rules that can be decided from the markup alone are enabled. The rules that guess at whether an element is meant to be interactive are left out, as they cannot see through component wrappers and do not apply to React Native. Enable those yourself if they suit your project.

If you wrap native elements in your own components, map them so the rules can see through the wrapper:

export default defineConfig([
	...eslintConfigXoReact(),
	{
		settings: {
			'jsx-a11y-x': {
				components: {
					TextField: 'input',
				},
			},
		},
	},
]);

Related

Current Tags

  • 0.32.0                                ...           latest (2 months ago)

34 Versions

  • 0.32.0                                ...           2 months ago
  • 0.31.0                                ...           5 months ago
  • 0.30.1                                ...           7 months ago
  • 0.30.0                                ...           8 months ago
  • 0.29.0                                ...           a year ago
  • 0.28.0                                ...           2 years ago
  • 0.27.0                                ...           5 years ago
  • 0.26.0                                ...           5 years ago
  • 0.25.0                                ...           6 years ago
  • 0.24.0                                ...           6 years ago
  • 0.23.0                                ...           7 years ago
  • 0.22.0                                ...           7 years ago
  • 0.21.0                                ...           7 years ago
  • 0.20.0                                ...           7 years ago
  • 0.19.0                                ...           8 years ago
  • 0.18.0                                ...           8 years ago
  • 0.17.0                                ...           8 years ago
  • 0.16.0                                ...           9 years ago
  • 0.15.0                                ...           9 years ago
  • 0.14.0                                ...           9 years ago
  • 0.13.0                                ...           9 years ago
  • 0.12.0                                ...           10 years ago
  • 0.11.1                                ...           10 years ago
  • 0.11.0                                ...           10 years ago
  • 0.10.0                                ...           10 years ago
  • 0.9.0                                ...           10 years ago
  • 0.8.0                                ...           10 years ago
  • 0.7.0                                ...           11 years ago
  • 0.6.0                                ...           11 years ago
  • 0.5.0                                ...           11 years ago
  • 0.4.0                                ...           11 years ago
  • 0.3.0                                ...           11 years ago
  • 0.2.0                                ...           11 years ago
  • 0.1.0                                ...           11 years ago
Downloads
Total 71
Today 0
This Week 1
This Month 53
Last Day 0
Last Week 52
Last Month 1
Dev Dependencies (4)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE