Skip to content

Commit 8432bf0

Browse files
committed
refactor: apply spec.md code standards — ESLint 9 flat config, vitest coverage thresholds, pnpm scripts, strict tsconfig, CI workflow fixes
1 parent 9f9f473 commit 8432bf0

12 files changed

Lines changed: 141 additions & 17 deletions

File tree

.DS_Store

-2 KB
Binary file not shown.

.commitlintrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": ["@commitlint/config-conventional"],
3+
"rules": {
4+
"type-enum": [
5+
2, "always",
6+
["feat", "fix", "docs", "style", "refactor", "perf", "test", "build", "ci", "chore", "revert"]
7+
],
8+
"subject-max-length": [2, "always", 72],
9+
"body-max-line-length": [2, "always", 100]
10+
}
11+
}

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
day: "monday"
8+
open-pull-requests-limit: 5
9+
groups:
10+
dev-dependencies:
11+
dependency-type: "development"

.github/workflows/ci.yml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,39 @@ on:
77
branches: [main]
88

99
jobs:
10-
test:
10+
ci:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
node-version: ['18.x', '20.x', '22.x']
14+
node-version: [20, 22]
15+
1516
steps:
1617
- uses: actions/checkout@v4
18+
19+
- uses: pnpm/action-setup@v3
20+
with:
21+
version: 9
22+
1723
- uses: actions/setup-node@v4
1824
with:
1925
node-version: ${{ matrix.node-version }}
20-
cache: 'npm'
21-
- run: npm ci
22-
- run: npm run typecheck
23-
- run: npm run build
24-
- name: Run tests with Node.js native test runner
25-
run: node --test dist/tests/**/*.test.js
26+
cache: "pnpm"
27+
28+
- run: pnpm install --frozen-lockfile
29+
30+
- name: Lint
31+
run: pnpm lint
32+
33+
- name: Type check
34+
run: pnpm typecheck
35+
36+
- name: Test
37+
run: pnpm test --coverage
38+
39+
- name: Build
40+
run: pnpm build
41+
42+
- name: Upload coverage
43+
uses: codecov/codecov-action@v4
44+
with:
45+
files: ./coverage/lcov.info

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
node_modules
2-
.DS_Store
1+
node_modules/
2+
dist/
3+
coverage/
4+
.DS_Store
5+
*.log
6+
*.tsbuildinfo

.husky/commit-msg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pnpm exec commitlint --edit "$1"

.husky/pre-commit

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

.prettierrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"semi": true,
3+
"singleQuote": false,
4+
"trailingComma": "all",
5+
"printWidth": 100,
6+
"tabWidth": 2,
7+
"useTabs": false,
8+
"bracketSpacing": true,
9+
"arrowParens": "always",
10+
"endOfLine": "lf"
11+
}

eslint.config.mjs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import js from "@eslint/js";
2+
import ts from "typescript-eslint";
3+
import prettier from "eslint-config-prettier";
4+
5+
export default ts.config(
6+
js.configs.recommended,
7+
...ts.configs.strictTypeChecked,
8+
...ts.configs.stylisticTypeChecked,
9+
prettier,
10+
{
11+
languageOptions: {
12+
parserOptions: {
13+
project: true,
14+
tsconfigRootDir: import.meta.dirname,
15+
},
16+
},
17+
rules: {
18+
"@typescript-eslint/explicit-module-boundary-types": "error",
19+
"@typescript-eslint/no-non-null-assertion": "error",
20+
"prefer-const": "error",
21+
"no-console": ["warn", { allow: ["warn", "error"] }],
22+
},
23+
},
24+
{ ignores: ["dist/", "coverage/", "*.config.*"] }
25+
);

package.json

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,35 @@
66
"scripts": {
77
"dev": "tsx watch src/index.ts",
88
"build": "tsc",
9-
"test": "node --test",
10-
"test:watch": "node --test --watch",
11-
"lint": "eslint src tests --ext .ts",
12-
"typecheck": "tsc --noEmit"
9+
"typecheck": "tsc --noEmit",
10+
"lint": "eslint src tests",
11+
"lint:fix": "eslint src tests --fix",
12+
"format": "prettier --write .",
13+
"test": "vitest run",
14+
"test:watch": "vitest",
15+
"test:coverage": "vitest run --coverage",
16+
"prepare": "husky"
17+
},
18+
"lint-staged": {
19+
"*.{ts,mts}": ["eslint --fix", "prettier --write"],
20+
"*.{js,mjs,cjs}": ["prettier --write"],
21+
"*.{json,md,yaml,yml}": ["prettier --write"]
1322
},
1423
"devDependencies": {
24+
"@commitlint/cli": "^19.0.0",
25+
"@commitlint/config-conventional": "^19.0.0",
26+
"@eslint/js": "^9.0.0",
1527
"@types/node": "^20.0.0",
16-
"@typescript-eslint/eslint-plugin": "^7.0.0",
17-
"@typescript-eslint/parser": "^7.0.0",
28+
"@vitest/coverage-v8": "^1.4.0",
1829
"eslint": "^9.0.0",
30+
"eslint-config-prettier": "^9.0.0",
31+
"husky": "^9.0.0",
32+
"lint-staged": "^15.0.0",
33+
"prettier": "^3.3.0",
1934
"tsx": "^4.7.0",
20-
"typescript": "^5.4.0"
35+
"typescript": "^5.4.0",
36+
"typescript-eslint": "^7.0.0",
37+
"vitest": "^1.4.0"
2138
},
2239
"dependencies": {
2340
"fastify": "^4.27.0"

0 commit comments

Comments
 (0)