-
Notifications
You must be signed in to change notification settings - Fork 0
feat: scaffold @inth/docs package with convert, llm, lint, components #1
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
7855f25
c69d5d4
cd02443
2cf181d
8492e53
381896a
f602e37
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,8 @@ | ||
| # Changesets | ||
|
|
||
| Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
| with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
| find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
|
|
||
| We have a quick list of common questions to get you started engaging with this project in | ||
| [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "$schema": "https://unpkg.com/@changesets/config@2.30.0/schema.json", | ||
| "changelog": "@changesets/cli/changelog", | ||
| "commit": false, | ||
| "access": "public", | ||
| "baseBranch": "main", | ||
| "updateInternalDependencies": "patch", | ||
| "ignore": [], | ||
| "snapshot": { | ||
| "useCalculatedVersion": true | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| # 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` | ||
|
|
||
| Biome (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 (`<button>`, `<nav>`, etc.) instead of divs with roles | ||
|
|
||
| ### Error Handling & Debugging | ||
|
|
||
| - Remove `console.log`, `debugger`, and `alert` statements from production code | ||
| - Throw `Error` objects with descriptive messages, not strings or other values | ||
| - Use `try-catch` blocks meaningfully - don't catch errors just to rethrow them | ||
| - Prefer early returns over nested conditionals for error cases | ||
|
|
||
| ### Code Organization | ||
|
|
||
| - Keep functions focused and under reasonable cognitive complexity limits | ||
| - Extract complex conditions into well-named boolean variables | ||
| - Use early returns to reduce nesting | ||
| - Prefer simple conditionals over nested ternary operators | ||
| - Group related code together and separate concerns | ||
|
|
||
| ### Security | ||
|
|
||
| - Add `rel="noopener"` when using `target="_blank"` on links | ||
| - Avoid `dangerouslySetInnerHTML` unless absolutely necessary | ||
| - Don't use `eval()` or assign directly to `document.cookie` | ||
| - Validate and sanitize user input | ||
|
|
||
| ### Performance | ||
|
|
||
| - Avoid spread syntax in accumulators within loops | ||
| - Use top-level regex literals instead of creating them in loops | ||
| - Prefer specific imports over namespace imports | ||
| - Avoid barrel files (index files that re-export everything) | ||
| - Use proper image components (e.g., Next.js `<Image>`) over `<img>` tags | ||
|
|
||
| ### Framework-Specific Guidance | ||
|
|
||
| **Next.js:** | ||
| - Use Next.js `<Image>` component for images | ||
| - Use `next/head` or App Router metadata API for head elements | ||
| - Use Server Components for async data fetching instead of async Client Components | ||
|
|
||
| **React 19+:** | ||
| - Use ref as a prop instead of `React.forwardRef` | ||
|
|
||
| **Solid/Svelte/Vue/Qwik:** | ||
| - Use `class` and `for` attributes (not `className` or `htmlFor`) | ||
|
|
||
| --- | ||
|
|
||
| ## Testing | ||
|
|
||
| - Write assertions inside `it()` or `test()` blocks | ||
| - Avoid done callbacks in async tests - use async/await instead | ||
| - Don't use `.only` or `.skip` in committed code | ||
| - Keep test suites reasonably flat - avoid excessive `describe` nesting | ||
|
|
||
| ## When Biome Can't Help | ||
|
|
||
| Biome's linter will catch most issues automatically. Focus your attention on: | ||
|
|
||
| 1. **Business logic correctness** - Biome can't validate your algorithms | ||
| 2. **Meaningful naming** - Use descriptive names for functions, variables, and types | ||
| 3. **Architecture decisions** - Component structure, data flow, and API design | ||
| 4. **Edge cases** - Handle boundary conditions and error states | ||
| 5. **User experience** - Accessibility, performance, and usability considerations | ||
| 6. **Documentation** - Add comments for complex logic, but prefer self-documenting code | ||
|
|
||
| --- | ||
|
|
||
| Most formatting and common issues are automatically fixed by Biome. Run `bun x ultracite fix` before committing to ensure compliance. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "hooks": { | ||
| "PostToolUse": [ | ||
| { | ||
| "hooks": [ | ||
| { | ||
| "command": "bun fix --skip=correctness/noUnusedImports", | ||
| "type": "command" | ||
| } | ||
| ], | ||
| "matcher": "Write|Edit" | ||
| } | ||
| ] | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "hooks": { | ||
| "afterFileEdit": [ | ||
| { | ||
| "command": "bun fix --skip=correctness/noUnusedImports" | ||
| } | ||
| ] | ||
| }, | ||
| "version": 1 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| name: Benchmark | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - "packages/docs/**" | ||
| - "apps/docs-smoke/**" | ||
| - ".github/workflows/bench.yml" | ||
|
|
||
| # Don't stack benchmarks on rapid pushes — last one wins. | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| bench: | ||
| name: Convert + LLM pipeline | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
| # Non-blocking — numbers go to the job summary; no threshold gating | ||
| # because shared runners are too noisy for reliable regression detection. | ||
| continue-on-error: true | ||
|
|
||
| steps: | ||
| - name: Check out code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| # git enrichment needs full history | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup Bun | ||
| uses: oven-sh/setup-bun@v1 | ||
| with: | ||
| bun-version: "1.3.11" | ||
|
|
||
| - name: Install dependencies | ||
| run: bun install --frozen-lockfile | ||
|
|
||
| - name: Build @inth/docs | ||
| run: cd packages/docs && bun run build | ||
|
|
||
| - name: Run benchmark | ||
| env: | ||
| BENCH_RUNS: "3" | ||
| run: cd apps/docs-smoke && bun run bench | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| # Prevent multiple concurrent release workflows | ||
| concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
|
||
| permissions: | ||
| contents: write # create releases/tags + commit version bumps | ||
| pull-requests: write # create the "Version Packages" PR | ||
| id-token: write # OIDC token — the sole auth mechanism for npm publish | ||
| # Prereq: configure GitHub Actions as a Trusted Publisher on each npm | ||
| # package ( npmjs.com → Package → Settings → Publishing access ). Once | ||
| # configured, `npm publish` uses the OIDC token automatically — no | ||
| # NPM_TOKEN secret needed. | ||
|
Comment on lines
+11
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check if the repository is configured as public or private
gh api repos/{owner}/{repo} --jq '.visibility // .private | if . == true or . == "private" then "private" else "public" end'Repository: inthhq/docs Length of output: 62 OIDC trusted publishing cannot be used with a private repository — switch to NPM_TOKEN authentication. This repository is configured as private, but the workflow uses Either make the repository public or replace the OIDC approach with a traditional 🤖 Prompt for AI Agents |
||
|
|
||
| jobs: | ||
| release: | ||
| name: Release | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Check out code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| # Full history required for changesets to determine version bumps | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup Bun | ||
| uses: oven-sh/setup-bun@v1 | ||
| with: | ||
| # Pin Bun for reproducible releases. Bump intentionally. | ||
| bun-version: "1.3.11" | ||
|
|
||
| - name: Setup Node.js environment | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 | ||
| registry-url: "https://registry.npmjs.org" | ||
|
|
||
| # Upgrade npm for trusted publishing (OIDC provenance requires npm 11+). | ||
| # Workaround: Node.js 22's bundled npm is missing the `promise-retry` | ||
| # module which breaks `npm install -g`. We install it first then upgrade | ||
| # npm itself. Revisit once Node.js 22 ships a fixed npm. | ||
| # Ref: https://github.com/npm/cli/issues/7657 | ||
| - name: Upgrade npm for provenance publishing | ||
| run: | | ||
| npm install -g promise-retry 2>/dev/null || true | ||
| npm install -g npm@11.12.1 | ||
|
|
||
| - name: Install dependencies | ||
| run: bun install --frozen-lockfile | ||
|
|
||
| - name: Create Release Pull Request or Publish to npm | ||
| id: changesets | ||
| uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.4.9 | ||
| with: | ||
| version: bun run version | ||
| publish: bun run release | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| NPM_CONFIG_PROVENANCE: "true" | ||
|
|
||
| - name: Print changeset outputs | ||
| if: steps.changesets.outputs.published == 'true' | ||
| run: | | ||
| echo "Published: ${{ steps.changesets.outputs.published }}" | ||
| echo "Published packages: ${{ steps.changesets.outputs.publishedPackages }}" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
|
||
| # Dependencies | ||
| node_modules | ||
| .pnp | ||
| .pnp.js | ||
|
|
||
| # Local env files | ||
| .env | ||
| .env.local | ||
| .env.development.local | ||
| .env.test.local | ||
| .env.production.local | ||
|
|
||
| # Testing | ||
| coverage | ||
|
|
||
| # Turbo | ||
| .turbo | ||
|
|
||
| # Vercel | ||
| .vercel | ||
|
|
||
| # Build Outputs | ||
| .next/ | ||
| out/ | ||
| build | ||
| dist | ||
|
|
||
|
|
||
| # Debug | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
|
|
||
| # Misc | ||
| .DS_Store | ||
| *.pem |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #!/bin/sh | ||
| # Note: errors handled explicitly so FORMAT_EXIT_CODE is reachable. | ||
|
|
||
| # Check if there are any staged files | ||
| STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACMR) | ||
|
|
||
| # Run formatter first so tests run against the post-fix, restaged tree. | ||
| if [ -n "$STAGED_FILES" ]; then | ||
| bun x ultracite fix | ||
| FORMAT_EXIT_CODE=$? | ||
|
|
||
| # Re-stage files that were already staged | ||
| echo "$STAGED_FILES" | while IFS= read -r file; do | ||
| if [ -f "$file" ]; then | ||
| git add "$file" | ||
| fi | ||
| done | ||
|
|
||
| if [ $FORMAT_EXIT_CODE -ne 0 ]; then | ||
| echo "Ultracite found issues that could not be auto-fixed." | ||
| exit $FORMAT_EXIT_CODE | ||
| fi | ||
|
|
||
| echo "✨ Files formatted by Ultracite" | ||
| fi | ||
|
|
||
| # Run tests against the final tree that will be committed. | ||
| bun test --pass-with-no-tests || exit $? |
Uh oh!
There was an error while loading. Please reload this page.