Skip to content

Commit bb6f757

Browse files
Rel1cxclaude
andcommitted
docs: add CLAUDE.md for Claude Code guidance
Add CLAUDE.md file to provide guidance to Claude Code when working in this repository. Includes: - Project overview and architecture - Common development commands - Monorepo structure explanation - Rule structure and implementation patterns - Testing patterns and key dependencies Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 5e15fba commit bb6f757

1 file changed

Lines changed: 164 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
ESLint React is a high-performance ESLint plugin for React (4-7x faster than alternatives). It provides composable ESLint rules for React and related libraries. It's a monorepo with multiple specialized ESLint plugins that can be used individually or as a unified plugin.
8+
9+
## Build System
10+
11+
- **Package Manager**: pnpm (v10.28.2)
12+
- **Build Tool**: tsdown - TypeScript to JavaScript bundler
13+
- **Formatter**: dprint
14+
- **Test Runner**: vitest
15+
- **TypeScript**: v5.9.3 with strict configuration
16+
17+
## Common Commands
18+
19+
```bash
20+
# Build all packages (must be run before tests/linting)
21+
pnpm run build
22+
23+
# Run all tests
24+
pnpm run test
25+
26+
# Run a single test file
27+
pnpm vitest packages/plugins/eslint-plugin-react-x/src/rules/no-missing-key.spec.ts
28+
29+
# Run all linting checks
30+
pnpm run lint
31+
32+
# Run specific lint checks
33+
pnpm run lint:es # ESLint
34+
pnpm run lint:ts # TypeScript type checking
35+
pnpm run lint:deps # Dependency analysis with skott
36+
pnpm run lint:publish # Package linting with publint
37+
38+
# Format code
39+
pnpm run format:write
40+
41+
# Update generated files (versions, READMEs, website docs)
42+
pnpm run update:all
43+
```
44+
45+
## Monorepo Structure
46+
47+
### Packages (`/packages/`)
48+
49+
**Core packages:**
50+
- `@eslint-react/core` - Core ESLint utility module for static analysis of React core APIs
51+
- `@eslint-react/shared` - Shared constants, types, and functions
52+
53+
**Plugin packages** (`/packages/plugins/`):
54+
- `eslint-plugin` - Unified plugin combining all individual plugins
55+
- `eslint-plugin-react-x` - Core React rules (renderer-agnostic)
56+
- `eslint-plugin-react-dom` - DOM-specific rules
57+
- `eslint-plugin-react-web-api` - Web API interaction rules
58+
- `eslint-plugin-react-hooks-extra` - Additional React Hooks rules
59+
- `eslint-plugin-react-naming-convention` - Naming convention rules
60+
- `eslint-plugin-react-debug` - Debug utilities
61+
62+
**Utility packages** (`/packages/utilities/`):
63+
- `@eslint-react/ast` - AST manipulation utilities
64+
- `@eslint-react/eff` - Effect/functional programming utilities
65+
- `@eslint-react/var` - Variable analysis utilities
66+
67+
### Local Packages (`/.pkgs/`)
68+
69+
Private workspace packages:
70+
- `@local/configs` - Shared ESLint and TypeScript configurations
71+
- `@local/function-rules` - Custom function-based lint rules
72+
73+
### Applications (`/apps/`)
74+
75+
- `website` - Documentation website built with Next.js and Fumadocs
76+
77+
### Examples (`/examples/`)
78+
79+
Example projects showing integrations with Next.js, React DOM, and various parsers.
80+
81+
## Rule Structure
82+
83+
Each ESLint rule follows this structure:
84+
85+
```
86+
packages/plugins/[plugin-name]/src/rules/
87+
├── rule-name.ts # Rule implementation
88+
├── rule-name.spec.ts # Test file
89+
└── rule-name.mdx # Documentation
90+
```
91+
92+
### Rule Implementation Pattern
93+
94+
Rules are created using `createRule` from `@typescript-eslint/utils`:
95+
96+
```typescript
97+
import { createRule } from "../utils";
98+
99+
export const RULE_NAME = "rule-name";
100+
export const RULE_FEATURES = [] as const satisfies RuleFeature[];
101+
export type MessageID = "messageId";
102+
103+
export default createRule<[], MessageID>({
104+
meta: {
105+
type: "problem",
106+
docs: { description: "..." },
107+
messages: { messageId: "Error message" },
108+
schema: [],
109+
},
110+
name: RULE_NAME,
111+
create,
112+
defaultOptions: [],
113+
});
114+
115+
export function create(ctx: RuleContext<MessageID, []>): RuleListener {
116+
return {
117+
// AST visitors
118+
};
119+
}
120+
```
121+
122+
### Testing Pattern
123+
124+
Tests use the TypeScript ESLint Rule Tester with vitest:
125+
126+
```typescript
127+
import { ruleTester } from "../../../../../test";
128+
import rule, { RULE_NAME } from "./rule-name";
129+
130+
ruleTester.run(RULE_NAME, rule, {
131+
invalid: [{ code: "...", errors: [{ messageId: "..." }] }],
132+
valid: ["..."],
133+
});
134+
```
135+
136+
Use `ruleTesterWithTypes` for type-aware rules. Import test helpers from `/test`:
137+
138+
```typescript
139+
import { allValid, ruleTester, ruleTesterWithTypes } from "../../../../../test";
140+
```
141+
142+
## Key Dependencies
143+
144+
- `@typescript-eslint/*` - TypeScript ESLint integration
145+
- `effect` - Functional programming library used throughout
146+
- `ts-pattern` - Pattern matching library
147+
- `tsdown` - TypeScript bundler for building packages
148+
149+
## Adding a New Rule
150+
151+
1. Create the rule file in the appropriate plugin's `src/rules/` directory
152+
2. Create the corresponding `.spec.ts` test file
153+
3. Export the rule in the plugin's `src/plugin.ts` entry file
154+
4. Add documentation as `.mdx` file with the same name
155+
5. Update preset configurations if the rule should be enabled by default
156+
6. Update the unified plugin to include the new rule
157+
7. Run `pnpm run build` and `pnpm run test`
158+
159+
## Architecture Notes
160+
161+
- Rules use the `@eslint-react/core` package for React-specific analysis (component detection, hook analysis, JSX analysis)
162+
- The `@eslint-react/shared` package provides common types, settings, and reporting utilities
163+
- The `effect` library is used for functional programming patterns
164+
- Each plugin is independently publishable but the unified plugin (`@eslint-react/eslint-plugin`) combines them all

0 commit comments

Comments
 (0)