From 987917240623a2f758abf63a1f4fc1b77dec1bdf Mon Sep 17 00:00:00 2001 From: Ryuz Date: Sat, 5 Sep 2026 11:00:18 +0200 Subject: [PATCH 1/2] chore(oxide): refactor with ultracite --- .claude/CLAUDE.md | 126 +++ .husky/pre-commit | 27 + .oxfmtrc.json | 10 - AGENTS.md | 127 +++ README.md | 4 +- apps/website/blume.config.ts | 45 +- .../blume/{Header.astro => header.astro} | 0 apps/website/docs/(introduction)/meta.ts | 2 +- apps/website/docs/oxide/configuration.mdx | 44 +- apps/website/docs/oxide/meta.ts | 13 +- apps/website/docs/oxide/quickstart.mdx | 15 +- apps/website/docs/oxide/security.mdx | 18 +- apps/website/docs/oxide/server-actions.mdx | 22 +- apps/website/docs/oxide/server-entry.mdx | 70 +- apps/website/pages/_home/highlight.ts | 11 +- apps/website/pages/index.astro | 21 +- apps/website/tsconfig.json | 3 +- bun.lock | 206 +++- oxfmt.config.ts | 14 + oxlint.config.ts | 8 + package.json | 13 +- packages/oxidejs/README.md | 83 +- packages/oxidejs/client.d.ts | 24 +- packages/oxidejs/package.json | 2 +- packages/oxidejs/src/action.test.ts | 56 +- packages/oxidejs/src/action.ts | 309 ++++-- packages/oxidejs/src/actions.test.ts | 952 ++++++++++++------ packages/oxidejs/src/actions.ts | 712 ++++++++----- packages/oxidejs/src/context.ts | 214 +++- packages/oxidejs/src/core.test.ts | 145 ++- packages/oxidejs/src/core.ts | 357 ++++--- packages/oxidejs/src/index.test.ts | 447 +++++--- packages/oxidejs/src/index.ts | 3 + packages/oxidejs/src/plugin.ts | 806 ++++++++++----- packages/oxidejs/src/rpc/client.ts | 338 +++++-- packages/oxidejs/src/rpc/same-origin.ts | 21 +- packages/oxidejs/src/rpc/scrub.test.ts | 241 +++-- packages/oxidejs/src/rpc/scrub.ts | 275 +++-- packages/oxidejs/src/rpc/server.ts | 140 ++- packages/oxidejs/src/rpc/stream.ts | 82 +- packages/oxidejs/src/rpc/test-harness.ts | 31 + packages/oxidejs/src/rpc/ws-crossws.test.ts | 158 +-- packages/oxidejs/src/rpc/ws.test.ts | 80 +- packages/oxidejs/src/rpc/ws.ts | 178 ++-- packages/oxidejs/src/types.ts | 25 +- packages/oxidejs/src/worker-build.ts | 159 +-- packages/oxidejs/src/worker-dom.test.ts | 48 +- packages/oxidejs/src/worker-dom.ts | 38 +- packages/oxidejs/src/wrapper.test.ts | 35 +- packages/oxidejs/tsconfig.json | 3 +- packages/oxidejs/tsdown.config.ts | 12 +- packages/oxidejs/virtual.d.ts | 8 +- scripts/release.ts | 96 +- templates/simple/package.json | 2 +- templates/simple/src/lib/greet.server.tsx | 16 +- templates/simple/src/pages/index.tsx | 11 +- templates/simple/src/server.ts | 2 +- templates/simple/tsconfig.json | 3 +- templates/simple/vite.config.ts | 6 +- templates/tasks/package.json | 2 +- templates/tasks/src/lib/tasks.server.tsx | 126 ++- templates/tasks/src/pages/index.tsx | 27 +- templates/tasks/src/server.ts | 8 +- templates/tasks/tsconfig.json | 3 +- templates/tasks/vite.config.ts | 2 +- tsconfig.json | 3 +- 66 files changed, 4803 insertions(+), 2285 deletions(-) create mode 100644 .claude/CLAUDE.md create mode 100644 .husky/pre-commit delete mode 100644 .oxfmtrc.json rename apps/website/components/blume/{Header.astro => header.astro} (100%) create mode 100644 oxfmt.config.ts create mode 100644 oxlint.config.ts create mode 100644 packages/oxidejs/src/rpc/test-harness.ts diff --git a/.claude/CLAUDE.md b/.claude/CLAUDE.md new file mode 100644 index 0000000..f8a5623 --- /dev/null +++ b/.claude/CLAUDE.md @@ -0,0 +1,126 @@ +# Ultracite Code Standards + +This project uses **Ultracite**, a zero-config preset that enforces strict code quality standards through automated formatting and linting. + +## Quick Reference + +- **Format code**: `bun x ultracite fix` +- **Check for issues**: `bun x ultracite check` +- **Diagnose setup**: `bun x ultracite doctor` + +Oxlint + Oxfmt (the underlying engine) provides robust linting and formatting. Most issues are automatically fixable. + +--- + +## Core Principles + +Write code that is **accessible, performant, type-safe, and maintainable**. Focus on clarity and explicit intent over brevity. + +### Type Safety & Explicitness + +- Use explicit types for function parameters and return values when they enhance clarity +- Prefer `unknown` over `any` when the type is genuinely unknown +- Use const assertions (`as const`) for immutable values and literal types +- Leverage TypeScript's type narrowing instead of type assertions +- Use meaningful variable names instead of magic numbers - extract constants with descriptive names + +### Modern JavaScript/TypeScript + +- Use arrow functions for callbacks and short functions +- Prefer `for...of` loops over `.forEach()` and indexed `for` loops +- Use optional chaining (`?.`) and nullish coalescing (`??`) for safer property access +- Prefer template literals over string concatenation +- Use destructuring for object and array assignments +- Use `const` by default, `let` only when reassignment is needed, never `var` + +### Async & Promises + +- Always `await` promises in async functions - don't forget to use the return value +- Use `async/await` syntax instead of promise chains for better readability +- Handle errors appropriately in async code with try-catch blocks +- Don't use async functions as Promise executors + +### React & JSX + +- Use function components over class components +- Call hooks at the top level only, never conditionally +- Specify all dependencies in hook dependency arrays correctly +- Use the `key` prop for elements in iterables (prefer unique IDs over array indices) +- Nest children between opening and closing tags instead of passing as props +- Don't define components inside other components +- Use semantic HTML and ARIA attributes for accessibility: + - Provide meaningful alt text for images + - Use proper heading hierarchy + - Add labels for form inputs + - Include keyboard event handlers alongside mouse events + - Use semantic elements (`