Guardrails for
AI-written React

Jawad SefianiReact Osaka 2026

Guide it. Then verify it.

Verification has many layers: static linting, tests, type checks, and feedback loops. This talk focuses on the power of static lint rules — fast, cheap, and always on. Testing is the natural next step.

ESLint config

Flat config from the talk. 4 layers: React Compiler, modern React rules, "You Might Not Need an Effect", and check-the-checker.

eslint.config.js
// ESLint 10 flat config from the talk.
import { defineConfig } from 'eslint/config'
import tseslint from 'typescript-eslint'
import reactHooks from 'eslint-plugin-react-hooks'
import eslintReact from '@eslint-react/eslint-plugin'
import noEffect from 'eslint-plugin-react-you-might-not-need-an-effect'
import comments from '@eslint-community/eslint-plugin-eslint-comments/configs'

export default defineConfig({
  files: ['src/**/*.{ts,tsx}'],
  languageOptions: { parserOptions: { projectService: true } },
  extends: [
    tseslint.configs.base,
    reactHooks.configs.flat.recommended,
    eslintReact.configs['recommended-type-checked'],
    noEffect.configs.recommended,
    comments.recommended,
  ],
  rules: {
    '@eslint-community/eslint-comments/require-description': 'error',
    '@eslint-community/eslint-comments/no-restricted-disable': ['error', 'react-hooks/*'],
    '@typescript-eslint/no-explicit-any': 'error',
    '@typescript-eslint/ban-ts-comment': 'error',
  },
})
eslint-plugin-react-hooks ^7 @eslint-react/eslint-plugin ^5 eslint-plugin-react-you-might-not-need-an-effect @eslint-community/eslint-plugin-eslint-comments typescript-eslint

Agent prompt

Drop these two files into your project. The agent reads the map first, then opens the rules when it touches React code.

AGENTS.md
# Read the doc for what you touch
- docs/agents/react.md — refs, effects, memo
- docs/agents/data.md — queries, cache keys
- docs/agents/lint.md — rules, disables need a WHY
- docs/agents/testing.md — what to test, how

# Done means
pnpm lint && pnpm typecheck && pnpm test
docs/agents/react.md
# React

- The URL is the source of truth for shareable state.
  Never copy it into useState.
- Events go in event handlers, not in effects.
- Fetch with TanStack Query.
  Never fetch in an effect without cleanup.
- Derive values during render.
  Never use effect + setState for derived values.
- Reset state with a `key`, not an effect.

Resources