$ show jsx-eslint/eslint-plugin-react
This repository is the `eslint-plugin-react` package, a widely-used ESLint plugin that provides over 100 lint rules for React and JSX codebases. It is not a standalone application but a library consumed by ESLint to enforce best practices, prevent common errors, and maintain code style in React projects. The plugin supports both legacy `.eslintrc` and modern flat config (`eslint.config.js`) formats, and works with multiple parsers including babel-eslint and TypeScript-ESLint. The architecture is modular: each rule is a self-contained module in `lib/rules/`, sharing common utilities from `lib/util/` for component detection, AST traversal, version checking, and error reporting. The codebase is well-tested with a comprehensive test suite that runs across parser versions and ESLint versions. It is actively maintained with frequent releases and community contributions.
The LLM identified 4 files worth highlighting for reuse:
Provides generic AST helper functions such as `isFunctionLike`, `isParenthesized`, `traverseReturns`, and `unwrapTSAsExpression`. These are used across many rules to inspect and navigate the AST. The module is self-contained (no internal plugin imports) and could be extracted into any ESLint plugin or AST analysis tool.
Implements React version detection by resolving the installed `react` package, with fallback to a configured default or latest version. It also handles Flow version detection. The logic is isolated and parameterized, making it reusable in any tool that needs to conditionally adjust behavior based on the React version in a project.
A factory function that creates ESLint rules forbidding `setState` calls inside specific lifecycle methods. It takes a list of method names and returns a complete rule module with meta and create. This pattern demonstrates clean separation of concerns and is reusable for creating similar 'no-setState-in-X' rules in other contexts.
A thin wrapper around `context.report` that standardizes error reporting with message IDs and data objects. It handles the common pattern of looking up message text from the rule's `messages` object and passing data. This utility is self-contained and can be reused in any ESLint rule to reduce boilerplate and ensure consistent reporting.