mirror of
https://github.com/logancyang/obsidian-copilot.git
synced 2026-07-22 07:50:24 +00:00
chore: fix pre-commit hook to enforce formatting and linting (#2297)
The pre-commit hook existed but was not executable and used raw prettier instead of lint-staged. This fixes: - Make .husky/pre-commit executable (was -rw-r--r--) - Use `npx lint-staged` instead of raw prettier/eslint commands - Remove deprecated husky v4 config from package.json (hooks key) - Remove unnecessary `git add` from lint-staged (auto-staged in v15) - Add eslint --fix to lint-staged for JS/TS files All contributors now get automatic formatting + linting on commit. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1f2539712d
commit
095a5f2011
2 changed files with 5 additions and 13 deletions
7
.husky/pre-commit
Normal file → Executable file
7
.husky/pre-commit
Normal file → Executable file
|
|
@ -1,6 +1 @@
|
|||
# .husky/pre-commit
|
||||
prettier $(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g') --write --ignore-unknown
|
||||
git update-index --again
|
||||
|
||||
# Add linting
|
||||
npm run lint
|
||||
npx lint-staged
|
||||
|
|
|
|||
11
package.json
11
package.json
|
|
@ -22,15 +22,12 @@
|
|||
},
|
||||
"keywords": [],
|
||||
"author": "Logan Yang",
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,jsx,ts,tsx,json,css,md}": [
|
||||
"prettier --write",
|
||||
"git add"
|
||||
"prettier --write"
|
||||
],
|
||||
"*.{js,jsx,ts,tsx}": [
|
||||
"eslint --fix --no-warn-ignored"
|
||||
]
|
||||
},
|
||||
"license": "AGPL-3.0",
|
||||
|
|
|
|||
Loading…
Reference in a new issue