🔧 Migrate lefthook config to v2 schema
The previous config was a hybrid of v1 (jobs: array) and v1
(top-level commands: block) that no longer validates under
lefthook 2.x. lefthook 2.0.0's schema has top-level 'commands:'
set to 'false'; the v1 jobs: array form still works, but the
orphan named-commands block at the top was silently invalid
(caught by 'lefthook validate').
Migrate to the v2-native 'commands:' (named) form under the hook:
pre-commit:
parallel: true
commands:
oxlint:
glob: ...
run: npx oxlint {staged_files}
...
Changes:
- Add 'min_version: 2.0.0' to declare the v2 schema explicitly
- Replace pre-commit.jobs: array with pre-commit.commands: (named)
- Inline the glob on each command (was a top-level property on each
job in v1)
- Remove the orphan top-level 'commands:' block — it was never
referenced by any hook, and v2 forbids it
- Update project-specs.md: drop the dangling reference to the
lefthook 'commands:' block (it was the dead top-level one);
describe the v2 commands: form
Verified:
- 'lefthook validate' reports 'All good'
- 'lefthook run pre-commit' executes all 5 hooks (oxlint, oxfmt,
sort-package-json, typecheck, cspell); globs correctly skip hooks
on non-matching files (e.g. lefthook.yml alone) and run them on
TS/JS changes
- 'npm run check' exits 0
- 'lefthook dump' shows the normalized v2 config
This commit is contained in:
1 parent
9bc87aab87
commit
45b6c141e8
2 files changed
+25
-34
No files matched your search
+15
-27
@@ -1,29 +1,17 @@
|
||||
min_version: 2.0.0
|
||||
|
||||
pre-commit:
|
||||
parallel: true
|
||||
jobs:
|
||||
- name: oxlint
|
||||
glob: "*.{ts,tsx,js,jsx,mjs,cjs}"
|
||||
run: npx oxlint {staged_files}
|
||||
- name: oxfmt
|
||||
glob: "*.{ts,tsx,js,jsx,mjs,cjs}"
|
||||
run: npx oxfmt --check {staged_files}
|
||||
- name: cspell
|
||||
run: npx cspell {staged_files}
|
||||
- name: sort-package-json
|
||||
run: npx sort-package-json --check
|
||||
- name: typecheck
|
||||
run: npx tsc --noEmit
|
||||
|
||||
commands:
|
||||
typecheck:
|
||||
run: npm run check:tsc
|
||||
spell:
|
||||
run: npm run check:cspell
|
||||
sort:
|
||||
run: npm run check:package
|
||||
lint:
|
||||
run: npm run check:oxlint
|
||||
format:
|
||||
run: npm run check:oxfmt
|
||||
outdated:
|
||||
run: npm run check:outdated
|
||||
commands:
|
||||
oxlint:
|
||||
glob: "*.{ts,tsx,js,jsx,mjs,cjs}"
|
||||
run: npx oxlint {staged_files}
|
||||
oxfmt:
|
||||
glob: "*.{ts,tsx,js,jsx,mjs,cjs}"
|
||||
run: npx oxfmt --check {staged_files}
|
||||
cspell:
|
||||
run: npx cspell {staged_files}
|
||||
sort-package-json:
|
||||
run: npx sort-package-json --check
|
||||
typecheck:
|
||||
run: npx tsc --noEmit
|
||||
Reference in new issue
Block a user