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
17 lines
466 B
YAML
17 lines
466 B
YAML
min_version: 2.0.0
|
|
|
|
pre-commit:
|
|
parallel: true
|
|
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 |