Skip to content

Commit 8a1eca3

Browse files
committed
Scaffold TypeScript CLI with strict config, oxlint, vitest, and pre-commit hooks
1 parent 974329e commit 8a1eca3

File tree

12 files changed

+545
-0
lines changed

12 files changed

+545
-0
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
validate:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: oven-sh/setup-bun@v2
16+
with:
17+
bun-version: latest
18+
19+
- name: Install dependencies
20+
run: bun install
21+
22+
- name: Lint
23+
run: bun run lint
24+
25+
- name: Format check
26+
run: bun run format:check
27+
28+
- name: Type check
29+
run: bun x tsc --noEmit
30+
31+
- name: Test
32+
run: bun run test
33+
34+
- name: Build
35+
run: bun run build:ts

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
node_modules
2+
dist
3+
4+
# Lock files (only bun.lock is used)
5+
yarn.lock
6+
package-lock.json
7+
8+
# Editor
9+
.idea
10+
.vscode
11+
*.swp
12+
*.swo
13+
14+
# OS
15+
.DS_Store
16+
Thumbs.db
17+
18+
# Environment
19+
.env
20+
.env.local

.husky/pre-commit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bunx lint-staged
2+
bun run test

.oxfmtrc.jsonc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"printWidth": 100,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": true,
7+
"trailingComma": "es5"
8+
}

.oxlintrc.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"rules": {
4+
"no-unused-vars": "error",
5+
"no-console": "off",
6+
"eqeqeq": "error",
7+
"no-var": "error",
8+
"prefer-const": "error",
9+
"no-empty": "error",
10+
"no-useless-catch": "error",
11+
"no-self-compare": "error",
12+
"no-constant-condition": "error",
13+
"no-unreachable": "error",
14+
"no-loss-of-precision": "error",
15+
"no-debugger": "error",
16+
"no-duplicate-case": "error",
17+
"no-fallthrough": "error",
18+
"no-unsafe-finally": "error",
19+
"no-sparse-arrays": "error",
20+
"no-template-curly-in-string": "error",
21+
"valid-typeof": "error",
22+
"typescript/no-floating-promises": "error",
23+
"typescript/no-misused-promises": "error"
24+
},
25+
"ignorePatterns": ["dist", "node_modules"]
26+
}

bun.lock

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

package.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"name": "workout-cli",
3+
"version": "0.1.0",
4+
"description": "Workout CLI",
5+
"type": "module",
6+
"bin": {
7+
"workout": "./dist/index.js"
8+
},
9+
"files": [
10+
"dist"
11+
],
12+
"scripts": {
13+
"dev": "bun --watch src/index.ts",
14+
"build": "rm -rf ./dist && bun run build:ts && bun link",
15+
"build:ts": "tsc && chmod +x dist/index.js",
16+
"test": "vitest run",
17+
"test:watch": "vitest",
18+
"lint": "oxlint --type-aware --tsconfig=tsconfig.json src/",
19+
"format": "oxfmt src/ test/",
20+
"format:check": "oxfmt --check src/ test/",
21+
"check": "bun run lint && bun run format:check && bun x tsc --noEmit",
22+
"validate": "bun run check && bun run test && bun run build:ts",
23+
"prepare": "husky"
24+
},
25+
"engines": {
26+
"bun": ">=1.3.5"
27+
},
28+
"dependencies": {
29+
"commander": "^11.1.0",
30+
"zod": "^4.3.4"
31+
},
32+
"devDependencies": {
33+
"@types/bun": "^1.3.5",
34+
"@types/node": "^22.8.1",
35+
"husky": "^9.1.7",
36+
"lint-staged": "^16.2.7",
37+
"oxfmt": "^0.21.0",
38+
"oxlint": "^1.36.0",
39+
"oxlint-tsgolint": "^0.11.1",
40+
"typescript": "^5.6.3",
41+
"vitest": "^4.0.18"
42+
},
43+
"lint-staged": {
44+
"*.ts": [
45+
"oxlint --type-aware --tsconfig=tsconfig.json",
46+
"oxfmt"
47+
]
48+
},
49+
"license": "MIT"
50+
}

src/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bun
2+
import { Command } from 'commander';
3+
4+
const program = new Command();
5+
6+
program.name('workout').description('Workout CLI').version('0.1.0');
7+
8+
program.parse();

test/example.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { describe, it, expect } from 'vitest';
2+
3+
describe('example', () => {
4+
it('should pass', () => {
5+
expect(1 + 1).toBe(2);
6+
});
7+
});

tsconfig.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2022",
4+
"module": "ESNext",
5+
"moduleResolution": "Bundler",
6+
"outDir": "./dist",
7+
"rootDir": "./src",
8+
"esModuleInterop": true,
9+
"resolveJsonModule": true,
10+
"types": ["node", "bun"],
11+
"declaration": false,
12+
"sourceMap": false,
13+
"noEmitOnError": true,
14+
"strict": true,
15+
"forceConsistentCasingInFileNames": true,
16+
"skipLibCheck": true,
17+
"noUncheckedIndexedAccess": true,
18+
"noImplicitOverride": true,
19+
"noPropertyAccessFromIndexSignature": true,
20+
"exactOptionalPropertyTypes": true,
21+
"noFallthroughCasesInSwitch": true,
22+
"noUnusedLocals": true,
23+
"noUnusedParameters": true
24+
},
25+
"include": ["src/**/*"],
26+
"exclude": ["node_modules", "dist"]
27+
}

0 commit comments

Comments
 (0)