Skip to content

Commit 9584dd8

Browse files
feat: add lint-staged with pre-commit hooks for src/ directory
- Add husky (9.1.7) and lint-staged (16.2.3) dependencies - Configure lint-staged to run eslint and prettier on src/**/*.{ts,tsx} files - Add pre-commit hook to run lint-staged - Add post-checkout hook to run yarn install - Add pre-push hook to prevent direct pushes to main - Add .venv to .prettierignore to fix lint:check
1 parent 7d5d0ab commit 9584dd8

File tree

6 files changed

+238
-4
lines changed

6 files changed

+238
-4
lines changed

.husky/post-checkout

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yarn install

.husky/pre-commit

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

.husky/pre-push

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
branch_name="$(git symbolic-ref --short HEAD)"
2+
if [ "$branch_name" = "main" ]; then
3+
echo "Pushing directly to main is not allowed."
4+
exit 1
5+
fi

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ node_modules
44
**/package.json
55
!/package.json
66
jupyterlab_deepnote
7+
.venv

package.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"install:extension": "jlpm build",
4848
"lint": "jlpm stylelint && jlpm prettier && jlpm eslint",
4949
"lint:check": "jlpm stylelint:check && jlpm prettier:check && jlpm eslint:check",
50+
"prepare": "husky",
5051
"prettier": "jlpm prettier:base --write --list-different",
5152
"prettier:base": "prettier \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
5253
"prettier:check": "jlpm prettier:base --check",
@@ -83,7 +84,9 @@
8384
"eslint": "^8.36.0",
8485
"eslint-config-prettier": "^8.8.0",
8586
"eslint-plugin-prettier": "^5.0.0",
87+
"husky": "9.1.7",
8688
"jest": "^29.2.0",
89+
"lint-staged": "16.2.3",
8790
"mkdirp": "^1.0.3",
8891
"npm-run-all2": "^7.0.1",
8992
"prettier": "^3.0.0",
@@ -98,6 +101,12 @@
98101
"typescript": "~5.8.0",
99102
"yjs": "^13.5.0"
100103
},
104+
"lint-staged": {
105+
"src/**/*.{ts,tsx}": [
106+
"eslint --cache --fix",
107+
"prettier --write"
108+
]
109+
},
101110
"sideEffects": [
102111
"style/*.css",
103112
"style/index.js"
@@ -201,5 +210,6 @@
201210
"selector-no-vendor-prefix": null,
202211
"value-no-vendor-prefix": null
203212
}
204-
}
213+
},
214+
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
205215
}

0 commit comments

Comments
 (0)