Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

chore(scripts): add `lint:staged` script and update pre-commit hook

johaven5e41ee5a1b91
diff --git a/.husky/pre-commit b/.husky/pre-commit
index a845b850..a20a005c 100644
--- a/.husky/pre-commit
+++ b/.husky/pre-commit
@@ -1 +1 @@
-npm run lint
\ No newline at end of file
+npm run lint:staged
\ No newline at end of file
diff --git a/backend/package.json b/backend/package.json
index 131562ea..653c256d 100755
--- a/backend/package.json
+++ b/backend/package.json
@@ -20,6 +20,7 @@
"debug:circular:image": "madge ../dist/server/main.js --circular --image ../circular-dependencies.png",
"format": "prettier --write \\\\\\\"src/**/*.ts\\\\\\\" \\\\\\\"test/**/*.ts\\\\\\\"",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\"",
+ "lint:staged": "git diff --cached --name-only -z --diff-filter=ACM --relative -- . | grep -zE '^(src|apps|libs|test)/.*\\.ts$' | xargs -0 eslint",
"lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"start": "nest start",
"start:debug": "NODE_ENV=development nest start --debug --watch",
diff --git a/frontend/package.json b/frontend/package.json
index aba5afd2..a0efd8a0 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -16,6 +16,7 @@
"build": "ng build",
"build:dev": "ng build --configuration development",
"lint": "ng lint",
+ "lint:staged": "if git diff --cached --name-only --diff-filter=ACM --relative -- . | grep -q .; then ng lint; fi",
"lint:fix": "ng lint --fix",
"update:angular": "ng update @angular/cli@latest @angular/core@latest --allow-dirty"
},
diff --git a/package.json b/package.json
index c702329a..6fc3fa03 100755
--- a/package.json
+++ b/package.json
@@ -72,13 +72,14 @@
"frontend"
],
"scripts": {
- "build": "npm run build -ws",
+ "build": "npm run build --ws",
"release:build": "npm run build && node scripts/build/release.mjs",
"release:clean": "rm -rf release",
"bump:version": "npm run test && commit-and-tag-version",
- "bump:version:dry": "commit-and-tag-version --dry-run",
- "lint": "npm -ws run lint",
- "test": "npm -w backend test",
+ "bump:version:dry": "npm run test && commit-and-tag-version --dry-run",
+ "lint": "npm --ws run lint",
+ "lint:staged": "npm --ws run lint:staged",
+ "test": "npm --ws run lint && npm -w backend test",
"start": "node dist/server/main.js",
"reset": "rm -Rf frontend/node_modules frontend/.angular backend/node_modules node_modules .angular; npm cache clean --force",
"docker:build": "docker build -t $npm_package_name .",