Skip to content

Commit 01138a9

Browse files
authored
Add Biome linting and CI workflow (#7)
1 parent 3015330 commit 01138a9

38 files changed

+1586
-1079
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
name: Build
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: pnpm/action-setup@v4
16+
with:
17+
version: latest
18+
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: 22
22+
cache: pnpm
23+
24+
- name: Install dependencies
25+
run: pnpm install --frozen-lockfile
26+
27+
- name: Lint
28+
run: pnpm lint
29+
30+
- name: Build
31+
run: pnpm build

CLAUDE.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ Sprites documentation site built with Astro Starlight and React components. Stat
99
## Commands
1010

1111
```bash
12-
bun install # Install dependencies
13-
bun run dev # Start dev server at localhost:4321
14-
bun run build # Build static site to ./dist/
15-
bun run preview # Preview production build locally
12+
pnpm install # Install dependencies
13+
pnpm dev # Start dev server at localhost:4321
14+
pnpm build # Build static site to ./dist/
15+
pnpm preview # Preview production build locally
16+
pnpm lint # Run Biome linter
17+
pnpm lint:fix # Auto-fix lint issues
1618
```
1719

1820
## Architecture
@@ -32,14 +34,10 @@ bun run preview # Preview production build locally
3234
- `astro.config.mjs` - Site config including sidebar structure
3335

3436
### Component Pattern
35-
React components are wrapped in `.astro` files for MDX usage. The React components export from `src/components/react/index.ts`:
36-
- `CodeTabs`/`Snippet` - Language-tabbed code blocks
37-
- `Callout` - Alert/info boxes
38-
- `ParamTable`/`Param` - API parameter documentation
39-
- `APIEndpoint`/`StatusCodes` - REST API documentation
40-
- `BillingCalculator`/`PricingRates` - Interactive pricing tools
41-
42-
Use `client:load` directive when importing React components in MDX.
37+
React components are wrapped in `.astro` files for MDX usage. All React components export from `src/components/react/index.ts`. Use `client:load` directive when importing React components in MDX.
38+
39+
### Starlight Overrides
40+
Custom Starlight components in `src/components/` override defaults: `Head.astro`, `Header.astro`, `Search.astro`, `ThemeSelect.astro`, `PageTitle.astro`, `SiteTitle.astro`.
4341

4442
### Path Aliases
4543
- `@/*``./src/*`

astro.config.mjs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// @ts-check
2-
import { defineConfig } from 'astro/config';
3-
import starlight from '@astrojs/starlight';
4-
import sitemap from '@astrojs/sitemap';
2+
53
import react from '@astrojs/react';
4+
import sitemap from '@astrojs/sitemap';
5+
import starlight from '@astrojs/starlight';
66
import tailwindcss from '@tailwindcss/vite';
7+
import { defineConfig } from 'astro/config';
78

89
// https://astro.build/config
910
export default defineConfig({
@@ -27,7 +28,11 @@ export default defineConfig({
2728
favicon: '/favicon.svg',
2829
customCss: ['./src/styles/custom.css'],
2930
social: [
30-
{ icon: 'github', label: 'GitHub', href: 'https://github.com/superfly/sprites-docs' },
31+
{
32+
icon: 'github',
33+
label: 'GitHub',
34+
href: 'https://github.com/superfly/sprites-docs',
35+
},
3136
],
3237
editLink: {
3338
baseUrl: 'https://github.com/superfly/sprites-docs/edit/master/',
@@ -67,9 +72,7 @@ export default defineConfig({
6772
},
6873
{
6974
label: 'API',
70-
items: [
71-
{ label: 'REST API', slug: 'api/rest' },
72-
],
75+
items: [{ label: 'REST API', slug: 'api/rest' }],
7376
},
7477
{
7578
label: 'Reference',

biome.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.3.10/schema.json",
3+
"vcs": {
4+
"enabled": true,
5+
"clientKind": "git",
6+
"useIgnoreFile": true
7+
},
8+
"files": {
9+
"includes": ["**", "!!**/dist", "!!**/*.astro", "!!**/*.css"]
10+
},
11+
"formatter": {
12+
"enabled": true,
13+
"indentStyle": "space",
14+
"indentWidth": 2
15+
},
16+
"linter": {
17+
"enabled": true,
18+
"rules": {
19+
"recommended": true,
20+
"correctness": {
21+
"noUnusedFunctionParameters": "warn"
22+
},
23+
"a11y": {
24+
"noLabelWithoutControl": "off",
25+
"useButtonType": "warn",
26+
"noSvgWithoutTitle": "off",
27+
"noStaticElementInteractions": "off"
28+
},
29+
"suspicious": {
30+
"noArrayIndexKey": "warn"
31+
},
32+
"security": {
33+
"noDangerouslySetInnerHtml": "warn"
34+
}
35+
}
36+
},
37+
"javascript": {
38+
"formatter": {
39+
"quoteStyle": "single"
40+
}
41+
},
42+
"assist": {
43+
"enabled": true,
44+
"actions": {
45+
"source": {
46+
"organizeImports": "on"
47+
}
48+
}
49+
}
50+
}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
"start": "astro dev",
88
"build": "astro build",
99
"preview": "astro preview",
10+
"lint": "biome check",
11+
"lint:fix": "biome check --write",
1012
"astro": "astro"
1113
},
1214
"dependencies": {
@@ -37,6 +39,7 @@
3739
"tailwindcss": "^4.1.18"
3840
},
3941
"devDependencies": {
42+
"@biomejs/biome": "2.3.10",
4043
"@flydotio/dockerfile": "^0.7.10",
4144
"tw-animate-css": "^1.4.0"
4245
}

pnpm-lock.yaml

Lines changed: 91 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/transform-mdx.cjs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,42 @@
11
#!/usr/bin/env node
22

3-
const fs = require('fs');
4-
const path = require('path');
3+
const fs = require('node:fs');
4+
const path = require('node:path');
55

66
const srcDir = '../sprites-docs-next/content/docs';
77
const destDir = './src/content/docs';
88

9-
function transformContent(content, filePath) {
9+
function transformContent(content, _filePath) {
1010
let transformed = content;
1111

1212
// Transform {#snippet name()} to <Snippet name="name">
13-
transformed = transformed.replace(/\{#snippet\s+(\w+)\(\)\}/g, '<Snippet name="$1">');
13+
transformed = transformed.replace(
14+
/\{#snippet\s+(\w+)\(\)\}/g,
15+
'<Snippet name="$1">',
16+
);
1417

1518
// Transform {/snippet} to </Snippet>
1619
transformed = transformed.replace(/\{\/snippet\}/g, '</Snippet>');
1720

1821
// Check which components are used
1922
const usedComponents = [];
2023
if (transformed.includes('<Callout')) usedComponents.push('Callout');
21-
if (transformed.includes('<CodeTabs')) usedComponents.push('CodeTabs', 'Snippet');
22-
if (transformed.includes('<LifecycleDiagram')) usedComponents.push('LifecycleDiagram');
23-
if (transformed.includes('<BillingCalculator')) usedComponents.push('BillingCalculator');
24-
if (transformed.includes('<ParamTable') || transformed.includes('<Param ')) usedComponents.push('ParamTable', 'Param');
24+
if (transformed.includes('<CodeTabs'))
25+
usedComponents.push('CodeTabs', 'Snippet');
26+
if (transformed.includes('<LifecycleDiagram'))
27+
usedComponents.push('LifecycleDiagram');
28+
if (transformed.includes('<BillingCalculator'))
29+
usedComponents.push('BillingCalculator');
30+
if (transformed.includes('<ParamTable') || transformed.includes('<Param '))
31+
usedComponents.push('ParamTable', 'Param');
2532
if (transformed.includes('<ParamInline')) usedComponents.push('ParamInline');
26-
if (transformed.includes('<StatusCodes') || transformed.includes('<StatusBadge')) usedComponents.push('StatusCodes', 'StatusBadge');
27-
if (transformed.includes('<APIEndpoint') || transformed.includes('<APIBody')) usedComponents.push('APIEndpoint', 'APIBody');
33+
if (
34+
transformed.includes('<StatusCodes') ||
35+
transformed.includes('<StatusBadge')
36+
)
37+
usedComponents.push('StatusCodes', 'StatusBadge');
38+
if (transformed.includes('<APIEndpoint') || transformed.includes('<APIBody'))
39+
usedComponents.push('APIEndpoint', 'APIBody');
2840

2941
// Add imports after frontmatter if components are used
3042
if (usedComponents.length > 0) {
@@ -37,7 +49,8 @@ function transformContent(content, filePath) {
3749
const afterFrontmatter = frontmatterEnd + 3;
3850
transformed =
3951
transformed.substring(0, afterFrontmatter) +
40-
'\n\n' + importStatement +
52+
'\n\n' +
53+
importStatement +
4154
transformed.substring(afterFrontmatter).trimStart();
4255
}
4356
}

0 commit comments

Comments
 (0)