The Cloudflight ESLint Plugin for React provides multiple configurations of ESLint rules recommended by Cloudflight.
You can find the directory of all rules including their reasoning here.
The following dependencies are required:
"eslint": ">=9.0.0 < 10.0.0"
In your package.json
add the following:
"devDependencies": {
...
"@cloudflight/eslint-plugin-react": "<version>",
...
}
Now open your eslint.config.mjs
and add one of the configurations:
import { cloudflightReactConfig } from '@cloudflight/eslint-plugin-react';
import { includeIgnoreFile } from '@eslint/compat';
import { dirname, normalize, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
const directory = dirname(fileURLToPath(import.meta.url));
const gitignorePath = normalize(resolve(directory, '.gitignore'));
export default [
includeIgnoreFile(gitignorePath),
...cloudflightReactConfig({
rootDirectory: import.meta.dirname,
}),
];
See Custom Configuration for more complicated project setups.
When executing your next eslint .
it will now validate your code against the cloudflight-recommended rules.