Skip to content

Commit 0087507

Browse files
committed
fix: improve cross-tool AI config accuracy and consistency
- Fix import extensions: .js → .ts/.tsx (tsup converts for ESM) - Fix renderHookSSR import path to match actual codebase - Add mobile test filename distinction (.spec.ts vs .test.ts) - Add missing rules: strict boolean checks, cleanup, zero deps, performance patterns, CLI commands
1 parent ddd057a commit 0087507

3 files changed

Lines changed: 42 additions & 7 deletions

File tree

.cursorrules

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ Mobile depends on core. Core must NOT depend on mobile.
1515
- Named functions in useEffect: `useEffect(function handleResize() { ... }, [])`
1616
- Named exports only, no default exports
1717
- No `any` — strict TypeScript
18-
- `.js` extensions in relative imports
18+
- `.ts`/`.tsx` extensions in source imports (tsup converts to `.js`)
19+
- Strict boolean checks: `value !== undefined` not `if (value)`
1920
- Zero runtime dependencies
21+
- Always return cleanup in useEffect to remove listeners
2022

2123
## SSR-Safe Pattern
2224

@@ -44,13 +46,27 @@ useEffect(function syncBrowserState() {
4446

4547
Each hook in own folder: `src/hooks/useHookName/`
4648

47-
- `index.ts`, `useHookName.ts`, `useHookName.spec.ts`, `useHookName.ssr.test.ts`
49+
- `index.ts`, `useHookName.ts`, `useHookName.spec.ts` (core) / `.test.ts` (mobile), `useHookName.ssr.test.ts`
4850
- Docs: `useHookName.md` + `ko/useHookName.md`
4951

5052
## JSDoc
5153

5254
Required tags: `@description`, `@param`, `@returns`, `@example`
5355

56+
## Performance
57+
58+
- Throttle subscriptions at ~16ms (60fps)
59+
- Use `startTransition` for non-urgent state updates
60+
61+
## Commands
62+
63+
```bash
64+
yarn build # Build all (tsup)
65+
yarn test # Run tests (Vitest)
66+
yarn fix # Auto-fix lint + format
67+
yarn typecheck # Type check (tsc --noEmit)
68+
```
69+
5470
## Commits
5571

5672
Format: `<type>(<scope>): <description>`

.github/copilot-instructions.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
- Named functions in useEffect: `useEffect(function handleResize() { ... }, [])`
1313
- No default exports — named exports only
1414
- No `any` types — strict TypeScript
15-
- Include `.js` in relative imports for ESM
15+
- Use `.ts`/`.tsx` extensions in source imports (tsup converts to `.js`)
16+
- Strict boolean checks: `value !== undefined` not `if (value)`
17+
- Zero runtime dependencies
18+
- Always return cleanup in useEffect to remove listeners
1619

1720
## SSR-Safe Pattern (CRITICAL)
1821

@@ -39,7 +42,7 @@ Never call browser APIs during state initialization.
3942
- 100% coverage required (Vitest)
4043
- SSR test required for browser API hooks:
4144
```ts
42-
import { renderHookSSR } from '../utils/renderHookSSR';
45+
import { renderHookSSR } from '../../_internal/test-utils/renderHookSSR.tsx';
4346
it('is safe on server side rendering', () => {
4447
const result = renderHookSSR.serverOnly(() => useHookName());
4548
expect(result.current).toBeDefined();
@@ -68,8 +71,17 @@ Every public API requires:
6871
src/hooks/useHookName/
6972
├── index.ts # Re-export
7073
├── useHookName.ts # Implementation
71-
├── useHookName.spec.ts # Tests
74+
├── useHookName.spec.ts # Tests (core) / useHookName.test.ts (mobile)
7275
├── useHookName.ssr.test.ts # SSR tests
7376
├── useHookName.md # English docs
7477
└── ko/useHookName.md # Korean docs
7578
```
79+
80+
## Commands
81+
82+
```bash
83+
yarn build # Build all packages (tsup)
84+
yarn test # Run tests (Vitest)
85+
yarn fix # Auto-fix lint + format
86+
yarn typecheck # Type check (tsc --noEmit)
87+
```

AGENTS.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ src/hooks/useHookName/
4343
- **`type` over `interface`** — Always use `type` for type aliases
4444
- **Named functions in useEffect**`useEffect(function handleResize() { ... }, [])` not arrow functions
4545
- **Strict boolean checks**`value !== undefined` not `if (value)`
46-
- **Import extensions**Include `.js` in relative imports for ESM compliance
46+
- **Import extensions**Use `.ts`/`.tsx` extensions in source imports (tsup converts to `.js` for ESM output)
4747
- **Named exports only** — No default exports
4848
- **No `any` types** — Full TypeScript strict mode
4949
- **Zero runtime dependencies**
@@ -72,15 +72,22 @@ Never initialize state with browser API calls (causes hydration mismatch).
7272

7373
- **100% coverage mandatory** — Enforced by Vitest coverage threshold
7474
- **SSR tests required** — All hooks accessing browser APIs need `.ssr.test.ts`
75+
- **useEffect cleanup** — Always return cleanup in useEffect to remove listeners
7576
- **SSR test pattern**:
7677
```ts
77-
import { renderHookSSR } from '../utils/renderHookSSR';
78+
import { renderHookSSR } from '../../_internal/test-utils/renderHookSSR.tsx';
7879
it('is safe on server side rendering', () => {
7980
const result = renderHookSSR.serverOnly(() => useHookName());
8081
expect(result.current).toBeDefined();
8182
});
8283
```
8384

85+
### Performance Patterns
86+
87+
- Throttle subscriptions at ~16ms (60fps)
88+
- Deduplicate to skip unchanged updates
89+
- Use `startTransition` for non-urgent state updates (React 18+)
90+
8491
## Documentation
8592

8693
- **Bilingual**: English + Korean (co-located in hook folders)

0 commit comments

Comments
 (0)