Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit af8e45a

Browse files
authored
Merge pull request #39 from pyreon/fix-audit-findings
Fix audit findings from rules review
2 parents a47b883 + bdc3156 commit af8e45a

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

.claude/rules/architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
- Each `@pyreon/zero` subpath export (`./link`, `./cache`, etc.) must have a matching entry in `packages/zero/package.json` exports map with `bun`, `import`, and `types` conditions
44
- Shared utilities go in `packages/zero/src/utils/` — only extract when used by 2+ files
55
- Vite plugins follow the pattern: `export function pluginName(config = {}): Plugin`
6-
- Middleware uses the `(request, next) => Promise<Response>` signature from `@pyreon/server`
6+
- Middleware uses the `(ctx: MiddlewareContext) => Response | void | Promise<Response | void>` signature from `@pyreon/server`
77
- Use `withHeaders()` from `utils/with-headers.ts` for Response header modification in middleware
88
- Use `useIntersectionObserver()` from `utils/use-intersection-observer.ts` instead of raw IntersectionObserver
99
- Components that need customization should expose 3 levels: composable (`useX`), HOC (`createX`), default component

.claude/rules/code-style.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
- JSX via `@pyreon/vite-plugin` — never import `h` manually in `.tsx` files
55
- Use Biome for formatting and linting — run `bunx biome check .` before committing
66
- Prefer `signal`, `computed`, `effect` from `@pyreon/reactivity` — no React hooks
7-
- Use `onMount` / `onCleanup` lifecycle hooks, not `useEffect`
7+
- Use `onMount` / `onUnmount` / `onCleanup` lifecycle hooks, not `useEffect`
88
- Prefer composition (composables like `useLink`) over inheritance
99
- Export types separately: `export type { Foo }` not mixed with value exports
1010
- No default exports except Vite plugin (`export { zeroPlugin as default }`) and route components

packages/create-zero/templates/default/src/routes/counter.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default function Counter() {
2525
</div>
2626

2727
<div class="counter-demo">
28-
<div class="counter-display">{count}</div>
28+
<div class="counter-display">{() => count()}</div>
2929

3030
<div class="counter-controls">
3131
<button
@@ -53,10 +53,10 @@ export default function Counter() {
5353

5454
<div class="counter-meta">
5555
<div>
56-
count() → <strong>{count}</strong>
56+
count() → <strong>{() => count()}</strong>
5757
</div>
5858
<div>
59-
doubled() → <strong>{doubled}</strong>
59+
doubled() → <strong>{() => doubled()}</strong>
6060
</div>
6161
<div>
6262
isEven() → <strong>{() => (isEven() ? 'true' : 'false')}</strong>

packages/zero/src/link.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export interface LinkProps {
3535
/** Props passed to a custom component via createLink. */
3636
export interface LinkRenderProps {
3737
href: string
38-
ref: import('@pyreon/core').Ref<HTMLElement>
38+
ref: import('@pyreon/core').Ref<HTMLAnchorElement>
3939
onClick: (e: MouseEvent) => void
4040
onMouseEnter: () => void
4141
onTouchStart: () => void
@@ -53,7 +53,7 @@ export interface LinkRenderProps {
5353
/** Return type of useLink. */
5454
export interface UseLinkReturn {
5555
/** Ref object — attach to the root element for viewport-based prefetch. */
56-
ref: import('@pyreon/core').Ref<HTMLElement>
56+
ref: import('@pyreon/core').Ref<HTMLAnchorElement>
5757
/** Click handler — performs client-side navigation. */
5858
handleClick: (e: MouseEvent) => void
5959
/** Mouse enter handler — triggers hover prefetch. */
@@ -108,7 +108,7 @@ function doPrefetch(href: string) {
108108
*/
109109
export function useLink(props: LinkProps): UseLinkReturn {
110110
const router = useRouter()
111-
const elementRef = createRef<HTMLElement>()
111+
const elementRef = createRef<HTMLAnchorElement>()
112112
const strategy = props.prefetch ?? 'hover'
113113

114114
function handleClick(e: MouseEvent) {
@@ -248,7 +248,7 @@ export function createLink(
248248
*/
249249
export const Link = createLink((props: LinkRenderProps) => (
250250
<a
251-
ref={props.ref as any}
251+
ref={props.ref}
252252
href={props.href}
253253
{...(props.class ? { class: props.class } : {})}
254254
{...(props.style ? { style: props.style } : {})}

0 commit comments

Comments
 (0)