@howells/husky 0.2.1 → 0.2.2

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
@@ -23,6 +23,8 @@ In `package.json`:
23
23
  }
24
24
  ```
25
25
 
26
+ Standard external lint-staged configuration files are supported as an alternative to the inline `package.json` entry. Use one when path-aware or computed commands are needed.
27
+
26
28
  That's it. On `pnpm install`, the hooks are installed automatically.
27
29
 
28
30
  ## What it does
@@ -61,7 +63,7 @@ Your `package.json` must have:
61
63
  - a `"prepush"` script appropriate to the repository, or both:
62
64
  - a `"typecheck"` script (e.g. `tsc --noEmit` or `turbo run typecheck`)
63
65
  - a `"lint"` script (e.g. `howells-lint` or `turbo run lint`)
64
- - `"lint-staged"` config using `howells-fix` (`howells-ox-fix` and `howells-format` still accepted, legacy)
66
+ - inline or standard external lint-staged configuration; static inline commands use `howells-fix` (`howells-ox-fix` and `howells-format` remain accepted for projects mid-migration)
65
67
 
66
68
  ## Why a package?
67
69
 
package/bin/detect.mjs CHANGED
@@ -16,6 +16,27 @@ export const lintStagedFormatterCommands = [
16
16
 
17
17
  export const recommendedLintStagedCommand = "howells-fix";
18
18
 
19
+ // Standard configuration names supported by lint-staged. Package-level files
20
+ // in a monorepo are discovered by lint-staged itself; the installer only needs
21
+ // to recognise the root configuration it is responsible for validating.
22
+ export const lintStagedConfigFileNames = [
23
+ ".lintstagedrc",
24
+ ".lintstagedrc.json",
25
+ ".lintstagedrc.yaml",
26
+ ".lintstagedrc.yml",
27
+ ".lintstagedrc.js",
28
+ ".lintstagedrc.mjs",
29
+ ".lintstagedrc.cjs",
30
+ "lint-staged.config.js",
31
+ "lint-staged.config.mjs",
32
+ "lint-staged.config.cjs",
33
+ "lint-staged.config.ts",
34
+ ];
35
+
36
+ export function findLintStagedConfigFile(exists) {
37
+ return lintStagedConfigFileNames.find((file) => exists(file));
38
+ }
39
+
19
40
  /**
20
41
  * Flatten a lint-staged config object into the list of command strings it runs.
21
42
  * Values may be a single command string or an array of them.
@@ -27,6 +27,7 @@ import path from "node:path";
27
27
 
28
28
  import {
29
29
  fallbackFailed,
30
+ findLintStagedConfigFile,
30
31
  lintStagedCommandValues,
31
32
  recommendedLintStagedCommand,
32
33
  shouldUseNpxFallback,
@@ -117,17 +118,21 @@ for (const hook of hooks) {
117
118
  const packageJsonPath = path.join(projectRoot, "package.json");
118
119
  if (existsSync(packageJsonPath)) {
119
120
  const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
121
+ const externalLintStagedConfig = findLintStagedConfigFile((file) =>
122
+ existsSync(path.join(projectRoot, file))
123
+ );
120
124
 
121
- if (!packageJson["lint-staged"]) {
125
+ if (!packageJson["lint-staged"] && !externalLintStagedConfig) {
122
126
  console.warn(
123
- '[@howells/husky] Warning: no "lint-staged" config found in package.json.'
127
+ "[@howells/husky] Warning: no inline or external lint-staged config found."
124
128
  );
125
129
  console.warn(
126
130
  ` Add: "lint-staged": { "*.{js,ts,jsx,tsx,json,jsonc,css}": "${recommendedLintStagedCommand}" }`
127
131
  );
128
132
  }
129
133
 
130
- // Check that the lint-staged command uses a supported Howells formatter.
134
+ // Inline static configs can be checked directly. External JavaScript configs
135
+ // may compute commands dynamically, so lint-staged owns their validation.
131
136
  const lsConfig = packageJson["lint-staged"];
132
137
  if (lsConfig) {
133
138
  const commands = lintStagedCommandValues(lsConfig);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@howells/husky",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Standardised git hooks for Howells projects. Immutable pre-commit and pre-push configuration.",
5
5
  "license": "MIT",
6
6
  "repository": {