-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/compt 31 dom event hooks #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1cce5b0
f850005
852ae0c
c4172f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| --- | ||
| "@ciscode/hooks-kit": minor | ||
| --- | ||
|
|
||
| feat(COMPT-31): add DOM & event hooks — useMediaQuery, useWindowSize, useClickOutside, useIntersectionObserver | ||
|
|
||
| Second batch of production-ready hooks for HooksKit (epic COMPT-2). | ||
|
|
||
| **New hooks:** | ||
|
|
||
| - `useMediaQuery(query)` — tracks `matchMedia`, updates on change via `useSyncExternalStore`, SSR-safe (server snapshot returns `false`) | ||
| - `useWindowSize()` — returns `{ width, height }`, debounced 100ms on resize, SSR-safe (returns `{ 0, 0 }`) | ||
| - `useClickOutside(ref, handler)` — fires on `mousedown` or `touchstart` outside ref element, handler updated via ref pattern to avoid stale closures | ||
| - `useIntersectionObserver(ref, options?)` — returns latest `IntersectionObserverEntry | null`, disconnects observer on unmount | ||
|
|
||
| **Implementation details:** | ||
|
|
||
| - All listeners registered in `useEffect` and removed in cleanup return | ||
| - All SSR-safe: `typeof window === 'undefined'` guards in every hook | ||
| - `useMediaQuery` uses `useSyncExternalStore` (React 18) — no `setState` in effects | ||
| - Zero runtime dependencies | ||
| - `tsc --noEmit` passes, ESLint passes (0 warnings), 26/26 tests pass, coverage ≥ 95% | ||
| - All four hooks exported from `src/index.ts` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: npm | ||
| directory: "/" | ||
| schedule: | ||
| interval: monthly | ||
| open-pull-requests-limit: 1 | ||
| groups: | ||
| npm-dependencies: | ||
| patterns: | ||
| - "*" | ||
| assignees: | ||
| - CISCODE-MA/cloud-devops | ||
| labels: | ||
| - "dependencies" | ||
| - "npm" | ||
| commit-message: | ||
| prefix: "chore(deps)" | ||
| include: "scope" | ||
| rebase-strategy: auto |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| name: CI - PR Validation | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [develop] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| validate: | ||
| name: CI - PR Validation | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 | ||
| cache: npm | ||
|
|
||
| - name: Install | ||
| run: npm ci | ||
|
|
||
| - name: Format (check) | ||
| run: npm run format | ||
|
|
||
| - name: Lint | ||
| run: npm run lint | ||
|
|
||
| - name: Typecheck | ||
| run: npm run typecheck | ||
|
|
||
| - name: Test | ||
| run: npm test | ||
|
|
||
| - name: Build | ||
| run: npm run build |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,16 +3,6 @@ name: CI - Release Check | |||||||
| on: | ||||||||
| pull_request: | ||||||||
| branches: [master] | ||||||||
| workflow_dispatch: | ||||||||
| inputs: | ||||||||
| sonar: | ||||||||
| description: 'Run SonarCloud analysis' | ||||||||
| required: true | ||||||||
| default: 'false' | ||||||||
| type: choice | ||||||||
| options: | ||||||||
| - 'false' | ||||||||
| - 'true' | ||||||||
|
|
||||||||
| concurrency: | ||||||||
| group: ci-release-${{ github.ref }} | ||||||||
|
|
@@ -27,30 +17,25 @@ jobs: | |||||||
| permissions: | ||||||||
| contents: read | ||||||||
|
|
||||||||
| # Update these values for your package: | ||||||||
| # - SONAR_PROJECT_KEY: "CISCODE-MA_YourPackageName" | ||||||||
| env: | ||||||||
| SONAR_HOST_URL: 'https://sonarcloud.io' | ||||||||
| SONAR_ORGANIZATION: 'ciscode' | ||||||||
| SONAR_PROJECT_KEY: 'CISCODE-MA_PACKAGE_NAME_TEMPLATE' | ||||||||
| SONAR_HOST_URL: "https://sonarcloud.io" | ||||||||
| SONAR_ORGANIZATION: "ciscode" | ||||||||
| SONAR_PROJECT_KEY: "CISCODE-MA_HooksKit" | ||||||||
|
|
||||||||
| steps: | ||||||||
| - name: Checkout | ||||||||
| uses: actions/checkout@v4 | ||||||||
| uses: actions/checkout@v6 | ||||||||
|
||||||||
| uses: actions/checkout@v6 | |
| uses: actions/checkout@v4 |
Copilot
AI
Mar 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SonarCloud steps run unconditionally on pull_request. For PRs from forks, secrets.SONAR_TOKEN is not available, so the workflow will fail. Consider gating these steps (e.g., if: github.event.pull_request.head.repo.fork == false) or using a safe alternative like pull_request_target with appropriate hardening.
Copilot
AI
Mar 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-Dsonar.tests=test points to a directory that doesn’t exist in this repo (tests live under src/). This will cause Sonar to miss tests / miscompute coverage. Update sonar.tests (and optionally sonar.test.inclusions) to match the actual test locations.
| -Dsonar.tests=test | |
| -Dsonar.tests=src | |
| -Dsonar.test.inclusions=src/**/*.test.*,src/**/*.spec.* |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,4 +1,8 @@ | ||||||
| // Example placeholder export — replace with real hooks later. | ||||||
| export const __hooks_placeholder = true; | ||||||
|
|
||||||
|
Comment on lines
1
to
3
|
||||||
| // Example placeholder export — replace with real hooks later. | |
| export const __hooks_placeholder = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The publish gate only checks that tag
v${package.json version}exists somewhere in the repo (git rev-parse), not that it points to the commit being published. This can allow publishing from an untagged commit or reusing an old tag whenpackage.jsonwasn’t bumped, leading to failed or incorrect publishes. Validate thatTAGis an exact match onHEAD(e.g.,git describe --exact-match --tags HEADequalsTAG) before proceeding.