@vwala/tooling-config 1.0.0 → 1.2.0

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
@@ -9,12 +9,25 @@ src/
9
9
  ├── biome/ Biome config + custom GritQL rules (consumed via npm)
10
10
  │ ├── biome.config.json
11
11
  │ └── plugins/
12
+ ├── commitlint/ Commit-message rules + git hooks (consumed via npm and GitHub Actions)
13
+ │ ├── action.yml
14
+ │ ├── commitlint.config.js
15
+ │ └── hooks/
16
+ ├── syncpack/ pnpm catalog policy (consumed via npm)
17
+ │ └── syncpack.config.json
18
+ ├── typescript/ tsconfig presets (consumed via npm)
19
+ │ ├── base.json
20
+ │ ├── bundler.json
21
+ │ ├── node.json
22
+ │ ├── react-library.json
23
+ │ ├── nextjs.json
24
+ │ └── expo.json
12
25
  └── zizmor/ GitHub Actions security policy (consumed via GitHub Actions)
13
26
  ├── action.yml
14
27
  └── zizmor.yml
15
28
  ```
16
29
 
17
- The two tools are consumed differently — npm for anything a local toolchain reads, a GitHub Action for anything only CI runs — but they version together off the same git tag.
30
+ The tools are consumed differently — npm for anything a local toolchain reads, a GitHub Action for anything only CI runs — but they version together off the same git tag.
18
31
 
19
32
  ---
20
33
 
@@ -52,19 +65,136 @@ On top of Biome's `recommended` preset, four GritQL plugins enforce Vwala conven
52
65
 
53
66
  Each plugin file carries a header comment explaining the rule and linking to the governing reference in the [`vwala-conventions`](https://github.com/vwala-be/skills) skill. The plugins have tests in `src/biome/plugins/__tests__/` that drive the real Biome binary over fixture workspaces, so a rule that silently stops matching fails CI.
54
67
 
68
+ ### Naming
69
+
70
+ Two of Biome's own rules carry the naming convention, both at `warn`:
71
+
72
+ | Rule | Enforces |
73
+ | --- | --- |
74
+ | `useFilenamingConvention` | Filenames are kebab-case. Every dot-separated part counts, so `payment.service.ts`, `complete-invoice.command-handler.ts`, `invoice.types.ts` and `invoice.test.ts` all pass while `paymentService.ts` does not. |
75
+ | `useNamingConvention` | `camelCase` variables and functions, `PascalCase` types, classes, interfaces and components, `CONSTANT_CASE` for module-level constants. |
76
+
77
+ They are warnings because the convention applies to new code and asks that existing files be renamed only when meaningfully touched — a repository does not have to rename its way in. `useNamingConvention` deliberately does not check object literal or type properties: those keys are usually dictated by an external payload rather than chosen. `strictCase` is off, so `HTTPServer` is accepted alongside `HttpServer`.
78
+
79
+ `check-naming` (see [Convention checks](#convention-checks)) supplies the two halves the rules cannot express — folder names, which Biome never sees, and an error for files **added since the base ref**, which no static severity can express. Existing offenders are printed as warnings and leave the exit code at 0; a new file or a new folder that breaks the convention exits 1. The base ref defaults to `origin/main` — set `NAMING_BASE_REF` for a differently named default branch, and note that a shallow CI clone that cannot resolve it degrades the check to warnings only, so fetch enough history for `git merge-base` to work.
80
+
81
+ `__tests__`, `__mocks__`, `_scripts`, hidden folders, and the `[slug]` / `(group)` / `@slot` segments Next.js and Expo give meaning to are exempt from the folder check.
82
+
55
83
  ### Test layout boundaries
56
84
 
57
- `use-tests-folder-location` can only check syntax — a GritQL plugin cannot see its own file path. The path-level halves of that convention (no `tests/` folder, no non-test files in `__tests__/`, no production code importing test code) live in a script you run yourself:
85
+ `use-tests-folder-location` can only check syntax — a GritQL plugin cannot see its own file path. The path-level halves of that convention — no `tests/` folder, no non-test files in `__tests__/`, no production code importing test code — are the second of the [convention checks](#convention-checks).
86
+
87
+ ### Convention checks
88
+
89
+ Some conventions are about paths rather than syntax, and Biome reasons about syntax. Those live in scripts, behind one entry point:
90
+
91
+ ```jsonc
92
+ {
93
+ "scripts": {
94
+ "check-conventions": "node node_modules/@vwala/tooling-config/src/_scripts/check-conventions.mjs"
95
+ }
96
+ }
97
+ ```
98
+
99
+ | Check | Enforces |
100
+ | --- | --- |
101
+ | `naming` | Folders are kebab-case, and a file added since the base ref is named kebab-case — the error half of the [naming](#naming) rules. |
102
+ | `test layout` | The path-level halves of [test layout boundaries](#test-layout-boundaries). |
103
+
104
+ Wire that single script into your own preflight and new checks arrive with an upgrade, rather than as another `&&` you have to add by hand. It runs every check even after one fails — a bad filename and a misplaced test are independent problems, and seeing both in one run beats fixing one to discover the other. Each check is still a standalone script under `src/**/_scripts/` if you want to run one on its own.
105
+
106
+ Every check reads the repository through `git`, so run this from the repository root — and in CI, from a checkout deep enough for `git merge-base` to reach the default branch. With `actions/checkout` that means `fetch-depth: 0`; on a shallow clone the naming check cannot tell a new file from an old one and silently reports everything as a warning.
107
+
108
+ ---
109
+
110
+ ## pnpm catalog
111
+
112
+ Every external dependency in a pnpm workspace must be declared once in the `pnpm-workspace.yaml` catalog and referenced everywhere as `catalog:`.
113
+
114
+ The rule exists because of a specific failure. `next-intl` was declared as `^4.13.2` in three apps; an install re-resolved it to `4.13.4`, which brought `use-intl@4.13.4` with it, while `platform-i18n` and `app-mobile` still pinned `use-intl@4.13.2`. Two copies of `use-intl` in the tree, and type errors that pointed everywhere except the actual cause. Nothing looked inconsistent beforehand — every declaration read `^4.13.2`. The drift arrived with a resolution, not with an edit, which is why the rule is unconditional: **a dependency used by only one package is still cataloged**, because the second use is exactly what nobody notices adding.
115
+
116
+ ```bash
117
+ pnpm add -Dw syncpack
118
+ ```
58
119
 
59
120
  ```jsonc
60
121
  {
61
122
  "scripts": {
62
- "check-test-boundaries": "node node_modules/@vwala/tooling-config/src/biome/plugins/_scripts/check-test-layout.mjs"
123
+ "check-catalog": "syncpack lint --config ./node_modules/@vwala/tooling-config/src/syncpack/syncpack.config.json"
63
124
  }
64
125
  }
65
126
  ```
66
127
 
67
- It reads tracked files from `git ls-files`, so run it from the repository root.
128
+ Run it from the repository root, and add it to the repo's `isEverythingOk`.
129
+
130
+ Syncpack has no `extends`, so this cannot be wired the way `biome.json` is — unknown top-level keys are a hard error, not a warning. If a repo needs to override something, spread the config from a `.syncpackrc.mjs` instead:
131
+
132
+ ```js
133
+ import base from "@vwala/tooling-config/syncpack" with { type: "json" };
134
+
135
+ export default { ...base };
136
+ ```
137
+
138
+ That spread is shallow: replacing `versionGroups` replaces all of them, including the exemptions the config depends on. Read the comments in `syncpack.config.json` before overriding it.
139
+
140
+ ### What is in scope
141
+
142
+ `dependencies`, `devDependencies` and `optionalDependencies`, in every workspace package **and in the root manifest** — root dependencies install a real copy too, so a root `typescript@^5.7` alongside a package's `typescript@^5.9` is the same bug in the tooling layer.
143
+
144
+ `peerDependencies` are deliberately excluded. A peer range is a compatibility statement, intentionally wide; collapsing `>=18` to `catalog:` would pin a published package to one version of its own peer. The devDependency that actually installs the copy is in scope, so nothing is lost.
145
+
146
+ `workspace:`, `link:` and `file:` specifiers are exempt — all three resolve relative to the declaring package, so there is nothing for a central catalog to hold.
147
+
148
+ ### Migrating
149
+
150
+ `syncpack fix` rewrites specifiers to `catalog:` and writes the entries into `pnpm-workspace.yaml`, preserving comments and key order.
151
+
152
+ > **It picks the winner for you.** Where two packages disagree, `fix` takes the highest range and says so only in passing. That is usually right and occasionally an unannounced major bump, so resolve the genuine disagreements by hand first, then let `fix` do the mechanical rest. Re-run `pnpm install` and typecheck afterwards.
153
+
154
+ When two packages genuinely need different versions, use a [named catalog](https://pnpm.io/catalogs) (`catalog:react18`) rather than a literal range. Note that once more than one catalog exists, every dependency must live in exactly one of them — syncpack reports anything ambiguous as an unfixable error.
155
+
156
+ ### Stopping drift at the source
157
+
158
+ Set `catalogMode: strict` in `pnpm-workspace.yaml` (pnpm >= 10.12) so `pnpm add` writes catalog entries instead of literal ranges.
159
+
160
+ > **That is not a substitute for the CI check.** `catalogMode` applies only when `pnpm add` runs. It does not re-validate existing manifests on install, so a hand-edited `package.json` or a bad merge passes straight through. The two are complementary: `catalogMode` prevents most drift, `syncpack lint` catches the rest.
161
+
162
+ ---
163
+
164
+ ## TypeScript
165
+
166
+ ```bash
167
+ pnpm add -D @vwala/tooling-config typescript
168
+ ```
169
+
170
+ ```json
171
+ {
172
+ "extends": "@vwala/tooling-config/typescript/nextjs"
173
+ }
174
+ ```
175
+
176
+ Anything you add alongside `extends` overrides the preset for that key. In a monorepo each workspace package needs its own `devDependency` on `@vwala/tooling-config`, because pnpm only lets a package resolve what its own `package.json` declares — and `extends` is resolved from the directory of the `tsconfig.json` doing the extending.
177
+
178
+ ### Presets
179
+
180
+ `base` holds everything that is not negotiable — `strict`, `noUncheckedIndexedAccess`, `isolatedModules`, declaration output, ES2024 target — and the other five layer onto it.
181
+
182
+ | Preset | Extends | For |
183
+ | --- | --- | --- |
184
+ | `typescript/base` | — | Node-resolved libraries. `module`/`moduleResolution` are `NodeNext`, so relative imports need file extensions. |
185
+ | `typescript/bundler` | `base` | Anything a bundler resolves — `ESNext` + `Bundler`, so extensionless relative imports work. |
186
+ | `typescript/node` | `base` | Node services and CLIs. Narrows `lib` to `es2022` and pulls in `@types/node`. |
187
+ | `typescript/react-library` | `base` | React packages published for Node resolution. Adds the automatic JSX runtime. |
188
+ | `typescript/nextjs` | `bundler` | Next.js apps. Adds the `next` language-service plugin, `jsx: preserve` and `noEmit`. |
189
+ | `typescript/expo` | `bundler` | Expo apps. Adds the automatic JSX runtime and `noEmit`. |
190
+
191
+ Reach for `bundler` rather than `base` whenever the code is compiled by Vite, Next, Metro, esbuild or Vitest. Writing `"extends": ".../base"` and then overriding `module` and `moduleResolution` by hand is the same thing spelled longer.
192
+
193
+ The presets have tests in `src/typescript/__tests__/` that resolve each one through the real `tsc --showConfig` and assert the merged result, plus a check that every preset file is reachable through the package's `exports` map — a broken entry otherwise only surfaces in a consumer.
194
+
195
+ > **Requires TypeScript >= 5.7.** `base` targets ES2024, and 5.6 and earlier reject `es2024` for `--target` and `--lib` outright (`TS6046`). The presets are otherwise valid on 5.7, 6 and 7 alike.
196
+
197
+ > **TypeScript 7 dropped the compiler API.** `typescript@7` ships the native `tsc` binary and nothing else: no `lib/typescript.js` and no `lib/tsserver.js`. Editors cannot point "Use Workspace Version" at it, and any tool that reads the TypeScript API breaks. Pick the version your toolchain needs — `@typescript/typescript6` still carries the API — and note that `plugins` (such as Next's) configures the language service, so tsc 7 accepts it but never acts on it.
68
198
 
69
199
  ---
70
200
 
@@ -86,16 +216,122 @@ jobs:
86
216
  with:
87
217
  persist-credentials: false
88
218
 
219
+ - name: Mint a token that can read this repository
220
+ id: policy-token
221
+ uses: actions/create-github-app-token@v2
222
+ with:
223
+ app-id: ${{ vars.APP_ID }}
224
+ private-key: ${{ secrets.APP_PRIVATE_KEY }}
225
+ owner: vwala-be
226
+ repositories: tooling-config
227
+ permission-contents: read
228
+
89
229
  - uses: vwala-be/tooling-config/src/zizmor@v1.0.0
230
+ with:
231
+ token: ${{ steps.policy-token.outputs.token }}
90
232
  ```
91
233
 
92
234
  This needs the repository to be readable by the caller — already set (`Settings → Actions → General → Access → Accessible from repositories in the organization`), which is what lets a private repo share actions with other private repos in the org.
93
235
 
236
+ ### Why `token` is not optional in practice
237
+
238
+ Two different permissions are at play, and the org-level setting above only covers one of them.
239
+
240
+ The Actions *runtime* can check this action out. But zizmor then audits the very workflow that references it, and it resolves every `uses:` through the GitHub *API* using the job's token. The default `GITHUB_TOKEN` is scoped to the calling repository, so it cannot read `vwala-be/tooling-config`, and the `ref-confusion` audit fails hard:
241
+
242
+ ```text
243
+ fatal: no audit was performed
244
+ 'ref-confusion' audit failed on file://./.github/workflows/ci.yml
245
+
246
+ Caused by:
247
+ 0: error in 'ref-confusion' audit
248
+ 1: couldn't list branches for vwala-be/tooling-config
249
+ 2: can't access vwala-be/tooling-config: missing or you have no access
250
+ ```
251
+
252
+ That is an audit *error*, not a finding, so an inline `# zizmor: ignore[ref-confusion]` does not suppress it. Pass a token that can read this repository instead.
253
+
254
+ The GitHub App has to be installed on `tooling-config` with read access to contents and metadata. A repository-scoped installation token can still read public repositories, so the same token also covers the third-party actions in the audited workflows.
255
+
256
+ Our own CI never hits this: it dogfoods the action through the local `./src/zizmor` path, which gives zizmor no cross-repository `uses:` to resolve. The failure is invisible here by construction and only surfaces in consuming repositories.
257
+
94
258
  ### The policy is not overridable
95
259
 
96
260
  zizmor has no `extends` or import mechanism, and passing `--config` disables local config discovery entirely. That is deliberate here: a repository cannot quietly weaken the org-wide policy with its own `zizmor.yml`. Exceptions go in `src/zizmor/zizmor.yml` via a PR against this repo.
97
261
 
98
- Only operational knobs are exposed as action inputs — `inputs` (paths), `persona`, and `advanced-security`.
262
+ Only operational knobs are exposed as action inputs — `inputs` (paths), `persona`, `advanced-security`, and `token`. Severity and rule selection stay central.
99
263
 
100
264
  `advanced-security` is **off** by default. Uploading to the security tab needs GitHub Advanced Security, which private repositories only have under a licence; with it off you get inline PR annotations instead, which need no entitlement. The upstream action defaults this to `true` and refuses to run with both it and `annotations` enabled, so the wrapper derives `annotations` from it.
101
265
 
266
+ ---
267
+
268
+ ## Commit messages
269
+
270
+ Commit messages follow **Conventional Commits with a leading gitmoji** — every message needs an emoji plus a `type: subject`, e.g. `🎉 feat: add the widget`, `🐛 fix: correct the resolver`. The convention is enforced in two places: a local git hook that blocks a bad message as you commit, and a CI gate that blocks it at the PR (so it can't be skipped with `git commit --no-verify` or by never installing the hook).
271
+
272
+ ### Local: the shared config + hooks (npm)
273
+
274
+ ```bash
275
+ pnpm add -D @vwala/tooling-config @commitlint/cli commitizen cz-emoji-conventional husky lint-staged
276
+ ```
277
+
278
+ Point your `commitlint.config.js` at the shared config (it layers gitmoji on top of Conventional Commits, so you no longer declare `commitlint-config-gitmoji` yourself — it comes transitively):
279
+
280
+ ```js
281
+ // commitlint.config.js (use `export default { … }` if your repo is "type": "module")
282
+ module.exports = { extends: ["@vwala/tooling-config/commitlint"] };
283
+ ```
284
+
285
+ Wire the hooks into `package.json`. The `prepare` script runs husky, then the shipped installer copies the canonical `commit-msg`, `pre-commit` and `prepare-commit-msg` hooks into your `.husky/` — so every repo runs identical hooks from one source of truth:
286
+
287
+ ```jsonc
288
+ {
289
+ "scripts": {
290
+ "commit": "cz",
291
+ "prepare": "husky && node node_modules/@vwala/tooling-config/src/commitlint/_scripts/install-hooks.mjs"
292
+ },
293
+ "config": {
294
+ "commitizen": {
295
+ "path": "node_modules/cz-emoji-conventional",
296
+ "useGitmojis": true
297
+ }
298
+ },
299
+ "lint-staged": {
300
+ "*": ["biome check --write --no-errors-on-unmatched"]
301
+ }
302
+ }
303
+ ```
304
+
305
+ `pnpm install` runs `prepare`, so the hooks land on the first install. `pnpm commit` opens the interactive gitmoji + conventional prompt; `commit-msg` then lints whatever message you end up with, and `pre-commit` runs Biome over staged files via lint-staged.
306
+
307
+ ### CI: the bypass-proof gate (GitHub Action)
308
+
309
+ Add a step to the workflow you already have. Check out with `fetch-depth: 0` so the whole commit range is present, install first, then run the shared action over the PR's `base..head`:
310
+
311
+ ```yaml
312
+ jobs:
313
+ ci:
314
+ runs-on: ubuntu-latest
315
+ steps:
316
+ - uses: actions/checkout@v6
317
+ with:
318
+ persist-credentials: false
319
+ fetch-depth: 0
320
+
321
+ - uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
322
+ - uses: actions/setup-node@v6
323
+ with:
324
+ node-version: 24
325
+ cache: "pnpm"
326
+ - run: pnpm install --frozen-lockfile
327
+
328
+ - name: Lint commit messages
329
+ if: github.event_name == 'pull_request'
330
+ uses: vwala-be/tooling-config/src/commitlint@v1.1.0
331
+ with:
332
+ from: ${{ github.event.pull_request.base.sha }}
333
+ to: ${{ github.event.pull_request.head.sha }}
334
+ ```
335
+
336
+ The action pins and fetches nothing — it runs your repo's own installed commitlint against the shared config, so the commitlint version stays under your lockfile. Make it a **required status check** (branch protection) so a non-conventional commit can't be merged.
337
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vwala/tooling-config",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "description": "Shared tooling configuration for Vwala repositories",
6
6
  "license": "UNLICENSED",
@@ -17,22 +17,72 @@
17
17
  "!src/**/test-support"
18
18
  ],
19
19
  "exports": {
20
- "./biome": "./src/biome/biome.config.json"
20
+ "./biome": "./src/biome/biome.config.json",
21
+ "./commitlint": "./src/commitlint/commitlint.config.js",
22
+ "./syncpack": "./src/syncpack/syncpack.config.json",
23
+ "./typescript/base": "./src/typescript/base.json",
24
+ "./typescript/bundler": "./src/typescript/bundler.json",
25
+ "./typescript/node": "./src/typescript/node.json",
26
+ "./typescript/react-library": "./src/typescript/react-library.json",
27
+ "./typescript/nextjs": "./src/typescript/nextjs.json",
28
+ "./typescript/expo": "./src/typescript/expo.json"
29
+ },
30
+ "dependencies": {
31
+ "commitlint-config-gitmoji": "^2.3.1"
21
32
  },
22
33
  "scripts": {
23
34
  "lint": "biome check .",
24
35
  "format": "biome check --write .",
36
+ "typecheck": "tsc --noEmit",
25
37
  "test": "vitest run",
26
- "isEverythingOk": "biome ci . && vitest run"
38
+ "check-conventions": "node src/_scripts/check-conventions.mjs",
39
+ "commit": "cz",
40
+ "prepare": "husky && node src/commitlint/_scripts/install-hooks.mjs",
41
+ "isEverythingOk": "biome ci . && tsc --noEmit && vitest run && node src/_scripts/check-conventions.mjs"
42
+ },
43
+ "config": {
44
+ "commitizen": {
45
+ "path": "node_modules/cz-emoji-conventional",
46
+ "useGitmojis": true
47
+ }
48
+ },
49
+ "lint-staged": {
50
+ "*": [
51
+ "biome check --write --no-errors-on-unmatched"
52
+ ]
27
53
  },
28
54
  "devDependencies": {
29
55
  "@biomejs/biome": "2.5.6",
56
+ "@commitlint/cli": "^21.2.1",
30
57
  "@types/node": "^26.1.2",
31
58
  "@vwala/tooling-config": "link:.",
59
+ "commitizen": "^4.3.2",
60
+ "cz-emoji-conventional": "^1.2.1",
61
+ "husky": "^9.1.7",
62
+ "lint-staged": "^17.0.8",
63
+ "syncpack": "^15.3.2",
64
+ "typescript": "^7.0.2",
32
65
  "vitest": "^4.1.10"
33
66
  },
34
67
  "peerDependencies": {
35
- "@biomejs/biome": ">=2.5.0"
68
+ "@biomejs/biome": ">=2.5.0",
69
+ "@commitlint/cli": ">=19",
70
+ "syncpack": ">=15.0.0",
71
+ "typescript": ">=5.7.0"
72
+ },
73
+ "peerDependenciesMeta": {
74
+ "@biomejs/biome": {
75
+ "optional": true
76
+ },
77
+ "@commitlint/cli": {
78
+ "optional": true
79
+ },
80
+ "syncpack": {
81
+ "optional": true
82
+ },
83
+ "typescript": {
84
+ "optional": true
85
+ }
36
86
  },
37
87
  "packageManager": "pnpm@11.15.0"
38
88
  }
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * One entry point for every convention check that is a script rather than a
4
+ * Biome rule — so a repository wires up `check-conventions` once and keeps
5
+ * getting new checks as they ship, instead of growing another `&&` in
6
+ * `isEverythingOk` each time one is added.
7
+ *
8
+ * Unlike the `&&` chain it replaces, this runs every check even after one
9
+ * fails. A failing name and a misplaced test are independent problems, and
10
+ * seeing both in one run beats fixing one to discover the other.
11
+ *
12
+ * Each check stays runnable on its own — they are separate scripts with their
13
+ * own tests, and this only sequences them.
14
+ */
15
+ import { spawnSync } from "node:child_process";
16
+ import path from "node:path";
17
+ import { fileURLToPath } from "node:url";
18
+
19
+ // `src/` — the checks are addressed from there rather than relative to this
20
+ // file, so moving a check does not mean counting `..` hops.
21
+ const sourceRoot = path.resolve(
22
+ path.dirname(fileURLToPath(import.meta.url)),
23
+ "..",
24
+ );
25
+
26
+ const CHECKS = [
27
+ { name: "naming", script: "biome/_scripts/check-naming.mjs" },
28
+ {
29
+ name: "test layout",
30
+ script: "biome/plugins/_scripts/check-test-layout.mjs",
31
+ },
32
+ ];
33
+
34
+ const failed = [];
35
+
36
+ for (const check of CHECKS) {
37
+ console.log(`\n▸ ${check.name}`);
38
+ // The checks read the repository through git, so they inherit this process's
39
+ // working directory — which is why every one of them has to be run from the
40
+ // repository root.
41
+ const { status } = spawnSync(
42
+ process.execPath,
43
+ [path.join(sourceRoot, check.script)],
44
+ { stdio: "inherit" },
45
+ );
46
+ if (status !== 0) {
47
+ failed.push(check.name);
48
+ }
49
+ }
50
+
51
+ if (failed.length > 0) {
52
+ console.error(
53
+ `\n ✖ ${failed.length} of ${CHECKS.length} convention checks failed: ${failed.join(", ")}\n`,
54
+ );
55
+ process.exit(1);
56
+ }
57
+
58
+ console.log(`\n ✔ ${CHECKS.length} convention checks passed\n`);
@@ -0,0 +1,153 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * The two halves of the naming convention that Biome's `useFilenamingConvention`
4
+ * rule cannot express.
5
+ *
6
+ * 1. Folders. Biome only ever sees a filename, never the directories above it,
7
+ * so `SomeFolder/invoice.ts` passes the rule untouched.
8
+ * 2. Severity by age. The convention applies to new code and asks that existing
9
+ * files be renamed only when meaningfully touched, so the shared config sets
10
+ * the rule to `warn`. A Biome severity is fixed per glob and cannot depend on
11
+ * git history — this script supplies the other half, failing only on files
12
+ * added since the base ref. Existing offenders are printed as warnings and do
13
+ * not affect the exit code.
14
+ *
15
+ * Filenames are re-checked here rather than left to Biome, because the rule's
16
+ * warning never fails a build; a file added in this branch has to be an error
17
+ * somewhere, and this is that somewhere. Expect a new badly-named file to be
18
+ * reported twice — once by `biome ci` as a warning, once here as an error.
19
+ *
20
+ * Wire this into a repository's own check script and run it from the repository
21
+ * root. Set NAMING_BASE_REF when the default branch is not `origin/main`; when
22
+ * the base ref cannot be resolved at all (a shallow CI clone, a fresh repo with
23
+ * no remote) nothing counts as new and the script degrades to warnings only.
24
+ *
25
+ * See: .agents/skills/vwala-conventions/references/typescript-naming.md
26
+ */
27
+ import { execFileSync } from "node:child_process";
28
+
29
+ const BASE_REF = process.env.NAMING_BASE_REF ?? "origin/main";
30
+ const IGNORED_PREFIXES = [".agents/", ".claude/", ".husky/"];
31
+ const SOURCE_FILE = /\.[cm]?[jt]sx?$/;
32
+ const KEBAB_CASE = /^[a-z0-9]+(-[a-z0-9]+)*$/;
33
+ // Folder names that are a convention in their own right rather than a name:
34
+ // the test and story folders, the `_scripts` prefix this package uses for
35
+ // runnable helpers, anything hidden, and the bracket/paren/@ segments that
36
+ // Next.js and Expo routing give meaning to.
37
+ const RESERVED_FOLDER = /^(__[a-z]+__|_[a-z-]+|\..+|\[.+\]|\(.+\)|@.+|\+.+)$/;
38
+
39
+ const trackedFiles = git(["ls-files"]);
40
+ const untrackedFiles = git(["ls-files", "--others", "--exclude-standard"]);
41
+ const files = [...trackedFiles, ...untrackedFiles].filter(
42
+ (file) => !IGNORED_PREFIXES.some((prefix) => file.startsWith(prefix)),
43
+ );
44
+ const newFiles = new Set([...untrackedFiles, ...addedSinceBaseRef()]);
45
+
46
+ const errors = [];
47
+ const warnings = [];
48
+
49
+ /**
50
+ * A folder is reported once, not once per file inside it, and counts as new
51
+ * only when every file under it is new — a rename of a long-standing folder
52
+ * would otherwise read as an error the moment one file is added to it.
53
+ */
54
+ const folders = new Map();
55
+ for (const file of files) {
56
+ const segments = file.split("/");
57
+ for (const [index, segment] of segments.slice(0, -1).entries()) {
58
+ const folder = segments.slice(0, index + 1).join("/");
59
+ const existing = folders.get(folder);
60
+ folders.set(folder, {
61
+ segment,
62
+ isNew: (existing?.isNew ?? true) && newFiles.has(file),
63
+ });
64
+ }
65
+ }
66
+
67
+ for (const [folder, { segment, isNew }] of folders) {
68
+ if (!KEBAB_CASE.test(segment) && !RESERVED_FOLDER.test(segment)) {
69
+ report({
70
+ isNew,
71
+ violation: `${folder}/\n Folder "${segment}" is not kebab-case.`,
72
+ });
73
+ }
74
+ }
75
+
76
+ for (const file of files) {
77
+ if (!SOURCE_FILE.test(file)) {
78
+ continue;
79
+ }
80
+ // `payment.service.ts` is a name plus two extensions; the convention allows a
81
+ // dot-separated responsibility suffix, so every part has to be kebab-case
82
+ // rather than just the part before the first dot.
83
+ const parts = basename(file).split(".");
84
+ const offending = parts.find((part) => !KEBAB_CASE.test(part));
85
+ if (offending !== undefined) {
86
+ report({
87
+ isNew: newFiles.has(file),
88
+ violation: `${file}\n "${offending}" is not kebab-case. Name the file after its primary export: \`PaymentService\` → \`payment.service.ts\`.`,
89
+ });
90
+ }
91
+ }
92
+
93
+ if (warnings.length > 0) {
94
+ console.warn(
95
+ `\n ! ${warnings.length} naming violation(s) in existing files — rename when you next touch them:\n`,
96
+ );
97
+ for (const warning of warnings) {
98
+ console.warn(` ${warning}\n`);
99
+ }
100
+ }
101
+
102
+ if (errors.length > 0) {
103
+ console.error(`\n ✖ ${errors.length} naming violation(s) in new files:\n`);
104
+ for (const error of errors) {
105
+ console.error(` ${error}\n`);
106
+ }
107
+ process.exit(1);
108
+ }
109
+
110
+ console.log(" ✔ no naming violations in new files");
111
+
112
+ function report({ isNew, violation }) {
113
+ if (isNew) {
114
+ errors.push(violation);
115
+ } else {
116
+ warnings.push(violation);
117
+ }
118
+ }
119
+
120
+ function basename(file) {
121
+ const segments = file.split("/");
122
+ return segments[segments.length - 1];
123
+ }
124
+
125
+ /**
126
+ * Diffs the merge base against the working tree rather than against HEAD, so
127
+ * files added but not yet committed are held to the same standard as the ones
128
+ * already on the branch.
129
+ */
130
+ function addedSinceBaseRef() {
131
+ let mergeBase;
132
+ try {
133
+ mergeBase = execFileSync("git", ["merge-base", BASE_REF, "HEAD"], {
134
+ encoding: "utf8",
135
+ stdio: ["ignore", "pipe", "ignore"],
136
+ }).trim();
137
+ } catch {
138
+ console.warn(
139
+ ` ! Cannot resolve ${BASE_REF} — reporting every violation as a warning.`,
140
+ );
141
+ return [];
142
+ }
143
+ return git(["diff", "--diff-filter=A", "--name-only", mergeBase]);
144
+ }
145
+
146
+ function git(args) {
147
+ return execFileSync("git", args, {
148
+ encoding: "utf8",
149
+ maxBuffer: 1024 * 1024 * 64,
150
+ })
151
+ .split("\n")
152
+ .filter(Boolean);
153
+ }
@@ -124,7 +124,29 @@
124
124
  }
125
125
  }
126
126
  },
127
- "useBlockStatements": "warn"
127
+ "useBlockStatements": "warn",
128
+ "useFilenamingConvention": {
129
+ "level": "warn",
130
+ "options": {
131
+ "filenameCases": ["kebab-case"],
132
+ "requireAscii": true,
133
+ "strictCase": false
134
+ }
135
+ },
136
+ "useNamingConvention": {
137
+ "level": "warn",
138
+ "options": {
139
+ "conventions": [
140
+ {
141
+ "match": ".*",
142
+ "selector": { "kind": "objectLiteralProperty" }
143
+ },
144
+ { "match": ".*", "selector": { "kind": "typeProperty" } }
145
+ ],
146
+ "requireAscii": true,
147
+ "strictCase": false
148
+ }
149
+ }
128
150
  },
129
151
  "suspicious": {
130
152
  "noArrayIndexKey": "warn",
@@ -17,8 +17,10 @@
17
17
  * point rather than a leak:
18
18
  * - Storybook apps, whose whole job is rendering real fixtures, and whose
19
19
  * story helpers are not always named `*.stories.tsx`;
20
- * - `testSupport.ts` barrels, which re-export a package's own
21
- * `test-support/` through a published `"./test-support"` export.
20
+ * - `test-support.ts` barrels, which re-export a package's own
21
+ * `test-support/` through a published `"./test-support"` export. The
22
+ * camelCase spelling is still accepted, because the kebab-case filename
23
+ * rule only reaches code written since it shipped.
22
24
  *
23
25
  * See: .agents/skills/vwala-conventions/references/test-style.md
24
26
  */
@@ -29,7 +31,7 @@ const TEST_FILE = /\.test\.[cm]?[jt]sx?$/;
29
31
  // Matches any Storybook app rather than one repository's name for it.
30
32
  const STORY_FILE =
31
33
  /(\.stories\.[jt]sx?$|\/__stories__\/|^apps\/[^/]*storybook[^/]*\/)/;
32
- const TEST_SUPPORT_BARREL = /(^|\/)testSupport\.[cm]?ts$/;
34
+ const TEST_SUPPORT_BARREL = /(^|\/)(test-support|testSupport)\.[cm]?ts$/;
33
35
 
34
36
  const files = execFileSync("git", ["ls-files"], {
35
37
  encoding: "utf8",
@@ -5,6 +5,10 @@
5
5
  // shape and is not matched, and template-literal titles are skipped because the
6
6
  // interpolated text is not visible to the regex.
7
7
  //
8
+ // `$...` after the title absorbs the callback and any trailing timeout, so
9
+ // `test(title, fn)` and `test(title, fn, timeout)` are both visible. Matching
10
+ // exactly two arguments left the three-argument form unchecked.
11
+ //
8
12
  // This matches `test(...)` only, not `it(...)` — which is why the
9
13
  // `useConsistentTestIt` rule in biome.json has to stay on. Turn that off and a
10
14
  // title reverted to `it()` becomes invisible here.
@@ -13,7 +17,7 @@
13
17
  // makes Biome reformat the line to single quotes, which fails `biome ci`.
14
18
  //
15
19
  // See: .agents/skills/vwala-conventions/references/test-style.md
16
- `test($title, $body)` as $node where {
20
+ `test($title, $...)` as $node where {
17
21
  $title <: r"(?s)\"[^\"]*\"",
18
22
  $title <: not r"(?s).*GIVEN.*WHEN.*THEN.*",
19
23
  register_diagnostic(span=$title, message="Name the test GIVEN … WHEN … THEN … so the failure describes the scenario.", severity="error")
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Installs Vwala's shared git hooks into the consuming repository's `.husky/`.
4
+ *
5
+ * husky itself (run first, via `"prepare": "husky && node …/install-hooks.mjs"`)
6
+ * points `core.hooksPath` at `.husky/` and creates its internal `.husky/_/`.
7
+ * This script then copies the shipped hook templates from the package's
8
+ * `../hooks/` folder into `.husky/`, so every repo runs byte-identical
9
+ * `commit-msg`, `pre-commit` and `prepare-commit-msg` hooks from one source of
10
+ * truth. It overwrites on every run — the shipped copy is canonical — and is
11
+ * safe to run repeatedly.
12
+ *
13
+ * It writes into `process.cwd()`, which is the repo root during the `prepare`
14
+ * lifecycle, and reads the templates relative to its own location, so it works
15
+ * both here (dogfooding, `src/commitlint/hooks`) and from a consumer's
16
+ * `node_modules/@vwala/tooling-config/src/commitlint/hooks`.
17
+ */
18
+ import { chmod, copyFile, mkdir, readdir } from "node:fs/promises";
19
+ import path from "node:path";
20
+ import { fileURLToPath } from "node:url";
21
+
22
+ const scriptDirectory = path.dirname(fileURLToPath(import.meta.url));
23
+ const hooksSource = path.resolve(scriptDirectory, "..", "hooks");
24
+ const huskyDirectory = path.join(process.cwd(), ".husky");
25
+
26
+ const hooks = await readdir(hooksSource);
27
+ await mkdir(huskyDirectory, { recursive: true });
28
+
29
+ for (const hook of hooks) {
30
+ const destination = path.join(huskyDirectory, hook);
31
+ await copyFile(path.join(hooksSource, hook), destination);
32
+ // Git only runs a hook that is executable.
33
+ await chmod(destination, 0o755);
34
+ }
35
+
36
+ console.log(` ✔ installed ${hooks.length} git hook(s) into .husky/`);
@@ -0,0 +1,43 @@
1
+ name: Vwala commitlint
2
+ description: >-
3
+ Lint a range of commit messages with Vwala's shared conventional-commit +
4
+ gitmoji config.
5
+
6
+ # Runs commitlint over a commit range using the repository's own installed
7
+ # @commitlint/cli and the shared @vwala/tooling-config/commitlint config — so the
8
+ # convention the local commit-msg hook enforces is enforced again in CI, where it
9
+ # cannot be skipped with `git commit --no-verify` or by never installing the
10
+ # hook. This is the bypass-proof half of the enforcement; the husky hook is the
11
+ # fast-feedback half.
12
+ #
13
+ # The caller must (1) check out with `fetch-depth: 0` so the whole commit range
14
+ # is present, and (2) install dependencies first, so `node_modules/.bin/commitlint`
15
+ # and the shared config exist. The action pins nothing and fetches nothing — it
16
+ # reuses what the repository already declares, keeping the commitlint version
17
+ # under the consumer's lockfile rather than this action.
18
+
19
+ inputs:
20
+ from:
21
+ description: >-
22
+ Ref or SHA to lint commits from (exclusive). For a pull request, the base
23
+ SHA (e.g. github.event.pull_request.base.sha).
24
+ required: true
25
+ to:
26
+ description: Ref or SHA to lint commits to (inclusive).
27
+ required: false
28
+ default: HEAD
29
+
30
+ runs:
31
+ using: composite
32
+ steps:
33
+ # `${{ inputs.* }}` is routed through env and referenced as "$VAR" rather than
34
+ # interpolated straight into the script, so a crafted ref can't break out of
35
+ # the command (zizmor: template-injection). `npx --no` resolves the locally
36
+ # installed binary and refuses to fetch one, so this never becomes an
37
+ # unpinned package pull (zizmor: adhoc-packages).
38
+ - name: Lint commit messages
39
+ shell: bash
40
+ env:
41
+ FROM: ${{ inputs.from }}
42
+ TO: ${{ inputs.to }}
43
+ run: npx --no -- commitlint --from "$FROM" --to "$TO" --verbose
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Vwala's shared commitlint config — the one place the commit-message convention
3
+ * lives. Consumers extend it from their own `commitlint.config.js`:
4
+ *
5
+ * export default { extends: ["@vwala/tooling-config/commitlint"] };
6
+ *
7
+ * It layers on `commitlint-config-gitmoji`, which is the gitmoji flavor of
8
+ * Conventional Commits: every message needs a leading gitmoji plus a
9
+ * conventional `type: subject`. commitlint resolves nested `extends` recursively
10
+ * and looks the package up relative to THIS file, so `commitlint-config-gitmoji`
11
+ * is a runtime dependency of @vwala/tooling-config — a consumer no longer
12
+ * declares it directly.
13
+ *
14
+ * `rules` is intentionally left empty: it is the seam for Vwala-specific
15
+ * overrides on top of the gitmoji base. Keep the allowed types/emoji aligned
16
+ * with the vocabulary in `.github/release-drafter.yml` so commit messages and
17
+ * PR-title labeling do not drift.
18
+ *
19
+ * @type {import("@commitlint/types").UserConfig}
20
+ */
21
+ export default {
22
+ extends: ["gitmoji"],
23
+ rules: {},
24
+ };
@@ -0,0 +1 @@
1
+ npx --no -- commitlint --edit "$1"
@@ -0,0 +1 @@
1
+ pnpm lint-staged
@@ -0,0 +1,7 @@
1
+ # Skip cz whenever Git is already supplying a commit message.
2
+ # That covers amend, rebase, merge, squash, and cherry-pick flows.
3
+ if [ -n "${2:-}" ]; then
4
+ exit 0
5
+ fi
6
+
7
+ exec < /dev/tty && npx cz --hook || true
@@ -0,0 +1,33 @@
1
+ {
2
+ "// rule": "Every external dependency must be declared in the pnpm-workspace.yaml catalog and referenced as `catalog:`. Two declarations of the same package re-resolve independently, which is how a second copy lands in the tree even when the ranges look identical today.",
3
+ "// source": "No `source` key on purpose. Syncpack discovers packages from pnpm-workspace.yaml `packages:` and then appends the root package.json. Setting `source` (default sourceMode `replace`) replaces discovery and silently drops the root manifest, whose dependencies install a real copy too. Override with `sourceMode: extend` if you must.",
4
+ "// peers": "peerDependencies are out of scope. A peer range is a deliberately wide compatibility statement; collapsing it to `catalog:` would pin a published package to one version of its own peer. The devDependency that actually installs the copy is in scope.",
5
+ "// customTypes": "optionalDependencies is not one of syncpack's built-in dependency types (dev, local, overrides, peer, pnpmOverrides, prod, resolutions). Without the custom type below, the string \"optional\" passes schema validation and silently matches nothing. Never add a `//` comment key inside `customTypes` itself — it is parsed as a custom type, fails to deserialise, and syncpack falls back to its default version group without reporting an error.",
6
+ "customTypes": {
7
+ "optional": {
8
+ "strategy": "versionsByName",
9
+ "path": "optionalDependencies"
10
+ }
11
+ },
12
+ "versionGroups": [
13
+ {
14
+ "// order": "Must stay first. Version groups are first-match-wins, and `policy: catalog` does not exempt these itself — syncpack only refuses to catalog a package's own `version` field. Without this group, `syncpack fix` rewrites workspace:, link: and file: specifiers to `catalog:`, which breaks them: all three resolve relative to the declaring package.",
15
+ "// types": "`link` is a real specifier type at runtime but is missing from the JSON schema's enum, so editors will not suggest it. Verified against syncpack 15.3.2.",
16
+ "label": "Locally-resolved specifiers cannot be centralised in a catalog",
17
+ "dependencyTypes": ["prod", "dev", "optional"],
18
+ "specifierTypes": ["workspace-protocol", "file", "link"],
19
+ "isIgnored": true
20
+ },
21
+ {
22
+ "// scope": "Registry ranges, tags, npm: aliases, git refs and tarball URLs all stay in scope — each is a globally resolvable identifier a catalog can legitimately centralise.",
23
+ "label": "Every external dependency comes from the pnpm catalog",
24
+ "dependencyTypes": ["prod", "dev", "optional"],
25
+ "policy": "catalog"
26
+ },
27
+ {
28
+ "// order": "Must stay last, and must exist. Anything no explicit group claims falls into syncpack's built-in \"Default Version Group\", which enforces highest-semver agreement across packages — a second, unrelated rule this config does not intend to impose. Without this group, peerDependencies, overrides and resolutions are all quietly linted for version agreement.",
29
+ "label": "Everything else is outside the scope of this config",
30
+ "isIgnored": true
31
+ }
32
+ ]
33
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "declaration": true,
5
+ "declarationMap": true,
6
+ "esModuleInterop": true,
7
+ "incremental": false,
8
+ "isolatedModules": true,
9
+ "lib": ["es2024", "DOM", "DOM.Iterable"],
10
+ "module": "NodeNext",
11
+ "moduleDetection": "force",
12
+ "moduleResolution": "NodeNext",
13
+ "noUncheckedIndexedAccess": true,
14
+ "resolveJsonModule": true,
15
+ "skipLibCheck": true,
16
+ "strict": true,
17
+ "target": "ES2024"
18
+ }
19
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./base.json",
4
+ "compilerOptions": {
5
+ "module": "ESNext",
6
+ "moduleResolution": "Bundler"
7
+ }
8
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./bundler.json",
4
+ "compilerOptions": {
5
+ "allowJs": true,
6
+ "jsx": "react-jsx",
7
+ "noEmit": true
8
+ }
9
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./bundler.json",
4
+ "compilerOptions": {
5
+ "plugins": [{ "name": "next" }],
6
+ "allowJs": true,
7
+ "jsx": "preserve",
8
+ "noEmit": true
9
+ }
10
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./base.json",
4
+ "compilerOptions": {
5
+ "lib": ["es2022"],
6
+ "types": ["node"]
7
+ }
8
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./base.json",
4
+ "compilerOptions": {
5
+ "jsx": "react-jsx"
6
+ }
7
+ }
@@ -28,6 +28,26 @@ inputs:
28
28
  entitlement and no security-events permission.
29
29
  required: false
30
30
  default: "false"
31
+ token:
32
+ description: >-
33
+ GitHub API token for zizmor's online audits. Defaults to the calling
34
+ job's GITHUB_TOKEN, which is scoped to the calling repository alone.
35
+
36
+ A consuming repository normally has to override this. Adding this action
37
+ puts `vwala-be/tooling-config/src/zizmor@vX.Y.Z` into that repository's
38
+ own workflow, and zizmor resolves every `uses:` through the API. This
39
+ repository is private, so the default token cannot read it and the
40
+ `ref-confusion` audit fails hard with "missing or you have no access".
41
+ That is an audit error rather than a finding, so no `# zizmor: ignore`
42
+ can suppress it. Pass a token that can read this repository instead —
43
+ for example one minted by `actions/create-github-app-token` scoped to
44
+ `tooling-config` with `permission-contents: read`.
45
+
46
+ Our own CI never hits this, because it dogfoods the action through the
47
+ local `./src/zizmor` path and so has no cross-repository `uses:` to
48
+ resolve.
49
+ required: false
50
+ default: ${{ github.token }}
31
51
 
32
52
  runs:
33
53
  using: composite
@@ -51,6 +71,7 @@ runs:
51
71
  version: "1.29.0"
52
72
  persona: ${{ inputs.persona }}
53
73
  advanced-security: ${{ inputs.advanced-security }}
74
+ token: ${{ inputs.token }}
54
75
  # The action rejects advanced-security and annotations both being true.
55
76
  annotations: ${{ inputs.advanced-security == 'true' && 'false' || 'true' }}
56
77