mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Summary: Implements: https://github.com/facebook/react-native/issues/42996 Add support for Flat config (eslint v9) to `eslint-config-react-native`. To achieve this, I created `packages/eslint-config-react-native/flat.js` to export flat config as well as maintain legacy config for backward compatibility. I recognize we have had [the PR for supporting Flat config](https://github.com/facebook/react-native/issues/42996) already, but it looks stale and doesn't seem likely to move forward. That's why I created this PR. I also updated `eslint-plugin-react-native` and `eslint-plugin-specs` so that they comply with the current eslint plugin format. ## Changelog: [GENERAL] [ADDED] - Add support for Flat Config (eslint v9) Pull Request resolved: https://github.com/facebook/react-native/pull/54297 Test Plan: 1. Pull this branch into your local machine 2. `cd packages/eslint-config-react-native` 3. `yarn link` 4. Clone https://github.com/pipopotamasu/rn-eslint-config-test in your local machine 5. `cd path/to/rn-eslint-config-test` 6. `yarn install` 7. `yarn link "react-native/eslint-config"` 8. `yarn lint` 9. Confirm that eslint rules from `react-native/eslint-config` are applied <img width="1470" height="628" alt="image" src="https://github.com/user-attachments/assets/955fd655-8a79-4dd4-9031-e505d218d63a" /> Reviewed By: vzaidman Differential Revision: D85851077 Pulled By: huntie fbshipit-source-id: 9c78ecc4f5c3b10175a89417628b599735f95215
1020 B
1020 B
@react-native/eslint-config
Installation
yarn add --dev eslint prettier @react-native/eslint-config
Note: We're using yarn to install deps. Feel free to change commands to use npm 3+ and npx if you like
Usage
For ESLint 9+ (Flat Config)
Add to your eslint.config.js:
const reactNativeConfig = require('@react-native/eslint-config/flat');
module.exports = [
...reactNativeConfig,
// Your custom config here
];
Or with ES modules:
import reactNativeConfig from '@react-native/eslint-config/flat';
export default [
...reactNativeConfig,
// Your custom config here
];
For ESLint 8 (Legacy Config)
Add to your eslint config (.eslintrc, or eslintConfig field in package.json):
{
"extends": "@react-native"
}