Add pre-commit hooks (husky + lint-staged + prettier)

This commit is contained in:
haylan committed 2026-10-14 15:15:38 +02:00
1 parent aa89e07262
commit 8fce64c34e
4 files changed
+88 -1

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
npx lint-staged
npm run test
+3
View File
@@ -0,0 +1,3 @@
{
"*": "prettier --ignore-unknown --write"
}
+79
View File
@@ -16,6 +16,8 @@
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^26.6.4", "@types/node": "^26.6.4",
"husky": "^9.1.7",
"lint-staged": "^17.6.0",
"prettier": "^3.9.9", "prettier": "^3.9.9",
"typescript": "^7.0.2" "typescript": "^7.0.2"
}, },
@@ -2493,6 +2495,22 @@
"node": ">= 14" "node": ">= 14"
} }
}, },
"node_modules/husky": {
"version": "9.1.7",
"resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz",
"integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==",
"dev": true,
"license": "MIT",
"bin": {
"husky": "bin.js"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/typicode"
}
},
"node_modules/iconv-lite": { "node_modules/iconv-lite": {
"version": "0.7.3", "version": "0.7.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz",
@@ -2708,6 +2726,30 @@
"safe-buffer": "^5.0.1" "safe-buffer": "^5.0.1"
} }
}, },
"node_modules/lint-staged": {
"version": "17.6.0",
"resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-17.6.0.tgz",
"integrity": "sha512-nOhBfYkZEwkFtNzD5pK9s9LkcWoxJ+whLzEnhqi9nl7zTB5n7tg8+9iYgMGx2Wm3VlLu8cbNj0RACzY+nWi5iQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"picomatch": "^4.0.7",
"string-argv": "^0.3.2",
"tinyexec": "^1.3.1"
},
"bin": {
"lint-staged": "bin/lint-staged.js"
},
"engines": {
"node": ">=22.22.1"
},
"funding": {
"url": "https://opencollective.com/lint-staged"
},
"optionalDependencies": {
"yaml": "^2.9.1"
}
},
"node_modules/lru-cache": { "node_modules/lru-cache": {
"version": "11.5.3", "version": "11.5.3",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz",
@@ -3589,6 +3631,16 @@
"node": "^20.17.0 || >=22.9.0" "node": "^20.17.0 || >=22.9.0"
} }
}, },
"node_modules/string-argv": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.2.tgz",
"integrity": "sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.6.19"
}
},
"node_modules/string-width": { "node_modules/string-width": {
"version": "5.1.2", "version": "5.1.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz",
@@ -3701,6 +3753,16 @@
"node": ">=18" "node": ">=18"
} }
}, },
"node_modules/tinyexec": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.3.1.tgz",
"integrity": "sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=18"
}
},
"node_modules/tinyglobby": { "node_modules/tinyglobby": {
"version": "0.2.17", "version": "0.2.17",
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
@@ -3992,6 +4054,23 @@
"engines": { "engines": {
"node": ">=18" "node": ">=18"
} }
},
"node_modules/yaml": {
"version": "2.9.1",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.1.tgz",
"integrity": "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw==",
"dev": true,
"license": "ISC",
"optional": true,
"bin": {
"yaml": "bin.mjs"
},
"engines": {
"node": ">= 14.6"
},
"funding": {
"url": "https://github.com/sponsors/eemeli"
}
} }
} }
} }
+4 -1
View File
@@ -29,7 +29,8 @@
"test": "node --test", "test": "node --test",
"sync": "node scripts/sync-upstream.ts", "sync": "node scripts/sync-upstream.ts",
"generate": "node scripts/generate.ts", "generate": "node scripts/generate.ts",
"smoke": "node scripts/smoke.ts" "smoke": "node scripts/smoke.ts",
"prepare": "husky"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@@ -41,6 +42,8 @@
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^26.6.4", "@types/node": "^26.6.4",
"husky": "^9.1.7",
"lint-staged": "^17.6.0",
"prettier": "^3.9.9", "prettier": "^3.9.9",
"typescript": "^7.0.2" "typescript": "^7.0.2"
} }