Skip to content

Commit fe4fb7d

Browse files
authored
feat: tooling (ts, lint, format, commit hook) (#3)
* chore: remove depracated calls * chore: add `@astrojs/ts-plugin` plugin * chore: adjust eslint config * feat: add vscode settings.json * feat: add prettier * chore: run format script * chore: add pre-commit hook * chore: update eslint ignore list
1 parent a07356f commit fe4fb7d

50 files changed

Lines changed: 6449 additions & 2711 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pnpm lint-staged

.prettierrc.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"semi": true,
3+
"singleQuote": false,
4+
"printWidth": 80,
5+
"plugins": ["prettier-plugin-astro", "prettier-plugin-tailwindcss"],
6+
"overrides": [
7+
{
8+
"files": "*.astro",
9+
"options": {
10+
"parser": "astro"
11+
}
12+
}
13+
]
14+
}

.vscode/extensions.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2-
"recommendations": ["astro-build.astro-vscode"],
2+
"recommendations": [
3+
"astro-build.astro-vscode",
4+
"esbenp.prettier-vscode",
5+
"dbaeumer.vscode-eslint",
6+
"oxc.oxc-vscode"
7+
],
38
"unwantedRecommendations": []
49
}

.vscode/settings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"explorer.fileNesting.enabled": true,
3+
"explorer.fileNesting.patterns": {
4+
"package.json": "package-lock.json, pnpm*, .yarnrc*, yarn*, .eslint*, eslint*, .oxlint*, oxlint*, .prettier*, prettier*, .editorconfig"
5+
},
6+
"editor.codeActionsOnSave": {
7+
"source.fixAll": "explicit",
8+
"source.organizeImports": "explicit"
9+
},
10+
"editor.formatOnSave": true,
11+
"editor.defaultFormatter": "esbenp.prettier-vscode",
12+
"oxc.enable": true
13+
}

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@ pnpm dev
2323

2424
## Scripts
2525

26-
| Command | Description |
27-
|---------|-------------|
28-
| `pnpm dev` | Start dev server |
29-
| `pnpm build` | Production build |
30-
| `pnpm preview` | Preview production build |
31-
| `pnpm test` | Run tests in watch mode |
32-
| `pnpm test:run` | Run tests once (CI) |
33-
| `pnpm lint` | Lint with ESLint |
26+
| Command | Description |
27+
| --------------- | ------------------------ |
28+
| `pnpm dev` | Start dev server |
29+
| `pnpm build` | Production build |
30+
| `pnpm preview` | Preview production build |
31+
| `pnpm test` | Run tests in watch mode |
32+
| `pnpm test:run` | Run tests once (CI) |
33+
| `pnpm lint` | Lint with ESLint |
3434

3535
The Open Graph image at `/og-image.png` is generated at build time from `public/og-image.svg` and `public/logo.png` via a [static file endpoint](https://docs.astro.build/en/guides/endpoints/#static-file-endpoints) (`src/pages/og-image.png.ts`).
3636

3737
## Environment variables
3838

39-
| Variable | Description |
40-
|----------|-------------|
41-
| `PUBLIC_SITE_URL` | Canonical site URL for meta tags |
42-
| `PUBLIC_DISCORD_INVITE_URL` | Discord invite link for CTAs |
39+
| Variable | Description |
40+
| --------------------------- | -------------------------------- |
41+
| `PUBLIC_SITE_URL` | Canonical site URL for meta tags |
42+
| `PUBLIC_DISCORD_INVITE_URL` | Discord invite link for CTAs |
4343

4444
## Pages
4545

@@ -51,11 +51,11 @@ The Open Graph image at `/og-image.png` is generated at build time from `public/
5151

5252
This project includes a [`wrangler.toml`](wrangler.toml) for Cloudflare Pages.
5353

54-
| Setting | Value |
55-
|---------|-------|
56-
| Build command | `pnpm build` |
57-
| Output directory | `dist` |
58-
| Node version | 24 |
54+
| Setting | Value |
55+
| ---------------- | ------------ |
56+
| Build command | `pnpm build` |
57+
| Output directory | `dist` |
58+
| Node version | 24 |
5959

6060
Set `PUBLIC_SITE_URL` and `PUBLIC_DISCORD_INVITE_URL` in Cloudflare Pages environment variables.
6161

astro.config.mjs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
// @ts-check
2-
import { fileURLToPath, URL } from 'node:url';
3-
import { defineConfig, envField } from 'astro/config';
4-
import react from '@astrojs/react';
5-
import tailwindcss from '@tailwindcss/vite';
2+
import { fileURLToPath, URL } from "node:url";
3+
import { defineConfig, envField } from "astro/config";
4+
import react from "@astrojs/react";
5+
import tailwindcss from "@tailwindcss/vite";
66

77
// https://astro.build/config
88
// Static output — deploy dist/ to Cloudflare Pages without an adapter.
99
// Add @astrojs/cloudflare when switching to output: 'server'.
1010
export default defineConfig({
11-
site: process.env.PUBLIC_SITE_URL ?? 'https://webdevdesign.example.com',
11+
site: process.env.PUBLIC_SITE_URL ?? "https://webdevdesign.example.com",
1212
env: {
1313
schema: {
1414
PUBLIC_SITE_URL: envField.string({
15-
context: 'client',
16-
access: 'public',
17-
default: 'https://webdevdesign.example.com',
15+
context: "client",
16+
access: "public",
17+
default: "https://webdevdesign.example.com",
1818
}),
1919
PUBLIC_DISCORD_INVITE_URL: envField.string({
20-
context: 'client',
21-
access: 'public',
22-
default: 'https://discord.gg/webdevdesign',
20+
context: "client",
21+
access: "public",
22+
default: "https://discord.gg/webdevdesign",
2323
}),
2424
},
2525
},
26-
output: 'static',
26+
output: "static",
2727
integrations: [react()],
2828
vite: {
2929
resolve: {
3030
alias: {
31-
'@': fileURLToPath(new URL('./src', import.meta.url)),
31+
"@": fileURLToPath(new URL("./src", import.meta.url)),
3232
},
3333
},
3434
plugins: [tailwindcss()],

eslint.config.mjs

Lines changed: 0 additions & 20 deletions
This file was deleted.

eslint.config.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import js from "@eslint/js";
2+
import astroParser from "astro-eslint-parser";
3+
import prettierConfig from "eslint-config-prettier";
4+
import astro from "eslint-plugin-astro";
5+
import oxlint from "eslint-plugin-oxlint";
6+
import { defineConfig } from "eslint/config";
7+
import tseslint from "typescript-eslint";
8+
9+
export default defineConfig([
10+
js.configs.recommended,
11+
...tseslint.configs.recommended,
12+
...astro.configs.recommended,
13+
...oxlint.configs["flat/recommended"],
14+
15+
prettierConfig,
16+
{
17+
ignores: [
18+
"dist/",
19+
".astro/",
20+
"node_modules/",
21+
"pnpm-lock.yaml",
22+
".vscode/",
23+
".husky/",
24+
".cursor/",
25+
"terraform/",
26+
],
27+
},
28+
{
29+
files: ["**/*.{mjs,js,cjs}"],
30+
languageOptions: {
31+
globals: {
32+
process: "readonly",
33+
},
34+
},
35+
},
36+
{
37+
files: ["**/*.astro"],
38+
languageOptions: {
39+
parser: astroParser,
40+
parserOptions: {
41+
parser: tseslint.parser,
42+
extraFileExtensions: [".astro"],
43+
sourceType: "module",
44+
},
45+
},
46+
},
47+
]);

package.json

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,31 @@
88
},
99
"scripts": {
1010
"dev": "astro dev",
11-
"build": "astro build",
11+
"build": "astro check && astro build",
1212
"preview": "astro preview",
1313
"astro": "astro",
14-
"lint": "eslint .",
14+
"lint:eslint": "eslint . --fix",
15+
"lint:oxlint": "oxlint . --fix",
16+
"lint": "pnpm lint:eslint && pnpm lint:oxlint",
1517
"test": "vitest",
1618
"test:run": "vitest run",
17-
"test:coverage": "vitest run --coverage"
19+
"typecheck": "astro check",
20+
"test:coverage": "vitest run --coverage",
21+
"format": "prettier . --write",
22+
"prepare": "husky"
1823
},
1924
"dependencies": {
25+
"@astrojs/check": "^0.9.9",
2026
"@astrojs/react": "^5.0.7",
27+
"@astrojs/ts-plugin": "^1.10.9",
2128
"@tailwindcss/vite": "^4.3.0",
2229
"@types/react": "^19.2.17",
2330
"@types/react-dom": "^19.2.3",
2431
"astro": "^6.4.4",
2532
"react": "^19.2.7",
2633
"react-dom": "^19.2.7",
2734
"tailwindcss": "^4.3.0",
35+
"typescript": "^6.0.3",
2836
"zod": "^4.4.3"
2937
},
3038
"devDependencies": {
@@ -34,11 +42,30 @@
3442
"@testing-library/jest-dom": "^6.9.1",
3543
"@testing-library/react": "^16.3.2",
3644
"@testing-library/user-event": "^14.6.1",
45+
"@types/node": "^25.9.3",
46+
"astro-eslint-parser": "^1.4.0",
3747
"eslint": "^10.4.1",
48+
"eslint-config-prettier": "^10.1.8",
3849
"eslint-plugin-astro": "^1.7.0",
50+
"eslint-plugin-oxlint": "^1.69.0",
51+
"husky": "^9.1.7",
3952
"jsdom": "^29.1.1",
53+
"lint-staged": "^17.0.7",
54+
"oxlint": "^1.69.0",
55+
"prettier": "^3.8.4",
56+
"prettier-plugin-astro": "^0.14.1",
57+
"prettier-plugin-tailwindcss": "^0.8.0",
4058
"sharp": "^0.34.5",
4159
"typescript-eslint": "^8.61.0",
4260
"vitest": "^4.1.8"
61+
},
62+
"lint-staged": {
63+
"*.{js,ts,mjs,cjs}": [
64+
"eslint --fix",
65+
"prettier --write"
66+
],
67+
"*.{astro,json,md,yml,yaml}": [
68+
"prettier --write"
69+
]
4370
}
44-
}
71+
}

0 commit comments

Comments
 (0)