Skip to content

Commit b6ce22a

Browse files
chore(COMPT-30): add changeset, update copilot-instructions, fix husky pre-commit
- .changeset/COMPT-30-state-storage-hooks.md: minor bump summary for 0.0.1 release - .github/instructions/copilot-instructions.md: updated to HooksKit package identity, real src structure with COMPT-30 hooks marked, COMPT-XX branch naming convention - .husky/pre-commit: removed deprecated husky v9 shebang lines (breaks in v10)
1 parent ec532f7 commit b6ce22a

3 files changed

Lines changed: 66 additions & 46 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
"@ciscode/reactts-developerkit": minor
3+
---
4+
5+
feat(COMPT-30): add state & storage hooks — useDebounce, useLocalStorage, useSessionStorage
6+
7+
First batch of production-ready hooks for HooksKit (epic COMPT-2).
8+
9+
**New hooks:**
10+
11+
- `useDebounce<T>(value, delay)` — returns debounced value; resets timer on value or delay change
12+
- `useLocalStorage<T>(key, initial)` — syncs with `localStorage`, SSR-safe, JSON serialization, parse-error fallback
13+
- `useSessionStorage<T>(key, initial)` — same pattern for `sessionStorage`
14+
15+
**Implementation details:**
16+
17+
- Shared `storage.ts` helper (`readStorageValue` / `writeStorageValue`) encapsulates SSR guard (`typeof window === 'undefined'`) and JSON parse fallback
18+
- Generics inferred at call site — no manual type params required
19+
- Zero runtime dependencies
20+
- `tsc --noEmit` passes, ESLint passes (0 warnings), 13/13 tests pass, coverage ≥ 91%
21+
- All three hooks exported from `src/index.ts`

.github/instructions/copilot-instructions.md

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,61 @@
1-
# Copilot Instructions - React Component Library
1+
# Copilot Instructions - HooksKit
22

3-
> **Purpose**: Development guidelines for React component libraries - reusable, well-structured components for modern apps.
3+
> **Purpose**: Development guidelines for HooksKit — production-ready React hooks with zero runtime deps.
44
55
---
66

77
## 🎯 Module Overview
88

9-
**Package**: `@ciscode/ui-components` (example)
10-
**Type**: React Component Library
9+
**Package**: `@ciscode/reactts-developerkit`
10+
**Epic**: COMPT-2 — HooksKit
11+
**Type**: React Hooks Library
1112
**Framework**: React 18+, TypeScript 5+
12-
**Build**: Vite/tsup
13+
**Build**: tsup
1314
**Testing**: Vitest + React Testing Library
1415
**Distribution**: NPM package
15-
**Purpose**: Reusable, production-ready React components for building modern UIs
16+
**Purpose**: 12 production-ready React hooks. Zero runtime deps. SSR-safe.
1617

17-
### Typical Module Responsibilities:
18+
### Hook Groups:
1819

19-
- Atomic UI components (Button, Input, Card, etc.)
20-
- Composite components (Form, Modal, Navigation, etc.)
21-
- Hooks for common patterns
22-
- Type definitions and props interfaces
23-
- Accessibility compliance (WCAG 2.1 AA)
24-
- Theming and customization
25-
- Comprehensive documentation
20+
- **State & Storage**`useDebounce`, `useLocalStorage`, `useSessionStorage`
21+
- **DOM & Events**_(upcoming)_
22+
- **Async & Lifecycle**_(upcoming)_
23+
24+
### Module Responsibilities:
25+
26+
- Generic, fully-typed hooks with inference at call site
27+
- SSR-safe (all `window`/`document` access guarded with `typeof window === 'undefined'`)
28+
- JSON serialization for storage hooks (parse-error fallback to initial value)
29+
- Zero runtime dependencies
30+
- WCAG-accessible patterns where applicable
31+
- Comprehensive tests (hooks ≥ 90% coverage)
2632

2733
---
2834

2935
## 🏗️ Module Structure
3036

3137
```
3238
src/
33-
├── components/ # React components
34-
│ ├── Button/
35-
│ │ ├── Button.tsx # Component
36-
│ │ ├── Button.test.tsx # Tests
37-
│ │ ├── Button.types.ts # Props types
38-
│ │ └── index.ts # Exports
39-
│ ├── Input/
40-
│ ├── Modal/
41-
│ └── Form/
42-
├── hooks/ # Custom hooks
43-
│ ├── useModal.ts
44-
│ ├── useForm.ts
45-
│ └── useModal.test.ts
46-
├── context/ # Context providers
47-
│ ├── ThemeContext.tsx
48-
│ └── FormContext.tsx
49-
├── types/ # TypeScript types
50-
│ └── common.types.ts
51-
├── utils/ # Utilities
52-
│ └── classNameUtils.ts
53-
└── index.ts # Public API
39+
├── components/ # Minimal supporting components
40+
│ ├── NoopButton.tsx
41+
│ └── index.ts
42+
├── hooks/ # All public hooks
43+
│ ├── storage.ts # Internal SSR-safe storage helpers
44+
│ ├── useDebounce.ts # COMPT-30 ✅
45+
│ ├── useDebounce.test.ts
46+
│ ├── useLocalStorage.ts # COMPT-30 ✅
47+
│ ├── useLocalStorage.test.ts
48+
│ ├── useSessionStorage.ts # COMPT-30 ✅
49+
│ ├── useSessionStorage.test.ts
50+
│ └── index.ts # Hook barrel
51+
├── utils/ # Framework-agnostic utils
52+
│ ├── noop.ts
53+
│ └── index.ts
54+
└── index.ts # Public API (only entry point)
5455
```
5556

57+
> ⚠️ Only export from `src/index.ts`. Deep imports are forbidden.
58+
5659
---
5760

5861
## 📝 Naming Conventions
@@ -277,18 +280,17 @@ export type { ButtonProps, ModalProps, InputProps, FormProps } from './component
277280
**1. Branch Creation:**
278281

279282
```bash
280-
feature/UI-MODULE-123-add-datepicker
281-
bugfix/UI-MODULE-456-fix-modal-focus
282-
refactor/UI-MODULE-789-extract-button-styles
283+
feat/COMPT-30-state-storage-hooks
284+
bugfix/COMPT-XX-short-description
283285
```
284286

285-
**2. Task Documentation:**
287+
> Branch names must reference the Jira ticket (COMPT-XX format). Pull from `develop` before opening PR.
286288
287-
Create task file:
289+
**PR targets:**
288290

289-
```
290-
docs/tasks/active/UI-MODULE-123-add-datepicker.md
291-
```
291+
- Feature branches → `develop`
292+
- `develop``master` on Friday release only
293+
- Never open a PR directly to `master`
292294

293295
**Task structure:**
294296

.husky/pre-commit

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/usr/bin/env sh
2-
. "$(dirname -- "$0")/_/husky.sh"
3-
41
npx lint-staged

0 commit comments

Comments
 (0)