metacoding 1.5.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/README.md +108 -514
- package/lib/cli.d.ts.map +1 -1
- package/lib/cli.js +18 -19
- package/lib/cli.js.map +1 -1
- package/lib/commands/init.d.ts +8 -14
- package/lib/commands/init.d.ts.map +1 -1
- package/lib/commands/init.js +105 -387
- package/lib/commands/init.js.map +1 -1
- package/lib/commands/update.d.ts +9 -9
- package/lib/commands/update.d.ts.map +1 -1
- package/lib/commands/update.js +141 -320
- package/lib/commands/update.js.map +1 -1
- package/lib/services/backup.d.ts +1 -1
- package/lib/services/backup.d.ts.map +1 -1
- package/lib/services/backup.js +10 -6
- package/lib/services/backup.js.map +1 -1
- package/lib/services/filesystem.d.ts.map +1 -1
- package/lib/services/filesystem.js +11 -5
- package/lib/services/filesystem.js.map +1 -1
- package/lib/services/gitignore-manager.js +5 -5
- package/lib/services/gitignore-manager.js.map +1 -1
- package/lib/services/project-detector.d.ts +9 -8
- package/lib/services/project-detector.d.ts.map +1 -1
- package/lib/services/project-detector.js +79 -197
- package/lib/services/project-detector.js.map +1 -1
- package/lib/services/skill-manager.d.ts +23 -0
- package/lib/services/skill-manager.d.ts.map +1 -0
- package/lib/services/skill-manager.js +212 -0
- package/lib/services/skill-manager.js.map +1 -0
- package/lib/types/index.d.ts +5 -15
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +9 -17
- package/skills/metacoding-workflow/SKILL.md +52 -0
- package/skills/metacoding-workflow/agents/openai.yaml +4 -0
- package/skills/metacoding-workflow/assets/templates/changelog-entry.md +6 -0
- package/skills/metacoding-workflow/assets/templates/project-context.md +18 -0
- package/skills/metacoding-workflow/assets/templates/repeated-task-checklist.md +8 -0
- package/skills/metacoding-workflow/assets/templates/task-entry.md +9 -0
- package/skills/metacoding-workflow/assets/templates/test-plan.md +8 -0
- package/skills/metacoding-workflow/references/javascript.md +7 -0
- package/skills/metacoding-workflow/references/node.md +7 -0
- package/skills/metacoding-workflow/references/platform-adaptation.md +37 -0
- package/skills/metacoding-workflow/references/python.md +7 -0
- package/skills/metacoding-workflow/references/react.md +7 -0
- package/skills/metacoding-workflow/references/repository-organization.md +84 -0
- package/skills/metacoding-workflow/references/typescript.md +7 -0
- package/skills/metacoding-workflow/references/workflow-rules.md +54 -0
- package/skills/vendor-templates/claude-agent.md.template +41 -0
- package/lib/services/assistant-adapter.d.ts +0 -18
- package/lib/services/assistant-adapter.d.ts.map +0 -1
- package/lib/services/assistant-adapter.js +0 -246
- package/lib/services/assistant-adapter.js.map +0 -1
- package/lib/services/cursor.d.ts +0 -47
- package/lib/services/cursor.d.ts.map +0 -1
- package/lib/services/cursor.js +0 -314
- package/lib/services/cursor.js.map +0 -1
- package/lib/services/template-manager.d.ts +0 -23
- package/lib/services/template-manager.d.ts.map +0 -1
- package/lib/services/template-manager.js +0 -374
- package/lib/services/template-manager.js.map +0 -1
- package/lib/services/vscode.d.ts +0 -10
- package/lib/services/vscode.d.ts.map +0 -1
- package/lib/services/vscode.js +0 -108
- package/lib/services/vscode.js.map +0 -1
- package/templates/assistants/AGENTS.md +0 -203
- package/templates/assistants/CLAUDE.md +0 -156
- package/templates/assistants/GEMINI.md +0 -193
- package/templates/general/code-review.instructions.md +0 -265
- package/templates/general/copilot-instructions.md +0 -427
- package/templates/general/docs-update.instructions.md +0 -275
- package/templates/general/release.instructions.md +0 -242
- package/templates/general/template.json +0 -9
- package/templates/general/test-runner.instructions.md +0 -188
- package/templates/javascript/javascript.coding.instructions.md +0 -500
- package/templates/javascript/javascript.docs.instructions.md +0 -563
- package/templates/javascript/javascript.testing.instructions.md +0 -686
- package/templates/javascript/template.json +0 -36
- package/templates/node/nodejs.coding.instructions.md +0 -249
- package/templates/node/nodejs.docs.instructions.md +0 -261
- package/templates/node/nodejs.testing.instructions.md +0 -373
- package/templates/node/template.json +0 -23
- package/templates/python/python.coding.instructions.md +0 -338
- package/templates/python/python.docs.instructions.md +0 -1178
- package/templates/python/python.testing.instructions.md +0 -1073
- package/templates/python/template.json +0 -75
- package/templates/react/react.coding.instructions.md +0 -694
- package/templates/react/react.docs.instructions.md +0 -451
- package/templates/react/react.testing.instructions.md +0 -192
- package/templates/react/template.json +0 -14
- package/templates/react/test-runner.instructions.md +0 -135
- package/templates/typescript/template.json +0 -16
- package/templates/typescript/typescript.coding.instructions.md +0 -368
- package/templates/typescript/typescript.docs.instructions.md +0 -760
- package/templates/typescript/typescript.testing.instructions.md +0 -739
|
@@ -1,451 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: 'React-specific documentation standards and guidelines'
|
|
3
|
-
applyTo: '**/*.{jsx,tsx}'
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# React Documentation Standards
|
|
7
|
-
|
|
8
|
-
## Component Documentation Guidelines
|
|
9
|
-
|
|
10
|
-
### JSDoc for React Components
|
|
11
|
-
|
|
12
|
-
````typescript
|
|
13
|
-
/**
|
|
14
|
-
* A reusable button component with multiple variants and sizes.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```tsx
|
|
18
|
-
* <Button variant="primary" size="large" onClick={handleClick}>
|
|
19
|
-
* Click me
|
|
20
|
-
* </Button>
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @param props - The component props
|
|
24
|
-
* @param props.variant - The visual style variant
|
|
25
|
-
* @param props.size - The size of the button
|
|
26
|
-
* @param props.disabled - Whether the button is disabled
|
|
27
|
-
* @param props.children - The button content
|
|
28
|
-
* @param props.onClick - Click event handler
|
|
29
|
-
*/
|
|
30
|
-
export function Button({
|
|
31
|
-
variant = 'primary',
|
|
32
|
-
size = 'medium',
|
|
33
|
-
disabled = false,
|
|
34
|
-
children,
|
|
35
|
-
onClick,
|
|
36
|
-
}: ButtonProps) {
|
|
37
|
-
// Component implementation
|
|
38
|
-
}
|
|
39
|
-
````
|
|
40
|
-
|
|
41
|
-
### PropTypes and TypeScript Interfaces
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
/**
|
|
45
|
-
* Props for the Button component.
|
|
46
|
-
*/
|
|
47
|
-
export interface ButtonProps {
|
|
48
|
-
/** The visual style variant of the button */
|
|
49
|
-
variant?: 'primary' | 'secondary' | 'danger';
|
|
50
|
-
/** The size of the button */
|
|
51
|
-
size?: 'small' | 'medium' | 'large';
|
|
52
|
-
/** Whether the button is disabled */
|
|
53
|
-
disabled?: boolean;
|
|
54
|
-
/** The content to display inside the button */
|
|
55
|
-
children: React.ReactNode;
|
|
56
|
-
/** Click event handler */
|
|
57
|
-
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Component API Documentation
|
|
62
|
-
|
|
63
|
-
### Required Documentation Elements
|
|
64
|
-
|
|
65
|
-
1. **Purpose and Use Cases:** Clear description of what the component does
|
|
66
|
-
2. **Props Interface:** Complete TypeScript interface with descriptions
|
|
67
|
-
3. **Usage Examples:** Common usage patterns with code examples
|
|
68
|
-
4. **Accessibility Notes:** ARIA requirements and keyboard interactions
|
|
69
|
-
5. **Styling Information:** CSS classes, design tokens, theming support
|
|
70
|
-
6. **Dependencies:** Required peer dependencies or context providers
|
|
71
|
-
|
|
72
|
-
### Component README Template
|
|
73
|
-
|
|
74
|
-
````markdown
|
|
75
|
-
# ComponentName
|
|
76
|
-
|
|
77
|
-
Brief description of the component's purpose and primary use case.
|
|
78
|
-
|
|
79
|
-
## Usage
|
|
80
|
-
|
|
81
|
-
```tsx
|
|
82
|
-
import { ComponentName } from './ComponentName';
|
|
83
|
-
|
|
84
|
-
function Example() {
|
|
85
|
-
return (
|
|
86
|
-
<ComponentName prop1="value" prop2={variable} onAction={handleAction}>
|
|
87
|
-
Content
|
|
88
|
-
</ComponentName>
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
````
|
|
93
|
-
|
|
94
|
-
## Props
|
|
95
|
-
|
|
96
|
-
| Prop | Type | Default | Description |
|
|
97
|
-
| ----- | ------- | --------- | -------------------- |
|
|
98
|
-
| prop1 | string | 'default' | Description of prop1 |
|
|
99
|
-
| prop2 | boolean | false | Description of prop2 |
|
|
100
|
-
|
|
101
|
-
## Examples
|
|
102
|
-
|
|
103
|
-
### Basic Usage
|
|
104
|
-
|
|
105
|
-
[Code example]
|
|
106
|
-
|
|
107
|
-
### Advanced Usage
|
|
108
|
-
|
|
109
|
-
[Code example with complex props]
|
|
110
|
-
|
|
111
|
-
## Accessibility
|
|
112
|
-
|
|
113
|
-
- Keyboard navigation support
|
|
114
|
-
- Screen reader compatibility
|
|
115
|
-
- ARIA attributes used
|
|
116
|
-
|
|
117
|
-
## Styling
|
|
118
|
-
|
|
119
|
-
- CSS classes available
|
|
120
|
-
- Design tokens used
|
|
121
|
-
- Theming support
|
|
122
|
-
|
|
123
|
-
## Related Components
|
|
124
|
-
|
|
125
|
-
- List of related components
|
|
126
|
-
- When to use alternatives
|
|
127
|
-
|
|
128
|
-
````
|
|
129
|
-
|
|
130
|
-
## Hook Documentation
|
|
131
|
-
|
|
132
|
-
### Custom Hook Documentation
|
|
133
|
-
|
|
134
|
-
```typescript
|
|
135
|
-
/**
|
|
136
|
-
* A hook for managing form state with validation.
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* ```tsx
|
|
140
|
-
* function ContactForm() {
|
|
141
|
-
* const { values, errors, handleChange, handleSubmit } = useForm({
|
|
142
|
-
* initialValues: { email: '', message: '' },
|
|
143
|
-
* validation: {
|
|
144
|
-
* email: (value) => value.includes('@') ? null : 'Invalid email'
|
|
145
|
-
* }
|
|
146
|
-
* });
|
|
147
|
-
*
|
|
148
|
-
* return (
|
|
149
|
-
* <form onSubmit={handleSubmit}>
|
|
150
|
-
* <input
|
|
151
|
-
* value={values.email}
|
|
152
|
-
* onChange={handleChange('email')}
|
|
153
|
-
* aria-invalid={!!errors.email}
|
|
154
|
-
* />
|
|
155
|
-
* {errors.email && <span>{errors.email}</span>}
|
|
156
|
-
* </form>
|
|
157
|
-
* );
|
|
158
|
-
* }
|
|
159
|
-
* ```
|
|
160
|
-
*
|
|
161
|
-
* @param config - Hook configuration options
|
|
162
|
-
* @returns Form state and handlers
|
|
163
|
-
*/
|
|
164
|
-
export function useForm<T extends Record<string, any>>(
|
|
165
|
-
config: FormConfig<T>
|
|
166
|
-
): FormReturn<T> {
|
|
167
|
-
// Hook implementation
|
|
168
|
-
}
|
|
169
|
-
````
|
|
170
|
-
|
|
171
|
-
## Storybook Documentation
|
|
172
|
-
|
|
173
|
-
### Story Documentation Standards
|
|
174
|
-
|
|
175
|
-
```typescript
|
|
176
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
177
|
-
import { Button } from './Button';
|
|
178
|
-
|
|
179
|
-
const meta: Meta<typeof Button> = {
|
|
180
|
-
title: 'Components/Button',
|
|
181
|
-
component: Button,
|
|
182
|
-
parameters: {
|
|
183
|
-
docs: {
|
|
184
|
-
description: {
|
|
185
|
-
component:
|
|
186
|
-
'A versatile button component with multiple variants and sizes.',
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
argTypes: {
|
|
191
|
-
variant: {
|
|
192
|
-
control: 'select',
|
|
193
|
-
options: ['primary', 'secondary', 'danger'],
|
|
194
|
-
description: 'The visual style variant of the button',
|
|
195
|
-
},
|
|
196
|
-
size: {
|
|
197
|
-
control: 'select',
|
|
198
|
-
options: ['small', 'medium', 'large'],
|
|
199
|
-
description: 'The size of the button',
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
export default meta;
|
|
205
|
-
type Story = StoryObj<typeof meta>;
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* The default button style used for primary actions.
|
|
209
|
-
*/
|
|
210
|
-
export const Primary: Story = {
|
|
211
|
-
args: {
|
|
212
|
-
variant: 'primary',
|
|
213
|
-
children: 'Button',
|
|
214
|
-
},
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Secondary buttons for less prominent actions.
|
|
219
|
-
*/
|
|
220
|
-
export const Secondary: Story = {
|
|
221
|
-
args: {
|
|
222
|
-
variant: 'secondary',
|
|
223
|
-
children: 'Button',
|
|
224
|
-
},
|
|
225
|
-
};
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
## Architecture Documentation
|
|
229
|
-
|
|
230
|
-
### Component Architecture Docs
|
|
231
|
-
|
|
232
|
-
Document component relationships and data flow:
|
|
233
|
-
|
|
234
|
-
```markdown
|
|
235
|
-
# Component Architecture
|
|
236
|
-
|
|
237
|
-
## Component Hierarchy
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
App
|
|
241
|
-
├── Header
|
|
242
|
-
│ ├── Navigation
|
|
243
|
-
│ └── UserMenu
|
|
244
|
-
├── Main
|
|
245
|
-
│ ├── Sidebar
|
|
246
|
-
│ └── ContentArea
|
|
247
|
-
│ ├── FeatureComponent
|
|
248
|
-
│ └── DataDisplay
|
|
249
|
-
└── Footer
|
|
250
|
-
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
## Data Flow
|
|
254
|
-
|
|
255
|
-
1. **State Management:** Describe state management approach (Context, Redux, Zustand)
|
|
256
|
-
2. **Props Flow:** How data flows down through component tree
|
|
257
|
-
3. **Event Handling:** How events bubble up and are handled
|
|
258
|
-
4. **Side Effects:** API calls, external integrations
|
|
259
|
-
|
|
260
|
-
## Performance Considerations
|
|
261
|
-
|
|
262
|
-
- Component memoization strategies
|
|
263
|
-
- Bundle splitting points
|
|
264
|
-
- Lazy loading implementation
|
|
265
|
-
- Re-render optimization
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
## Design System Documentation
|
|
269
|
-
|
|
270
|
-
### Component Design Specs
|
|
271
|
-
|
|
272
|
-
```markdown
|
|
273
|
-
# Design System - Button Component
|
|
274
|
-
|
|
275
|
-
## Design Tokens
|
|
276
|
-
|
|
277
|
-
### Colors
|
|
278
|
-
|
|
279
|
-
- Primary: `--color-primary-500`
|
|
280
|
-
- Secondary: `--color-neutral-200`
|
|
281
|
-
- Danger: `--color-error-500`
|
|
282
|
-
|
|
283
|
-
### Typography
|
|
284
|
-
|
|
285
|
-
- Font: `--font-family-base`
|
|
286
|
-
- Size: `--font-size-md`
|
|
287
|
-
- Weight: `--font-weight-medium`
|
|
288
|
-
|
|
289
|
-
### Spacing
|
|
290
|
-
|
|
291
|
-
- Padding: `--space-3` `--space-4`
|
|
292
|
-
- Margin: `--space-2`
|
|
293
|
-
|
|
294
|
-
## Variants
|
|
295
|
-
|
|
296
|
-
### Primary Button
|
|
297
|
-
|
|
298
|
-
- Background: Primary color
|
|
299
|
-
- Text: White
|
|
300
|
-
- Border: None
|
|
301
|
-
- Shadow: `--shadow-sm`
|
|
302
|
-
|
|
303
|
-
### Secondary Button
|
|
304
|
-
|
|
305
|
-
- Background: Transparent
|
|
306
|
-
- Text: Primary color
|
|
307
|
-
- Border: 1px solid primary
|
|
308
|
-
- Shadow: None
|
|
309
|
-
|
|
310
|
-
## States
|
|
311
|
-
|
|
312
|
-
- **Default:** Base styling
|
|
313
|
-
- **Hover:** Darker background, `--shadow-md`
|
|
314
|
-
- **Active:** Pressed state with inset shadow
|
|
315
|
-
- **Disabled:** 50% opacity, no interactions
|
|
316
|
-
- **Focus:** Visible focus ring for accessibility
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
## API Integration Documentation
|
|
320
|
-
|
|
321
|
-
### Component API Integration
|
|
322
|
-
|
|
323
|
-
````typescript
|
|
324
|
-
/**
|
|
325
|
-
* A component that fetches and displays user data.
|
|
326
|
-
*
|
|
327
|
-
* @example
|
|
328
|
-
* ```tsx
|
|
329
|
-
* <UserProfile userId="123" />
|
|
330
|
-
* ```
|
|
331
|
-
*
|
|
332
|
-
* ## API Dependencies
|
|
333
|
-
*
|
|
334
|
-
* - **GET /api/users/:id** - Fetches user profile data
|
|
335
|
-
* - **PUT /api/users/:id** - Updates user profile
|
|
336
|
-
*
|
|
337
|
-
* ## Error Handling
|
|
338
|
-
*
|
|
339
|
-
* - Network errors: Shows retry button
|
|
340
|
-
* - 404 errors: Shows "User not found" message
|
|
341
|
-
* - 403 errors: Shows permission denied message
|
|
342
|
-
*
|
|
343
|
-
* ## Loading States
|
|
344
|
-
*
|
|
345
|
-
* - Initial load: Skeleton placeholder
|
|
346
|
-
* - Update: Spinner overlay
|
|
347
|
-
* - Background refresh: Subtle loading indicator
|
|
348
|
-
*/
|
|
349
|
-
export function UserProfile({ userId }: UserProfileProps) {
|
|
350
|
-
// Component implementation
|
|
351
|
-
}
|
|
352
|
-
````
|
|
353
|
-
|
|
354
|
-
## Testing Documentation Integration
|
|
355
|
-
|
|
356
|
-
### Component Test Documentation
|
|
357
|
-
|
|
358
|
-
```typescript
|
|
359
|
-
/**
|
|
360
|
-
* Tests for the Button component.
|
|
361
|
-
*
|
|
362
|
-
* @testcases
|
|
363
|
-
* - Renders with correct text content
|
|
364
|
-
* - Applies variant classes correctly
|
|
365
|
-
* - Handles click events properly
|
|
366
|
-
* - Shows disabled state appropriately
|
|
367
|
-
* - Meets accessibility requirements
|
|
368
|
-
* - Supports keyboard navigation
|
|
369
|
-
*/
|
|
370
|
-
describe('Button Component', () => {
|
|
371
|
-
// Test implementations
|
|
372
|
-
});
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
## Migration and Deprecation Docs
|
|
376
|
-
|
|
377
|
-
### Breaking Changes Documentation
|
|
378
|
-
|
|
379
|
-
````markdown
|
|
380
|
-
# Migration Guide: Button v2.0
|
|
381
|
-
|
|
382
|
-
## Breaking Changes
|
|
383
|
-
|
|
384
|
-
### Removed Props
|
|
385
|
-
|
|
386
|
-
- `type` prop removed - use `variant` instead
|
|
387
|
-
- `large` prop removed - use `size="large"` instead
|
|
388
|
-
|
|
389
|
-
### API Changes
|
|
390
|
-
|
|
391
|
-
- `onClick` now receives event object as first parameter
|
|
392
|
-
- `disabled` prop now affects aria-disabled attribute
|
|
393
|
-
|
|
394
|
-
## Migration Steps
|
|
395
|
-
|
|
396
|
-
1. Replace `type="primary"` with `variant="primary"`
|
|
397
|
-
2. Replace `large={true}` with `size="large"`
|
|
398
|
-
3. Update click handlers to accept event parameter
|
|
399
|
-
|
|
400
|
-
### Before
|
|
401
|
-
|
|
402
|
-
```tsx
|
|
403
|
-
<Button type="primary" large onClick={handleClick}>
|
|
404
|
-
Click me
|
|
405
|
-
</Button>
|
|
406
|
-
```
|
|
407
|
-
````
|
|
408
|
-
|
|
409
|
-
### After
|
|
410
|
-
|
|
411
|
-
```tsx
|
|
412
|
-
<Button variant="primary" size="large" onClick={(e) => handleClick(e)}>
|
|
413
|
-
Click me
|
|
414
|
-
</Button>
|
|
415
|
-
```
|
|
416
|
-
|
|
417
|
-
```
|
|
418
|
-
|
|
419
|
-
## Documentation Maintenance
|
|
420
|
-
|
|
421
|
-
- **Component Updates:** Update docs when component API changes
|
|
422
|
-
- **Example Accuracy:** Ensure all code examples are tested and working
|
|
423
|
-
- **Version Alignment:** Keep documentation in sync with component versions
|
|
424
|
-
- **Accessibility Updates:** Update accessibility docs when ARIA patterns change
|
|
425
|
-
- **Performance Notes:** Document performance implications of component usage
|
|
426
|
-
|
|
427
|
-
## Repeated React Documentation Tasks and Checklist Templates
|
|
428
|
-
|
|
429
|
-
For any recurring React documentation process (such as component library releases, API documentation updates, or component migration guides), always use a dedicated checklist template to ensure all necessary documentation steps are followed and nothing is missed.
|
|
430
|
-
|
|
431
|
-
- **React Documentation Checklist Template Principle:**
|
|
432
|
-
- Maintain a template checklist file for each repeated React documentation process (e.g., `component-release-docs-checklist.md`, `react-migration-docs-checklist.md`).
|
|
433
|
-
- For each new instance (e.g., each component release or migration), copy the template checklist and tag it with the relevant version or context, preserving the original template for future use.
|
|
434
|
-
- Systematically work through the checklist for every instance of the repeated documentation task, marking each step as completed.
|
|
435
|
-
- Proactively identify any React documentation process that would benefit from a checklist and prompt the user to use or create one if it does not exist.
|
|
436
|
-
- If, during execution, you or the user identify missing or unclear documentation steps, update the template checklist to improve future reliability.
|
|
437
|
-
|
|
438
|
-
**Examples of repeated React documentation tasks requiring checklists:**
|
|
439
|
-
- Component library releases (PropTypes updates, example verification, Storybook updates)
|
|
440
|
-
- React version migrations (hook migration guides, breaking changes documentation, compatibility notes)
|
|
441
|
-
- Performance optimization documentation (profiling results, optimization guides, benchmark updates)
|
|
442
|
-
- Accessibility documentation updates (ARIA pattern updates, keyboard navigation guides, screen reader testing)
|
|
443
|
-
- Testing documentation (test pattern updates, snapshot reviews, accessibility test updates)
|
|
444
|
-
- Any other React documentation process with multiple required steps or risk of omission
|
|
445
|
-
|
|
446
|
-
**Agent Guidance for React Documentation Tasks:**
|
|
447
|
-
- Always check for the existence of a React documentation checklist template before starting a repeated documentation task.
|
|
448
|
-
- If a template does not exist, prompt the user to create one and assist in drafting it.
|
|
449
|
-
- When using a documentation checklist, copy it for the specific instance (e.g., `component-release-v2.1.0.md`), and work through each step systematically.
|
|
450
|
-
- If new documentation steps are discovered or improvements are needed, update the template and inform the user.
|
|
451
|
-
```
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: 'React-specific testing guidelines and standards'
|
|
3
|
-
applyTo: 'test/**/*.{tsx,jsx,ts,js}'
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# React Testing Standards
|
|
7
|
-
|
|
8
|
-
## Test Case Naming Conventions
|
|
9
|
-
|
|
10
|
-
### Test Case ID Format: `[AREA]-[TYPE]-[NUMBER]`
|
|
11
|
-
|
|
12
|
-
**React/Frontend Area Prefixes:**
|
|
13
|
-
|
|
14
|
-
- `COMP` - React component tests
|
|
15
|
-
- `HOOK` - Custom hooks tests
|
|
16
|
-
- `PAGE` - Page/Route component tests
|
|
17
|
-
- `FORM` - Form validation and submission tests
|
|
18
|
-
- `UI` - UI interaction and behavior tests
|
|
19
|
-
- `STORE` - State management tests (Redux/Zustand/Context)
|
|
20
|
-
- `API` - Frontend API client tests
|
|
21
|
-
- `A11Y` - Accessibility compliance tests
|
|
22
|
-
- `PERF` - Performance and optimization tests
|
|
23
|
-
- `UTIL` - Frontend utility function tests
|
|
24
|
-
|
|
25
|
-
**Type Suffixes:**
|
|
26
|
-
|
|
27
|
-
- `UNIT` - Unit tests (isolated component testing)
|
|
28
|
-
- `INT` - Integration tests (component interaction testing)
|
|
29
|
-
- `E2E` - End-to-end tests (full user workflow testing)
|
|
30
|
-
|
|
31
|
-
**Examples:**
|
|
32
|
-
|
|
33
|
-
- `COMP-UNIT-001` - First unit test for React Component
|
|
34
|
-
- `HOOK-UNIT-001` - First unit test for Custom Hook
|
|
35
|
-
- `PAGE-E2E-001` - First end-to-end test for Page Component
|
|
36
|
-
- `FORM-INT-001` - First integration test for Form Component
|
|
37
|
-
|
|
38
|
-
## Testing Framework Stack
|
|
39
|
-
|
|
40
|
-
- **Primary Framework:** Jest with React Testing Library
|
|
41
|
-
- **Component Testing:** @testing-library/react for component behavior testing
|
|
42
|
-
- **User Interaction:** @testing-library/user-event for realistic user interactions
|
|
43
|
-
- **Mocking:** Jest built-in mocking for modules and dependencies
|
|
44
|
-
- **Snapshot Testing:** Use sparingly, prefer behavioral tests
|
|
45
|
-
|
|
46
|
-
## Component Testing Guidelines
|
|
47
|
-
|
|
48
|
-
### Test Structure
|
|
49
|
-
|
|
50
|
-
- **Arrange-Act-Assert:** Clear test structure with setup, action, and verification
|
|
51
|
-
- **Test Behavior, Not Implementation:** Focus on what the component does, not how
|
|
52
|
-
- **User-Centric Tests:** Test from the user's perspective using accessible queries
|
|
53
|
-
- **Isolation:** Each test should be independent and not rely on other tests
|
|
54
|
-
|
|
55
|
-
### Testing Patterns
|
|
56
|
-
|
|
57
|
-
```typescript
|
|
58
|
-
// Good: Testing behavior
|
|
59
|
-
test('displays error message when form submission fails', async () => {
|
|
60
|
-
render(<ContactForm onSubmit={jest.fn().mockRejectedValue(new Error())} />);
|
|
61
|
-
|
|
62
|
-
await user.click(screen.getByRole('button', { name: /submit/i }));
|
|
63
|
-
|
|
64
|
-
expect(screen.getByText(/error occurred/i)).toBeInTheDocument();
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// Bad: Testing implementation details
|
|
68
|
-
test('calls setState when button is clicked', () => {
|
|
69
|
-
const component = shallow(<MyComponent />);
|
|
70
|
-
component.find('button').simulate('click');
|
|
71
|
-
expect(component.state('clicked')).toBe(true);
|
|
72
|
-
});
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Query Priorities
|
|
76
|
-
|
|
77
|
-
1. **Accessible Queries (Preferred):**
|
|
78
|
-
|
|
79
|
-
- `getByRole()` - Primary choice for interactive elements
|
|
80
|
-
- `getByLabelText()` - Form inputs with labels
|
|
81
|
-
- `getByPlaceholderText()` - Form inputs with placeholders
|
|
82
|
-
- `getByText()` - Non-interactive text content
|
|
83
|
-
|
|
84
|
-
2. **Semantic Queries:**
|
|
85
|
-
|
|
86
|
-
- `getByAltText()` - Images with alt text
|
|
87
|
-
- `getByTitle()` - Elements with title attributes
|
|
88
|
-
|
|
89
|
-
3. **Test ID Queries (Last Resort):**
|
|
90
|
-
- `getByTestId()` - Only when semantic queries aren't sufficient
|
|
91
|
-
|
|
92
|
-
## React-Specific Testing Scenarios
|
|
93
|
-
|
|
94
|
-
### Component Lifecycle and State
|
|
95
|
-
|
|
96
|
-
- **State Changes:** Test state transitions triggered by user interactions
|
|
97
|
-
- **Effect Testing:** Verify useEffect behavior with proper cleanup
|
|
98
|
-
- **Context Testing:** Test components that consume React Context
|
|
99
|
-
- **Custom Hooks:** Test custom hooks in isolation using renderHook
|
|
100
|
-
|
|
101
|
-
### Async Operations
|
|
102
|
-
|
|
103
|
-
- **API Calls:** Mock API responses and test loading/success/error states
|
|
104
|
-
- **User Interactions:** Use waitFor() for async state updates
|
|
105
|
-
- **Suspense:** Test Suspense boundaries and fallback components
|
|
106
|
-
- **Error Boundaries:** Test error boundary behavior with error states
|
|
107
|
-
|
|
108
|
-
### Form Testing
|
|
109
|
-
|
|
110
|
-
- **Form Validation:** Test client-side validation messages
|
|
111
|
-
- **Form Submission:** Test successful and failed form submissions
|
|
112
|
-
- **Field Interactions:** Test input changes, selections, and clearing
|
|
113
|
-
- **Accessibility:** Ensure form labels and error associations work correctly
|
|
114
|
-
|
|
115
|
-
## Mock Strategies
|
|
116
|
-
|
|
117
|
-
### Component Mocking
|
|
118
|
-
|
|
119
|
-
```typescript
|
|
120
|
-
// Mock child components that aren't relevant to the test
|
|
121
|
-
jest.mock('./ComplexChild', () => {
|
|
122
|
-
return function MockedComplexChild({ title }: { title: string }) {
|
|
123
|
-
return <div data-testid="mocked-complex-child">{title}</div>;
|
|
124
|
-
};
|
|
125
|
-
});
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
### API Mocking
|
|
129
|
-
|
|
130
|
-
```typescript
|
|
131
|
-
// Use MSW (Mock Service Worker) for API mocking
|
|
132
|
-
import { rest } from 'msw';
|
|
133
|
-
import { setupServer } from 'msw/node';
|
|
134
|
-
|
|
135
|
-
const server = setupServer(
|
|
136
|
-
rest.get('/api/users', (req, res, ctx) => {
|
|
137
|
-
return res(ctx.json([{ id: 1, name: 'John Doe' }]));
|
|
138
|
-
})
|
|
139
|
-
);
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
## Performance Testing
|
|
143
|
-
|
|
144
|
-
- **Render Performance:** Use React DevTools Profiler for performance testing
|
|
145
|
-
- **Memory Leaks:** Test component cleanup and event listener removal
|
|
146
|
-
- **Large Lists:** Test virtualization and pagination performance
|
|
147
|
-
- **Bundle Size:** Monitor component bundle impact with bundler analysis
|
|
148
|
-
|
|
149
|
-
## Testing File Organization
|
|
150
|
-
|
|
151
|
-
```
|
|
152
|
-
/test
|
|
153
|
-
/components
|
|
154
|
-
/common # Reusable component tests
|
|
155
|
-
/pages # Page component tests
|
|
156
|
-
/forms # Form component tests
|
|
157
|
-
/hooks # Custom hook tests
|
|
158
|
-
/utils # Utility function tests
|
|
159
|
-
/fixtures
|
|
160
|
-
/api-responses # Mock API response data
|
|
161
|
-
/component-props # Common component prop fixtures
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
## React Testing Anti-Patterns
|
|
165
|
-
|
|
166
|
-
- **Avoid Shallow Rendering:** Use full rendering with React Testing Library
|
|
167
|
-
- **Don't Test Implementation Details:** Focus on user-observable behavior
|
|
168
|
-
- **Avoid Snapshot Testing Everything:** Use snapshots sparingly for stable UI
|
|
169
|
-
- **Don't Mock React Itself:** Mock external dependencies, not React features
|
|
170
|
-
- **Avoid Testing Library Internals:** Don't test useState, useEffect directly
|
|
171
|
-
|
|
172
|
-
## Accessibility Testing
|
|
173
|
-
|
|
174
|
-
- **Screen Reader Testing:** Ensure components work with assistive technology
|
|
175
|
-
- **Keyboard Navigation:** Test keyboard-only navigation patterns
|
|
176
|
-
- **ARIA Attributes:** Verify proper ARIA labels and roles
|
|
177
|
-
- **Color Contrast:** Test component readability across different themes
|
|
178
|
-
- **Focus Management:** Test focus trapping and restoration in modals/dialogs
|
|
179
|
-
|
|
180
|
-
## Test Data Management
|
|
181
|
-
|
|
182
|
-
- **Factory Functions:** Create reusable test data generators
|
|
183
|
-
- **Realistic Data:** Use realistic data that matches production scenarios
|
|
184
|
-
- **Edge Cases:** Test with empty states, long text, special characters
|
|
185
|
-
- **Internationalization:** Test with different locales and text lengths
|
|
186
|
-
|
|
187
|
-
## CI/CD Integration
|
|
188
|
-
|
|
189
|
-
- **Visual Regression:** Use tools like Chromatic for visual testing
|
|
190
|
-
- **Cross-Browser Testing:** Test across different browsers and devices
|
|
191
|
-
- **Performance Budgets:** Set performance thresholds for components
|
|
192
|
-
- **Bundle Analysis:** Monitor bundle size impact of new components
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "react",
|
|
3
|
-
"description": "React frontend development template with modern patterns and best practices",
|
|
4
|
-
"prompts": [],
|
|
5
|
-
"vscodeSettings": {
|
|
6
|
-
"github.copilot.chat.codeGeneration.useInstructionFiles": true,
|
|
7
|
-
"chat.promptFiles": true,
|
|
8
|
-
"editor.formatOnSave": true,
|
|
9
|
-
"editor.codeActionsOnSave": {
|
|
10
|
-
"source.organizeImports": true,
|
|
11
|
-
"source.fixAll.eslint": true
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|