Skip to content

Commit 78433aa

Browse files
authored
chore: add husky and lint-staged for pre-commit hooks (#9)
* chore: add husky and lint-staged for pre-commit hooks - Configure husky to run lint-staged before commits - Add lint-staged configuration to automatically run linting and formatting - Update package scripts to support new pre-commit workflow * chore: simplify husky pre-commit hook configuration * chore: add .prettierignore to exclude pnpm-lock.yaml from formatting * chore: minor formatting and pre-commit hook adjustments
1 parent 6a5bf33 commit 78433aa

File tree

4 files changed

+874
-2369
lines changed

4 files changed

+874
-2369
lines changed

.husky/pre-commit

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pnpm-lock.yaml

package.json

+14-3
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@
2424
},
2525
"scripts": {
2626
"build": "tsup && node -e \"require('fs').chmodSync('build/index.js', '755')\"",
27-
"prepare": "npm run build",
27+
"prepare": "husky",
2828
"watch": "tsup --watch",
2929
"inspector": "npx @modelcontextprotocol/inspector build/index.js",
30-
"lint": "eslint . --ext .ts,.js",
30+
"lint": "eslint . --ext .ts,.js --fix",
3131
"format": "prettier --write .",
32-
"test": "jest"
32+
"test": "jest",
33+
"lint-staged": "lint-staged"
3334
},
3435
"dependencies": {
3536
"@datadog/datadog-api-client": "^1.32.0",
@@ -44,6 +45,7 @@
4445
"@types/node": "^20.11.24",
4546
"eslint": "^9.21.0",
4647
"globals": "^16.0.0",
48+
"husky": "^9.1.7",
4749
"jest": "^29.7.0",
4850
"prettier": "^3.5.2",
4951
"ts-jest": "^29.2.6",
@@ -54,5 +56,14 @@
5456
},
5557
"engines": {
5658
"node": ">=16.17.0"
59+
},
60+
"lint-staged": {
61+
"*.{js,ts}": [
62+
"eslint --fix",
63+
"prettier --write"
64+
],
65+
"*.{json,md}": [
66+
"prettier --write"
67+
]
5768
}
5869
}

0 commit comments

Comments
 (0)