@howells/husky 0.1.0 → 0.1.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 +5 -3
- package/bin/howells-husky.mjs +24 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ In `package.json`:
|
|
|
18
18
|
"prepare": "howells-husky"
|
|
19
19
|
},
|
|
20
20
|
"lint-staged": {
|
|
21
|
-
"*.{js,ts,jsx,tsx,json,jsonc,css}": "howells-
|
|
21
|
+
"*.{js,ts,jsx,tsx,json,jsonc,css}": "howells-ox-fix"
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
```
|
|
@@ -29,7 +29,9 @@ That's it. On `pnpm install`, the hooks are installed automatically.
|
|
|
29
29
|
|
|
30
30
|
### Pre-commit
|
|
31
31
|
|
|
32
|
-
Runs `pnpm lint-staged` — formats staged files with
|
|
32
|
+
Runs `pnpm lint-staged` — formats staged files with the configured Howells formatter.
|
|
33
|
+
Use `howells-ox-fix` for projects on the Ox lint path. `howells-format` remains supported
|
|
34
|
+
for older projects.
|
|
33
35
|
|
|
34
36
|
### Pre-push
|
|
35
37
|
|
|
@@ -41,7 +43,7 @@ Your `package.json` must have:
|
|
|
41
43
|
|
|
42
44
|
- `"typecheck"` script (e.g. `tsc --noEmit` or `turbo run typecheck`)
|
|
43
45
|
- `"lint"` script (e.g. `howells-lint` or `turbo run lint`)
|
|
44
|
-
- `"lint-staged"` config using `howells-format`
|
|
46
|
+
- `"lint-staged"` config using `howells-ox-fix` or `howells-format`
|
|
45
47
|
|
|
46
48
|
## Why a package?
|
|
47
49
|
|
package/bin/howells-husky.mjs
CHANGED
|
@@ -23,6 +23,24 @@ import { fileURLToPath } from "node:url";
|
|
|
23
23
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
24
24
|
const packageRoot = resolve(__dirname, "..");
|
|
25
25
|
const projectRoot = process.cwd();
|
|
26
|
+
const lintStagedFormatterCommands = ["howells-format", "howells-ox-fix"];
|
|
27
|
+
const recommendedLintStagedCommand = "howells-ox-fix";
|
|
28
|
+
|
|
29
|
+
function lintStagedCommandValues(config) {
|
|
30
|
+
return Object.values(config).flatMap((value) => {
|
|
31
|
+
if (typeof value === "string") {
|
|
32
|
+
return [value];
|
|
33
|
+
}
|
|
34
|
+
if (Array.isArray(value)) {
|
|
35
|
+
return value.filter((item) => typeof item === "string");
|
|
36
|
+
}
|
|
37
|
+
return [];
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function usesSupportedFormatter(command) {
|
|
42
|
+
return lintStagedFormatterCommands.some((formatter) => command.includes(formatter));
|
|
43
|
+
}
|
|
26
44
|
|
|
27
45
|
// Skip in CI environments — hooks aren't needed there
|
|
28
46
|
if (process.env.CI === "true" || process.env.VERCEL === "1") {
|
|
@@ -82,23 +100,21 @@ if (existsSync(packageJsonPath)) {
|
|
|
82
100
|
'[@howells/husky] Warning: no "lint-staged" config found in package.json.',
|
|
83
101
|
);
|
|
84
102
|
console.warn(
|
|
85
|
-
|
|
103
|
+
` Add: "lint-staged": { "*.{js,ts,jsx,tsx,json,jsonc,css}": "${recommendedLintStagedCommand}" }`,
|
|
86
104
|
);
|
|
87
105
|
}
|
|
88
106
|
|
|
89
|
-
// Check that the lint-staged command uses
|
|
107
|
+
// Check that the lint-staged command uses a supported Howells formatter.
|
|
90
108
|
const lsConfig = packageJson["lint-staged"];
|
|
91
109
|
if (lsConfig) {
|
|
92
|
-
const commands =
|
|
93
|
-
const usesHowells = commands.some(
|
|
94
|
-
(cmd) => typeof cmd === "string" && cmd.includes("howells-format"),
|
|
95
|
-
);
|
|
110
|
+
const commands = lintStagedCommandValues(lsConfig);
|
|
111
|
+
const usesHowells = commands.some(usesSupportedFormatter);
|
|
96
112
|
if (!usesHowells) {
|
|
97
113
|
console.warn(
|
|
98
|
-
"[@howells/husky] Warning: lint-staged should use
|
|
114
|
+
"[@howells/husky] Warning: lint-staged should use a supported Howells formatter.",
|
|
99
115
|
);
|
|
100
116
|
console.warn(
|
|
101
|
-
|
|
117
|
+
` Expected: "*.{js,ts,jsx,tsx,json,jsonc,css}": "${recommendedLintStagedCommand}"`,
|
|
102
118
|
);
|
|
103
119
|
}
|
|
104
120
|
}
|