BeforeMerge

AI-native code review knowledge base. Structured rules that catch what linters miss.

Product

  • Features
  • Explore
  • Pricing
  • Docs
  • GitHub

Company

  • About
  • Blog
  • Contributors
  • Contributing

Legal

  • Privacy Policy
  • Terms of Service
  • MIT License

© 2026 BeforeMerge. Built by Peter Krzyzek

BeforeMerge
Features
Explore
PricingBlogContributorsInstall Guide
3Sign In
FeaturesExplore
RulesSkillsKnowledgePrompts
PricingBlogContributorsInstall Guide
Sign In

Explore

Browse 354 rules, 42 knowledge articles, and 28 prompt templates across security, performance, architecture, and quality.

Sort:
Previous1...101112...15Next

Automate these checks on every PR

BeforeMerge scans your pull requests against these rules automatically. Get actionable feedback before code ships to production.

Join WaitlistLearn More

354 rules

Never Use eval() or new Function() with User Input

CRITICAL

Using eval(), new Function(), or innerHTML with user-controlled strings enables arbitrary code execution in the browser. [CWE-95 · A03:2021]

Securitycode-injectionReactReact

Sanitize Content Before dangerouslySetInnerHTML

CRITICAL

Using dangerouslySetInnerHTML with unsanitized user input enables XSS attacks. Always sanitize with DOMPurify or a trusted library. [CWE-79 · A03:2021]

SecuritySanitizationXSS

Always Clean Up useEffect Side Effects

MEDIUM

Missing cleanup in useEffect for subscriptions, timers, event listeners, and AbortControllers causes memory leaks, stale callbacks, and state updates on unmounted components.

QualityuseeffectReact

Never Use Array Index as Key for Dynamic Lists

MEDIUM

Using array index as key in lists that can be reordered, filtered, or inserted into causes React to mismap state to the wrong items, creating subtle and hard-to-debug UI bugs.

Qualitykey-propreconciliation

Add Error Boundaries Around Unreliable UI Sections

MEDIUM

Without error boundaries, a single component crash unmounts the entire React tree. Wrap unreliable sections so failures are isolated and recoverable.

QualityreliabilityReact

Do Not Mix Controlled and Uncontrolled Input Patterns

MEDIUM

Switching between controlled (value prop) and uncontrolled (defaultValue/no value) patterns on the same input causes React warnings and unpredictable behavior.

Qualitycontrolled-componentsforms

Avoid Inline Object/Array/Function Creation in JSX Props

HIGH

Creating new objects, arrays, or functions inline in JSX causes child components to re-render on every parent render due to referential inequality.

PerformanceusecallbackReact

Virtualize Large Lists Instead of Rendering All Items

HIGH

Rendering thousands of DOM nodes for long lists causes slow initial render, high memory usage, and scroll jank. Use virtualization (react-window, TanStack Virtual).

Performancetanstack-virtualReact

Memoize Expensive Computations with useMemo

HIGH

Running expensive calculations (sorting, filtering, transforming large datasets) on every render wastes CPU cycles. Use useMemo to cache results.

PerformancecomputationReact

Split Large Contexts to Prevent Unnecessary Consumer Re-renders

HIGH

Putting too much state in a single React Context causes all consumers to re-render when any value changes. Split into focused contexts.

PerformanceState ManagementReact

Colocate State with the Components That Use It

MEDIUM

Lifting state higher than necessary causes unnecessary re-renders in the parent and all siblings. Keep state as close as possible to where it is consumed.

ArchitectureState Management

Eliminate Prop Drilling Through 3+ Component Levels

MEDIUM

Passing props through 3+ levels of intermediate components that don't use them creates tight coupling and maintenance burden. Use context, composition, or state management.

ArchitectureReact

Extract Duplicated Stateful Logic into Custom Hooks

MEDIUM

Duplicating stateful logic (useState + useEffect patterns) across multiple components leads to inconsistency and maintenance burden. Extract into reusable custom hooks.

ArchitectureReact

Prefer Composition Over Monolithic Conditional Rendering

MEDIUM

Monolithic components with deeply nested ternaries and conditionals are hard to read, test, and extend. Use composition patterns (children, render props, compound components).

Architecturecompound-components

Sanitize All HTML Before Using dangerouslySetInnerHTML

CRITICAL

dangerouslySetInnerHTML bypasses React's XSS protection. Always sanitize HTML from external sources with DOMPurify before rendering. [CWE-79 · A03:2021]

SecuritySanitizationnextjs

Never Build Database Queries with String Concatenation

CRITICAL

String concatenation in database queries creates injection vulnerabilities. Always use parameterized queries or ORM query builders. [CWE-89 · A03:2021]

Securitydrizzlenextjs

Validate All Server Action Inputs at the Boundary

CRITICAL

Server Action arguments are deserialized from untrusted HTTP requests. Validate every input with Zod to prevent type confusion and injection attacks. [CWE-20, CWE-502 · A08:2021]

Securitynextjsinput-validation

Authenticate Server Actions Like API Routes

CRITICAL

Server Actions are public HTTP endpoints not protected by middleware or layout guards. Always verify authentication inside each action. [CWE-862 · A01:2021]

Securitynextjsauthentication

Authenticate Route Handlers Like Server Actions

CRITICAL

App Router route handlers (GET, POST, PUT, DELETE) are public HTTP endpoints. Every exported function must independently verify auth — middleware alone is insufficient. [CWE-862 · A01:2021]

Securitynextjsauthentication

Implement Rate Limiting on Sensitive Endpoints

HIGH

Next.js has no built-in rate limiting. Without it, login, signup, password reset, and Server Actions are vulnerable to brute force and credential stuffing. [CWE-799, CWE-307 · A04:2021]

Securitynextjsauthentication

Prevent Path Traversal in API Routes and File Operations

CRITICAL

API routes that construct file paths from user input without sanitization allow attackers to read or write arbitrary files using ../ sequences. [CWE-22 · A01:2021]

Securitynextjspath-traversal

Validate All Redirect URLs

CRITICAL

Unvalidated redirect URLs enable phishing attacks via your domain. Always validate against an allowlist or restrict to relative paths. [CWE-601 · A01:2021]

Securitymiddlewarenextjs

Never Rely Solely on Middleware for Authorization

CRITICAL

Next.js middleware can be bypassed (CVE-2025-29927). Always enforce auth checks inside route handlers and Server Actions as defense-in-depth. [CWE-287 · A01:2021]

Securitymiddlewarenextjs

Set Secure Cookie Attributes (HttpOnly, Secure, SameSite)

HIGH

Session cookies without HttpOnly, Secure, and SameSite are vulnerable to XSS theft and CSRF. The Next.js cookies() API does not enforce secure defaults. [CWE-614, CWE-1004 · A05:2021]

Securitysessionnextjs
React
React
React
React
React
React
React
React
React
React
React
Context
React
architecture
React
React
React
Next.js
Next.js
Next.js
Next.js
Next.js
Next.js
Next.js
Next.js
Next.js
Next.js