Skip to content
Esc

@noctcore/eslint-plugin-react

v1.1.018 rules9 recommended7 strict only2 opt-innamespace noctcore-react

A bad fit if your codebase keeps hooks inline by convention, or if you are linting a library of generic primitives where wide prop surfaces are the point.

React architecture and correctness: prop drilling, state colocation, memoized context values, effect safety.

React components that compile, render, and still rot: a props bundle forwarded unchanged through three layers, state and effects written inline in the .tsx, a context value that is a fresh object every render, a setState that lands after the component unmounted. TypeScript and eslint-plugin-react-hooks see none of these, because each is a structural decision rather than a type or hook-order error.

It will yell at you about where code lives as much as what it does. no-state-in-component-body wants state and effects in a colocated <Name>.hooks.ts, max-props-per-component and max-hook-return-surface cap how wide a component or hook is allowed to get, and props-must-be-visual rejects identity props like userId on presentational components. That is a deliberate architecture: containers own data, components render it. It is a bad fit if your codebase keeps hooks inline by convention, or if you are linting a library of generic primitives where wide prop surfaces are the point. Start with the correctness half (context-value-must-be-memoized, require-effect-cancellation, no-effect-derived-state) and switch the structural rules off rather than living with a wall of reports.

Install
npm install --save-dev @noctcore/eslint-plugin-react @typescript-eslint/parser
# or: bun add -D / pnpm add -D @noctcore/eslint-plugin-react @typescript-eslint/parser

The recommended preset enables 9 of 18 rules. The strict preset adds 7 house rules (naming, folder shape, size caps) on top. The rules board below builds the flat config: start from a preset, switch single rules between error and off, and copy the result.

Each rule links to its page, with the options it takes and Incorrect and Correct examples. A good first read is no-prop-drilling.

9 of 18 at error

--fixsuggestionsneeds optionstype infoEach switch sets a rule to error or off.

component-props-naming
A function component's first-param props type must be named <Component>Props. Autofixes by renaming the in-file type declaration and its references when that is safe.
Fixable with --fix
strict only
context-value-must-be-memoized
A context Provider value must not be an inline object, array or function: a fresh reference each render re-renders every consumer. Memoize it with useMemo / useCallback and pass the stable reference.
recommended
enforce-context-consumption
A prop whose value a registered scoped context already supplies must be read from the context, not declared or destructured as a prop again.
Needs options
opt-in
max-hook-return-surface
An exported use* hook in a hook file may return object literals (top-level or nested one level) of at most max (default 20) members. Wider returns are god-controllers in the making.
strict only
max-hooks-per-file
A hook/query/mutation file (default *.hooks.ts / *.queries.ts / *.mutations.ts) may export at most max (default 4) use* hooks. Split larger files.
strict only
max-props-per-component
A *Props interface/type-literal may declare at most max (default 12) local members. extends clauses are not counted.
strict only
max-state-per-hook
A use* hook in a hook file may keep at most max (default 4) useState / useReducer slots, and a function inside it may call at most maxSettersPerFunction (default 3) distinct setters. Group the rest in a reducer.
strict only
no-effect-derived-state
An effect whose entire body is setState calls with values derived purely from its dependencies is the "you might not need an effect" anti-pattern — compute the value during render (or with useMemo) instead.
recommended
no-jsx-computation
Disallow array methods, arithmetic, and chained logical expressions directly inside JSX {...}. Lift them to a const above the return or into the hook.
strict only
no-jsx-in-hooks
A use*-named function must not return JSX — that is a component wearing a hook costume. Rename it to a PascalCase component, or return values instead of elements.
recommended
no-native-date-input
Disallow native date inputs (type="date" and friends): Chromium formats them in the browser UI language and ignores lang, so the date order can contradict the page.
opt-in
no-prop-drilling
A bundle of maxForwarded+ (default 4) props each forwarded unchanged (name={name}) from the *Props param to the same child component is prop drilling. Compose instead.
recommended
no-state-in-component-body
State/effect/query hooks must live in the colocated hook file (<Name>.hooks.ts), not in the component .tsx body. The component is a thin shell.
strict only
no-unguarded-web-storage
A localStorage / sessionStorage access must sit inside a try with a catch: the access itself throws when storage is disabled, partitioned or full.
Editor suggestions
recommended
password-input-requires-autocomplete
A password field must carry an explicit autoComplete purpose, so a password manager can fill the current password and save a new one.
recommended
prefer-lazy-state-init
A useState initializer that is an expensive call (default JSON.parse / localStorage.getItem / sessionStorage.getItem, or a configured builder) must be wrapped in a function so it runs once on mount, not every render.
Fixable with --fix
recommended
props-must-be-visual
Component props must be visual. Auth/business-identity and credential prop names (userId, currentUser, *token*, *jwt*, *secret*, apiKey, ...) are disallowed. A live password input is a legitimate visual concern and is intentionally allowed.
recommended
require-effect-cancellation
A setState/dispatch that runs after an await or .then() inside a useEffect must be guarded against a unmounted/re-run effect (AbortController, a cancelled flag, or a cleanup return).
recommended