Skip to content

Commit 88fd175

Browse files
chore: add lint-staged with pre-commit hooks for src/ directory (#18)
* 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 * fix: use jlpm instead of yarn in husky hooks - Update pre-commit hook to use 'jlpm exec lint-staged' - Update post-checkout hook to use 'jlpm install' - Aligns with jupyterlab-deepnote's package manager setup * fix: remove packageManager field from package.json The packageManager field was automatically added by yarn during initial development but should not be present since jupyterlab-deepnote uses jlpm (JupyterLab's yarn wrapper) for package management. --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent ec81dd0 commit 88fd175

File tree

6 files changed

+236
-3
lines changed

6 files changed

+236
-3
lines changed

.husky/post-checkout

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

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
jlpm exec 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: 9 additions & 0 deletions
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"

0 commit comments

Comments
 (0)