A React-specific ESLint configuration for modern JavaScript and TypeScript projects. This package integrates recommended configurations for React, TypeScript, JSX accessibility, stylistic rules, and import handling to ensure a consistent and high-quality codebase.
Make sure you have the base ESLint configuration set up. Install @peculiar/eslint-config-base
by following the installation instructions here.
Once the base config is installed, add the @peculiar/eslint-config-react
package:
yarn add -D @peculiar/eslint-config-react
To use @peculiar/eslint-config-react
in your project, configure your ESLint to extend this configuration.
- Create or update your ESLint configuration file (e.g.,
eslint.config.mjs
). - Extend
@peculiar/eslint-config-react
as shown below:
import tseslint from 'typescript-eslint';
import baseConfig from '@peculiar/eslint-config-base';
import reactConfig from '@peculiar/eslint-config-react';
export default tseslint.config([
...baseConfig,
...reactConfig,
]);
After setting up, you can run ESLint using the following command:
yarn eslint
This configuration includes:
-
React Rules: Recommended settings for React and React Hooks using
eslint-plugin-react
andeslint-plugin-react-hooks
. -
JSX Accessibility: Ensures accessibility best practices with
eslint-plugin-jsx-a11y
. - Custom Rules: Tailored rules for statement padding, JSX formatting, object formatting, and more.
Feel free to override or extend the rules in your project-specific ESLint configuration as needed. For example:
To add a custom ESLint rule, include it in your configuration as follows:
import tseslint from 'typescript-eslint';
import baseConfig from '@peculiar/eslint-config-base';
import reactConfig from '@peculiar/eslint-config-react';
export default tseslint.config([
...baseConfig,
...reactConfig,
{
rules: {
'your-custom-rule': 'warn',
},
},
]);
This project is licensed under the MIT License.