oxlint-config-react-hooks-js
v1.1.1
Published
Oxlint config presets for eslint-plugin-react-hooks JS plugin (React Compiler rules)
Downloads
874
Maintainers
Readme
oxlint-config-react-hooks-js
Oxlint config presets for eslint-plugin-react-hooks as a JS plugin. Provides React Compiler lint rules that are not available in oxlint's native React plugin.
Why
Oxlint's built-in react plugin covers rules-of-hooks and exhaustive-deps natively, but the React Compiler rules (introduced in eslint-plugin-react-hooks v7) have no native oxlint equivalent. This package bridges the gap by configuring eslint-plugin-react-hooks as an oxlint JS plugin with the correct alias and rule settings.
Rules that oxlint already implements natively are automatically excluded using @oxlint/migrate.
[!WARNING] This package runs
eslint-plugin-react-hooksas an oxlint JS plugin, which is significantly slower than oxlint's native Rust-based rules. Expect a noticeable performance hit compared to a native-only setup.
Presets
| Preset | Rules | Source |
| ------------------------- | ----- | ----------------------------------------------------- |
| recommended.json | 14 | recommended from eslint-plugin-react-hooks |
| recommended-latest.json | 15 | recommended-latest from eslint-plugin-react-hooks |
Rules
recommended
Enabled via JS plugin (14 rules, prefixed with react-hooks-js/):
configerror-boundariesgatingglobalsimmutabilityincompatible-librarypreserve-manual-memoizationpurityrefsset-state-in-effectset-state-in-renderstatic-componentsunsupported-syntaxuse-memo
Excluded because oxlint covers them natively (2 rules):
exhaustive-depsrules-of-hooks
recommended-latest
Enabled via JS plugin (15 rules, prefixed with react-hooks-js/):
configerror-boundariesgatingglobalsimmutabilityincompatible-librarypreserve-manual-memoizationpurityrefsset-state-in-effectset-state-in-renderstatic-componentsunsupported-syntaxuse-memovoid-use-memo
Excluded because oxlint covers them natively (2 rules):
exhaustive-depsrules-of-hooks
Opt-in rules (not in any preset)
Rules shipped by eslint-plugin-react-hooks that no preset enables (12 rules). Add them manually under rules with the react-hooks-js/ prefix (see Overriding rules):
capitalized-callscomponent-hook-factoriesexhaustive-effect-dependenciesfbthooksinvariantmemo-dependenciesmemoized-effect-dependenciesno-deriving-state-in-effectsrule-suppressionsyntaxtodo
Installation
pnpm add -D oxlint-config-react-hooks-js eslint-plugin-react-hookseslint-plugin-react-hooks is a peer dependency and must be installed in your project.
Usage
JSON config (.oxlintrc.json)
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"extends": ["./node_modules/oxlint-config-react-hooks-js/configs/recommended-latest.json"]
}TypeScript config (oxlint.config.ts)
import { defineConfig } from "oxlint";
import reactCompiler from "oxlint-config-react-hooks-js/configs/recommended-latest.json" with { type: "json" };
export default defineConfig({
extends: [reactCompiler],
});The JSON import is typed as OxlintConfig via the bundled type declaration file exposed through the types subpath condition.
Overriding rules
import { defineConfig } from "oxlint";
import reactCompiler from "oxlint-config-react-hooks-js/configs/recommended-latest.json" with { type: "json" };
export default defineConfig({
extends: [reactCompiler],
rules: {
"react-hooks-js/incompatible-library": "off",
// Add rules not in the preset
"react-hooks-js/todo": "error",
},
});How it works
The scripts/generate.ts script:
- Reads the
recommendedandrecommended-latestconfigs fromeslint-plugin-react-hooks - Passes them through
@oxlint/migrateto identify rules that oxlint implements natively - Excludes native rules and prefixes the remaining rules with the
react-hooks-jsalias - Outputs JSON preset files to
configs/
The react-hooks-js alias is required because react-hooks is a reserved plugin name in oxlint (covered by the native react plugin).
License
MIT
