React Rules
Rules for React Luau components, hooks, and JSX patterns. Browse all 41 rules in this category.
Showing 41 rules
Ban React Fc
React Rulesban-react-fcBan React.FC and similar component type annotations. Use explicit function declarations instead.
- Problem
Memoized Effect Dependencies
React Rulesmemoized-effect-dependenciesFlags effect dependencies that are not memoized. Unmemoized dependencies can cause unnecessary re-renders or infinite loops.
- Problem
No Cascading Set State
React Rulesno-cascading-set-stateDisallow effect hooks with many cascading state updates.
- Problem
No Derived State
React Rulesno-derived-stateDisallow storing derived state in an effect.
- Suggestion
No Chain State Updates
React Rulesno-chain-state-updatesDisallow chaining state changes in an effect.
- Suggestion
No Event Handler
React Rulesno-event-handlerDisallow using state and an effect as an event handler.
- Suggestion
No Adjust State On Prop Change
React Rulesno-adjust-state-on-prop-changeDisallow adjusting state in an effect when a prop changes.
- Suggestion
No Reset All State On Prop Change
React Rulesno-reset-all-state-on-prop-changeDisallow resetting all state in an effect when a prop changes.
- Suggestion
No Pass Live State To Parent
React Rulesno-pass-live-state-to-parentDisallow passing live state to parents in an effect.
- Suggestion
No Pass Data To Parent
React Rulesno-pass-data-to-parentDisallow passing data to parents in an effect.
- Suggestion
No External Store Subscription
React Rulesno-external-store-subscriptionDisallow subscribing to an external store in an effect.
- Suggestion
No Initialize State
React Rulesno-initialize-stateDisallow initializing state in an effect.
- Suggestion
No Giant Component
React Rulesno-giant-componentReport React components whose bodies exceed 300 lines.
- Problem
No God Components
React Rulesno-god-componentsEnforce React component size and complexity limits inspired by the 'Refactor God Component' checklist.
- Problem
No Inline Property On Memo Component
React Rulesno-inline-property-on-memo-componentPrevent inline properties from being passed to memoized components.
- Problem
No New Instance In Use Memo
React Rulesno-new-instance-in-use-memoDisallow configured constructor calls (default: new Instance) inside React useMemo callbacks.
- Problem
No Render Helper Functions
React Rulesno-render-helper-functionsDisallow non-component functions that return JSX or React elements.
- Suggestion
No Static React Create Element
React Rulesno-static-react-create-elementRequire JSX for static React.createElement calls.
- Problem
No Underscore React Props
React Rulesno-underscore-react-propsBan React property names that begin with an underscore in JSX.
- Problem
No Unused Use Memo
React Rulesno-unused-use-memoDisallow standalone useMemo calls that ignore the memoized value.
- Problem
No Use Memo Simple Expression
React Rulesno-use-memo-simple-expressionDisallow useMemo for expressions that are already trivial to compute.
- Problem
No Useless Use Effect
React Rulesno-useless-use-effectDisallow empty effects, duplicate dependencies, effect chains, log-only effects, derived state, external-store state sync, state initialization, reset effects, parent notifications, parent ref callbacks, and event side effects routed through state.
- Suggestion
No Useless Use Memo
React Rulesno-useless-use-memoDisallow useMemo calls that only wrap values static enough to live at module scope.
- Suggestion
No Useless Use Spring
React Rulesno-useless-use-springDisallow useSpring hooks whose config and dependencies are entirely static
- Suggestion
Prefer Constant Dispatch
React Rulesprefer-constant-dispatchDisallow inline useReducer action objects that could be module-level constants.
- Suggestion
- Editor suggestions
Prefer Context Stack
React Rulesprefer-context-stackPrefer a local ContextStack component over directly nesting multiple context providers.
- Suggestion
- Automatic fix
Prefer Direct Hook Imports
React Rulesprefer-direct-hook-importsPrefer importing React hooks directly instead of calling them via the React namespace.
- Suggestion
Prefer Hoisted Jsx Elements
React Rulesprefer-hoisted-jsx-elementsPrefer extracting static JSX elements to module-level constants.
- Suggestion
Prefer Hoisted Jsx Object Properties
React Rulesprefer-hoisted-jsx-object-propertiesPrefer extracting inline JSX object props to module-level constants when the entire object is statically hoistable.
- Suggestion
Prefer Local Portal Component
React Rulesprefer-local-portal-componentPrefer a local Portal component over direct createPortal calls when the project already defines one.
- Suggestion
- Automatic fix
Prefer Padding Components
React Rulesprefer-padding-componentsPrefer local EqualPadding and DirectionalPadding components over matching <uipadding /> declarations.
- Suggestion
- Automatic fix
Prefer Ternary Conditional Rendering
React Rulesprefer-ternary-conditional-renderingPrefer ternary expressions over complementary JSX && branches.
- Suggestion
- Automatic fix
Prefer Use Reducer
React Rulesprefer-use-reducerSuggest using useReducer for related state updates instead of multiple useState calls.
- Problem
React Hooks Strict Return
React Rulesreact-hooks-strict-returnRestrict React hooks to object returns or short tuples.
- Suggestion
Require Named Effect Functions
React Rulesrequire-named-effect-functionsEnforce named effect functions for better debuggability. Prevents inline arrow functions in useEffect and similar hooks.
- Problem
- Automatic fix
Require React Component Keys
React Rulesrequire-react-component-keysRequire keys on nested React JSX children, fragments, and configured iteration or memoization contexts.
- Problem
Require React Display Names
React Rulesrequire-react-display-namesRequire displayName on exported memo components and contexts.
- Problem
Rerender Memo With Default Value
React Rulesrerender-memo-with-default-valuePrevent inline empty object and array defaults in component prop destructuring.
- Problem
Strict Component Boundaries
React Rulesstrict-component-boundariesPrevent imports that reach into another component's nested modules.
- Problem
Use Exhaustive Dependencies
React Rulesuse-exhaustive-dependenciesEnforce exhaustive and correct dependency specification in React hooks to prevent stale closures and unnecessary re-renders
- Problem
- Automatic fix and editor suggestions
Use Hook At Top Level
React Rulesuse-hook-at-top-levelEnforce that React hooks are only called at the top level of components or custom hooks, never conditionally or in nested functions
- Problem