Skip to content

Commit 407245e

Browse files
committed
add lefthook - lint fix, code format, build and test pre-commit, auto npm install on checkout and merge
1 parent 29b65b0 commit 407245e

File tree

3 files changed

+219
-1
lines changed

3 files changed

+219
-1
lines changed

lefthook.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# lefthook.yml
2+
# Configuration reference: https://lefthook.dev/configuration/
3+
4+
assert_lefthook_installed: true
5+
6+
output:
7+
- meta # Print lefthook version
8+
- summary # Print summary block (successful and failed steps)
9+
- empty_summary # Print summary heading when there are no steps to run
10+
- success # Print successful steps
11+
- failure # Print failed steps printing
12+
- execution # Print any execution logs (but prints if the execution failed)
13+
- execution_out # Print execution output (but still prints failed commands output)
14+
- execution_info # Print `EXECUTE > ...` logging
15+
- skips # Print "skip" (i.e. no files matched)
16+
17+
pre-commit:
18+
follow: true
19+
parallel: true
20+
jobs:
21+
- name: 'Lint'
22+
run: npx --no-install eslint --fix "{staged_files}"
23+
glob:
24+
- '*.ts'
25+
- '*.js'
26+
- '*.tsx'
27+
- '*.jsx'
28+
stage_fixed: true
29+
30+
- name: 'Code Formatting'
31+
run: npx --no-install prettier --write --ignore-unknown "{staged_files}"
32+
stage_fixed: true
33+
34+
- name: 'Build'
35+
run: npm run build
36+
stage_fixed: true
37+
38+
- name: 'Test'
39+
run: npm run fetch:spec-types && npx --no-install jest --passWithNoTests "{staged_files}"
40+
glob: '*.{ts,js,json}'
41+
stage_fixed: true
42+
43+
post-checkout:
44+
jobs:
45+
- name: 'Install Dependencies'
46+
run: npm install
47+
48+
post-merge:
49+
jobs:
50+
- name: 'Install Dependencies'
51+
run: npm install

package-lock.json

Lines changed: 164 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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
"examples:simple-server:w": "tsx --watch src/examples/server/simpleStreamableHttp.ts --oauth",
5757
"prepack": "npm run build:esm && npm run build:cjs",
5858
"lint": "eslint src/ && prettier --check .",
59+
"lint:fix": "eslint src/ --fix && prettier --write .",
60+
"prepare": "npx --no-install lefthook install",
5961
"test": "npm run fetch:spec-types && jest",
6062
"start": "npm run server",
6163
"server": "tsx watch --clear-screen=false src/cli.ts server",
@@ -90,8 +92,9 @@
9092
"@types/ws": "^8.5.12",
9193
"eslint": "^9.8.0",
9294
"eslint-config-prettier": "^10.1.8",
93-
"prettier": "3.6.2",
9495
"jest": "^29.7.0",
96+
"lefthook": "^1.13.6",
97+
"prettier": "3.6.2",
9598
"supertest": "^7.0.0",
9699
"ts-jest": "^29.2.4",
97100
"tsx": "^4.16.5",

0 commit comments

Comments
 (0)