@howells/husky 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -33,7 +33,7 @@ Runs `pnpm lint-staged` — formats staged files with the configured Howells for
33
33
 
34
34
  ### Pre-push
35
35
 
36
- Runs `pnpm typecheck` and `pnpm lint`. Both must pass before code reaches the remote.
36
+ Runs the project's `pnpm prepush` script when one exists, so each repository can define the narrowest appropriate gate for its own architecture. Projects without that script retain the backward-compatible `pnpm typecheck` followed by `pnpm lint` fallback. The selected gate must pass before code reaches the remote.
37
37
 
38
38
  Both run against the **working directory**, so their result only describes what is being pushed when the working directory is what is being pushed. Git names the refs on stdin, so the hook can tell:
39
39
 
@@ -58,8 +58,9 @@ What changed is that it is no longer silent. If an install replaces a hook whose
58
58
 
59
59
  Your `package.json` must have:
60
60
 
61
- - `"typecheck"` script (e.g. `tsc --noEmit` or `turbo run typecheck`)
62
- - `"lint"` script (e.g. `howells-lint` or `turbo run lint`)
61
+ - a `"prepush"` script appropriate to the repository, or both:
62
+ - a `"typecheck"` script (e.g. `tsc --noEmit` or `turbo run typecheck`)
63
+ - a `"lint"` script (e.g. `howells-lint` or `turbo run lint`)
63
64
  - `"lint-staged"` config using `howells-fix` (`howells-ox-fix` and `howells-format` still accepted, legacy)
64
65
 
65
66
  ## Why a package?
@@ -38,7 +38,11 @@ const packageRoot = path.resolve(scriptDir, "..");
38
38
  const projectRoot = process.cwd();
39
39
 
40
40
  // Skip in CI environments — hooks aren't needed there
41
- if (process.env.CI === "true" || process.env.VERCEL === "1") {
41
+ if (
42
+ process.env.HUSKY === "0" ||
43
+ process.env.CI === "true" ||
44
+ process.env.VERCEL === "1"
45
+ ) {
42
46
  process.exit(0);
43
47
  }
44
48
 
@@ -138,16 +142,17 @@ if (existsSync(packageJsonPath)) {
138
142
  }
139
143
  }
140
144
 
141
- // Check that typecheck and lint scripts exist
145
+ // Projects can own an appropriately scoped pre-push gate. Older projects
146
+ // retain the package's typecheck + lint fallback until they add one.
142
147
  const scripts = packageJson.scripts || {};
143
- if (!scripts.typecheck) {
148
+ if (!scripts.prepush && !scripts.typecheck) {
144
149
  console.warn(
145
- '[@howells/husky] Warning: no "typecheck" script found. Pre-push hook requires it.'
150
+ '[@howells/husky] Warning: no "prepush" or "typecheck" script found. Pre-push hook requires one.'
146
151
  );
147
152
  }
148
- if (!scripts.lint) {
153
+ if (!scripts.prepush && !scripts.lint) {
149
154
  console.warn(
150
- '[@howells/husky] Warning: no "lint" script found. Pre-push hook requires it.'
155
+ '[@howells/husky] Warning: no "prepush" or "lint" script found. Pre-push hook requires one.'
151
156
  );
152
157
  }
153
158
  }
package/hooks/pre-commit CHANGED
File without changes
package/hooks/pre-push CHANGED
@@ -54,5 +54,9 @@ if [ "$saw_ref" = "0" ]; then
54
54
  echo "[@howells/husky] No refs on stdin; checking the working directory."
55
55
  fi
56
56
 
57
- pnpm typecheck || exit 1
58
- pnpm lint || exit 1
57
+ if node -e 'const scripts = require("./package.json").scripts; process.exit(typeof scripts?.prepush === "string" ? 0 : 1)'; then
58
+ pnpm prepush
59
+ else
60
+ pnpm typecheck || exit 1
61
+ pnpm lint || exit 1
62
+ fi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@howells/husky",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Standardised git hooks for Howells projects. Immutable pre-commit and pre-push configuration.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -21,12 +21,6 @@
21
21
  "exports": {
22
22
  "./package.json": "./package.json"
23
23
  },
24
- "scripts": {
25
- "lint": "howells-check --config=oxlint.config.ts package.json bin hooks README.md oxlint.config.ts oxfmt.config.ts",
26
- "lint:fix": "howells-fix --config=oxlint.config.ts package.json bin hooks README.md oxlint.config.ts oxfmt.config.ts",
27
- "format": "howells-oxfmt --write package.json bin hooks README.md oxlint.config.ts oxfmt.config.ts",
28
- "test": "node --test bin/detect.test.mjs bin/pre-push.test.mjs"
29
- },
30
24
  "dependencies": {
31
25
  "husky": "^9.1.7",
32
26
  "lint-staged": "^16.4.0"
@@ -37,5 +31,10 @@
37
31
  "engines": {
38
32
  "node": ">=24.15.0"
39
33
  },
40
- "packageManager": "pnpm@11.11.0"
41
- }
34
+ "scripts": {
35
+ "lint": "howells-check --config=oxlint.config.ts package.json bin hooks README.md oxlint.config.ts oxfmt.config.ts",
36
+ "lint:fix": "howells-fix --config=oxlint.config.ts package.json bin hooks README.md oxlint.config.ts oxfmt.config.ts",
37
+ "format": "howells-oxfmt --write package.json bin hooks README.md oxlint.config.ts oxfmt.config.ts",
38
+ "test": "node --test bin/detect.test.mjs bin/pre-push.test.mjs"
39
+ }
40
+ }