react-stinky
React Stinky
A holistic code-smell detector for React and TypeScript. It finds the patterns that make a component, a hook, or a module hard to read, reason about, and change, explains the cost of each, and proposes a concrete fix. Coverage spans prop and API design, state and data flow, effects and lifecycle, component structure, rendering correctness, accessibility, and TypeScript discipline. The full catalog with detection signals, fixes, exceptions, and sources is in catalog.md; read it before running a scan.
It defers two neighboring concerns to sibling skills so it does not duplicate them: memoization (useMemo, useCallback, React.memo) to react-compiler, and color literals to theme-colors. If those are not installed, note the finding in one line and move on. Everything else about day-to-day React maintainability is in scope.
What it sniffs for
Seven pillars. The categories under each, with detection signals and sources, are in catalog.md.
- Component API and props (the backbone, 18 categories). Component and prop naming, boolean and callback conventions, string-union variants over boolean flags, discriminated unions, controlled and uncontrolled state, children and slot composition, render props, generics, extending HTML, refs, styling APIs, accessibility props, server-component boundaries, JSDoc.
- State and data flow. Derivable values held in
useState, props copied into state, two sources of truth for one fact, prop drilling through layers that ignore the prop. - Effects and lifecycle. Effects that compute derived data or run logic that belongs in an event handler, fetches and subscriptions and timers with no cleanup (races and leaks), dependency arrays that do not match what the effect reads, state reset by an effect instead of
key. - Component structure and hooks. God components doing fetching, logic, and presentation at once; a component defined inside another (remounts every render); stateful logic that wants a custom hook; conditional hooks; positional-parameter sprawl on a hook or util.
- Rendering correctness. Array index as
keyon a list that reorders or edits, direct mutation of state or props, nested ternaries in JSX, copy-pasted JSX blocks that want one parameterized helper. - Accessibility in markup.
onClickon a non-interactive element with norole,tabIndex, or keyboard handler; div soup where semantic elements belong; form controls with no associated label. - TypeScript discipline.
anyandas anyand@ts-ignore, lyingascasts and non-null!, loose internal types (object,Function, stringly-typed enums). - Cross-file duplication (folder and repo scope only). A component re-implemented inline where a reusable one exists, the same hook or utility copied across files, a type declared in two places. Method in duplication-pass.md.