@lcooper/eslint-config-react
v3.0.0
Published
Shareable ESLint config for React
Downloads
17
Readme
@lcooper/eslint-config-react
An ESlint shareable flat config for React projects. Extends @lcooper/eslint-config
.
Installation
The peer dependency eslint
must be installed alongside this package.
install with npm:
npm install -D eslint @lcooper/eslint-config-react
install with yarn:
yarn add -D eslint @lcooper/eslint-config-react
This config is meant to be used in addition to the base @lcooper/eslint-config
config, so that should be installed as well.
Note: This project requires Eslint version
>=8.56
, and NodeJS version^18.18.0 || >=20.0.0
.
Usage
Add an eslint.config.js
config file to your project's root directory.
Note: this package exports a single flat config object, so no need for the
...
spread syntax when using it.
import baseConfig from '@lcooper/eslint-config';
import reactConfig from '@lcooper/eslint-config-react';
export default [
...baseConfig,
reactConfig,
];
If your project does not specify "type": "module"
in its package.json
file, then eslint.config.js
must be in CommonJS format:
const baseConfig = require('@lcooper/eslint-config'),
reactConfig = require('@lcooper/eslint-config-react');
module.exports = [
...baseConfig,
reactConfig,
];
This project is no longer compatable with the legacy eslintrc format, and requires you use the flat config format. Check out this page for more details about migrating from the eslintrc format to the flat config format.
File Matching
By default, this config matches .js
, .mjs
, and .jsx
files using the glob **/*.{js,mjs,jsx}
. More specificity can be achieved by overwriting the files
option with your own globs, like in this example:
import baseConfig from '@lcooper/eslint-config';
import reactConfig from '@lcooper/eslint-config-react';
export default [
...baseConfig,
{
...reactConfig,
files: ['src/**/*.{js,mjs,jsx}'],
},
];
Related
@lcooper/eslint-config
- Base config for standard JavaScript projects@lcooper/eslint-config-typescript
- Base config for TypeScript projects@lcooper/eslint-config-typescript-react
- Enhancement config for React projects that use TypeScript@lcooper/eslint-config-jest
- Enhancement config for projects using Jest@lcooper/eslint-plugin
- Plugin with awesome extra ESLint rules