diff --git a/lefthook.yml b/lefthook.yml index 9b642b7..66f0edf 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -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 \ No newline at end of file + 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 \ No newline at end of file diff --git a/project-specs.md b/project-specs.md index 86526ba..7142c24 100644 --- a/project-specs.md +++ b/project-specs.md @@ -38,12 +38,15 @@ typescript-lib-starter-tiny => https://github.com/tmueller/typescript-lib-starte `oxfmtrc`, `oxlintrc`, `sortpackagerc`, `EDITMSG`, `typescriptteam`, `gitmoji`, `dbaeumer`, `msvc`) and a few library names (`tslib`, `typefest`, `lefthook`). -- **Lefthook**: Pre-commit checks for (run in parallel): - - oxlint on staged JS/TS files - - oxfmt --check on staged JS/TS files - - cspell on staged files - - sort-package-json --check - - tsc --noEmit +- **Lefthook**: Pre-commit checks (run in parallel, lefthook v2 schema): + - `min_version: 2.0.0` + - `pre-commit.commands.oxlint` — `npx oxlint {staged_files}` on + staged `*.{ts,tsx,js,jsx,mjs,cjs}` files + - `pre-commit.commands.oxfmt` — `npx oxfmt --check {staged_files}` + on staged `*.{ts,tsx,js,jsx,mjs,cjs}` files + - `pre-commit.commands.cspell` — `npx cspell {staged_files}` + - `pre-commit.commands.sort-package-json` — `npx sort-package-json --check` + - `pre-commit.commands.typecheck` — `npx tsc --noEmit` `outdated` is intentionally NOT a pre-commit check (it can flag upstream patch releases that aren't actionable locally); it runs in CI and via the explicit `lefthook run outdated` command. @@ -173,7 +176,7 @@ typescript-lib-starter-tiny => https://github.com/tmueller/typescript-lib-starte - `fix:oxfmt`: `oxfmt src`. - `fix:package`: `sort-package-json --write`. (There is no `fix` aggregator in the scripts; run the `fix:*` scripts - individually or via the lefthook `commands:` block.) + individually.) ### HOOKS