diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 0000000..461742b --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,18 @@ +name: Code quality + +on: + push: + pull_request: + +jobs: + quality: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Biome + uses: biomejs/setup-biome@v2 + with: + version: latest + - name: Run Biome + run: biome ci . diff --git a/app/client.ts b/app/client.ts index 16ecf96..4a2cea5 100644 --- a/app/client.ts +++ b/app/client.ts @@ -1,3 +1,3 @@ -import { createClient } from 'honox/client' +import { createClient } from "honox/client"; -createClient() +createClient(); diff --git a/app/global.d.ts b/app/global.d.ts index 288f02b..97866ad 100644 --- a/app/global.d.ts +++ b/app/global.d.ts @@ -1,15 +1,14 @@ -import {} from 'hono' +import {} from "hono"; type Head = { - title?: string -} + title?: string; +}; -declare module 'hono' { - interface Env { - Variables: {} - Bindings: {} - } +declare module "hono" { interface ContextRenderer { - (content: string | Promise, head?: Head): Response | Promise + ( + content: string | Promise, + head?: Head, + ): Response | Promise; } } diff --git a/app/index.css b/app/index.css new file mode 100644 index 0000000..b5c61c9 --- /dev/null +++ b/app/index.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; diff --git a/app/islands/counter.tsx b/app/islands/counter.tsx index 0bb5438..87b3f26 100644 --- a/app/islands/counter.tsx +++ b/app/islands/counter.tsx @@ -1,11 +1,13 @@ -import { useState } from 'hono/jsx' +import { useState } from "hono/jsx"; export default function Counter() { - const [count, setCount] = useState(0) + const [count, setCount] = useState(0); return (

{count}

- +
- ) + ); } diff --git a/app/routes/_renderer.tsx b/app/routes/_renderer.tsx index f72c28f..fc3ce8b 100644 --- a/app/routes/_renderer.tsx +++ b/app/routes/_renderer.tsx @@ -1,6 +1,6 @@ -import { Style } from 'hono/css' -import { jsxRenderer } from 'hono/jsx-renderer' -import { Script } from 'honox/server' +import { Style } from "hono/css"; +import { jsxRenderer } from "hono/jsx-renderer"; +import { Script } from "honox/server"; export default jsxRenderer(({ children, title }) => { return ( @@ -14,5 +14,5 @@ export default jsxRenderer(({ children, title }) => { {children} - ) -}) + ); +}); diff --git a/app/routes/index.tsx b/app/routes/index.tsx index fc34955..1debc0b 100644 --- a/app/routes/index.tsx +++ b/app/routes/index.tsx @@ -1,18 +1,13 @@ -import { css } from 'hono/css' -import { createRoute } from 'honox/factory' -import Counter from '../islands/counter' - -const className = css` - font-family: sans-serif; -` +import { createRoute } from "honox/factory"; +import Counter from "../islands/counter"; export default createRoute((c) => { - const name = c.req.query('name') ?? 'Hono' + const name = c.req.query("name") ?? "Hono"; return c.render( -
-

Hello, {name}!

+
+

Hello world! {name}

, - { title: name } - ) -}) + { title: name }, + ); +}); diff --git a/app/server.ts b/app/server.ts index c0cbcb7..0de9afb 100644 --- a/app/server.ts +++ b/app/server.ts @@ -1,8 +1,8 @@ -import { showRoutes } from 'hono/dev' -import { createApp } from 'honox/server' +import { showRoutes } from "hono/dev"; +import { createApp } from "honox/server"; -const app = createApp() +const app = createApp(); -showRoutes(app) +showRoutes(app); -export default app +export default app; diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..5ddb4b7 --- /dev/null +++ b/biome.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.5.3/schema.json", + "organizeImports": { + "enabled": true + }, + "formatter": { + "enabled": true, + "formatWithErrors": true, + "indentStyle": "space", + "indentWidth": 2, + "lineWidth": 80 + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true + } + } +} diff --git a/package.json b/package.json index 4594c68..77af02a 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,14 @@ { - "name": "basic", + "name": "blog", "type": "module", "scripts": { "dev": "vite", "build": "vite build --mode client && vite build", "preview": "wrangler pages dev ./dist", - "deploy": "$npm_execpath run build && wrangler pages deploy ./dist" + "deploy": "$npm_execpath run build && wrangler pages deploy ./dist", + "format": "biome format --write .", + "lint": "biome lint .", + "check": "biome check --apply ." }, "private": true, "dependencies": { @@ -13,8 +16,12 @@ "honox": "^0.1.4" }, "devDependencies": { + "@biomejs/biome": "1.5.3", "@cloudflare/workers-types": "^4.20240208.0", "@hono/vite-cloudflare-pages": "^0.2.4", + "autoprefixer": "^10.4.17", + "postcss": "^8.4.35", + "tailwindcss": "^3.4.1", "vite": "^5.0.12", "wrangler": "^3.27.0" } diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 0000000..2aa7205 --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +}; diff --git a/tailwind.config.js b/tailwind.config.js new file mode 100644 index 0000000..0ac5a7d --- /dev/null +++ b/tailwind.config.js @@ -0,0 +1,8 @@ +/** @type {import('tailwindcss').Config} */ +export default { + content: ["./app/**/*.{js,ts,jsx,tsx}"], + theme: { + extend: {}, + }, + plugins: [], +}; diff --git a/vite.config.ts b/vite.config.ts index f154f37..3c38e23 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -8,9 +8,8 @@ export default defineConfig(({ mode }) => { return { plugins: [client()], }; - } else { - return { - plugins: [honox(), pages()], - }; } + return { + plugins: [honox(), pages()], + }; });