Hub rules-react

rules-react

v4 public Verified

React

React is a JavaScript library for building user interfaces based on components. These rules govern hook usage, state management, and component lifecycle best practices for AI agents.

@sigmashakeinc 16 pulls 20 rules published Apr 8, 2026 synced Oct 11, 2026 sigmashakeinc/rules/rulesets/rules-react →
Severity
14 error 6 warn 0 info
demo.cast
React is a JavaScript library for building user interfaces based on components. These rules govern hook usage, state management, and component lifecycle best practices for AI agents.

Rules index

20 governance rules

Indexed from the repository's .rules files, grouped by technology. Expand any rule to read the raw source.

react

ask-empty-dep-array warning log

Empty dependency array [] means this hook only runs once (on mount). Verify this is intentional and there are no stale closure issues with captured values.

Rule source requires an active Pro or Enterprise subscription.
ask-external-url-href warning log

Dynamic href detected. Validate that user-supplied values cannot inject javascript: or data: URIs.

Rule source requires an active Pro or Enterprise subscription.
ask-use-server-action warning log

'use server' exposes an HTTP endpoint callable by any client (see CVE-2025-55182/55183/55184). Authenticate + authorize every server action, validate all arguments, and ensure React is on >=19.0.1/19.1.2/19.2.1.

Rule source requires an active Pro or Enterprise subscription.
no-aria-hidden-on-focusable error block

aria-hidden="true" on a focusable element creates a keyboard trap — the element is invisible to screen readers but still reachable by keyboard. Remove tabIndex or aria-hidden.

Rule source requires an active Pro or Enterprise subscription.
no-autofocus warning log

autoFocus moves keyboard focus unexpectedly, which can disorient screen reader users navigating a page. Use autoFocus only for modal dialogs or intentional focus management.

Rule source requires an active Pro or Enterprise subscription.
no-click-without-keyboard warning log

Interactive element with onClick but no keyboard handler. Non-button/anchor elements with click handlers are inaccessible to keyboard users. Use <button> or add onKeyDown.

Rule source requires an active Pro or Enterprise subscription.
no-dangerous-html error block

dangerouslySetInnerHTML bypasses React's XSS protection. If you need HTML rendering, sanitize with DOMPurify first: dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(html) }}

Rule source requires an active Pro or Enterprise subscription.
no-empty-button-label error block

Button with no text label. Screen readers will announce it as 'button' with no context. Add visible text or an aria-label attribute.

Rule source requires an active Pro or Enterprise subscription.
no-find-dom-node error block

findDOMNode was removed in React 19. Use a ref (useRef/createRef) attached to the target element instead.

Rule source requires an active Pro or Enterprise subscription.
no-hooks-in-conditionals error block

React hooks must not be called inside conditionals. This violates the Rules of Hooks and causes unpredictable behavior. Move the hook call to the top level.

Rule source requires an active Pro or Enterprise subscription.
no-href-javascript error block

href="javascript:" enables XSS attacks. Use onClick handlers instead of javascript: URIs.

Rule source requires an active Pro or Enterprise subscription.
no-img-without-alt error block

img element missing alt attribute. Screen readers cannot describe the image. Add alt="description" for meaningful images, alt="" for decorative ones.

Rule source requires an active Pro or Enterprise subscription.
no-missing-key-in-list warning log

Array .map() rendering detected. Ensure each rendered element has a unique 'key' prop — missing keys cause incorrect re-renders and React warnings.

Rule source requires an active Pro or Enterprise subscription.
no-nextjs-middleware-subrequest error block

Referencing the x-middleware-subrequest header is associated with CVE-2025-29927 (Next.js middleware auth bypass). Upgrade Next.js to >=14.2.25 / >=15.2.3 and strip this header at the edge; do not trust it in application code.

Rule source requires an active Pro or Enterprise subscription.
no-react-router-prerender-headers error block

X-React-Router-SPA-Mode / X-React-Router-Prerender-Data headers are attacker-controlled inputs behind CVE-2025-43864/43865 (cache poisoning, data spoofing). Upgrade react-router to >=7.5.2 and never forward or trust these headers.

Rule source requires an active Pro or Enterprise subscription.
no-ref-innerhtml-xss error block

RISK: assigning to ref.current.innerHTML bypasses React's XSS escaping entirely — any user-controlled content becomes injected HTML. FIX: use textContent for plain text, or sanitise with DOMPurify.sanitize() before assigning innerHTML.

Rule source requires an active Pro or Enterprise subscription.
no-setstate-in-render error block

Calling setState directly in the render body (outside useEffect) causes an infinite render loop. Move state updates into event handlers or useEffect.

Rule source requires an active Pro or Enterprise subscription.
no-string-refs error block

String refs (ref="name") were removed in React 19. Use useRef() or a callback ref (ref={el => ...}) instead.

Rule source requires an active Pro or Enterprise subscription.
no-target-blank-without-rel error block

target="_blank" without rel="noopener noreferrer" allows the new page to access window.opener (reverse tabnapping). Add rel="noopener noreferrer".

Rule source requires an active Pro or Enterprise subscription.
no-token-in-localstorage error block

Storing auth tokens in localStorage exposes them to any XSS on the page (OWASP guidance). Keep access tokens in memory and long-lived refresh tokens in HttpOnly SameSite cookies.

Rule source requires an active Pro or Enterprise subscription.

Version metadata

Published metadata

The hash-locked record of this published ruleset. When source contents change, the maintainer resyncs and the version bumps.

Version
v4
Published
Apr 8, 2026
Source commits
0
Synced
Oct 11, 2026
Hash
6ec2985484cdfa0549c749ed79a6a999ce29af3eb5c1ebb073c8b8d150b5c90a
Signature
Verified (publisher key)
Tested with
claude-code@current
Plan
Starter (free)
Visibility
Public

Source history

Recent commits

Latest commits touching rulesets/rules-react/.sigmashake/rules in sigmashakeinc/rules/rulesets/rules-react. The published version only bumps when a maintainer resyncs.

No commit history available.