@vwala/tooling-config 1.3.0 → 1.3.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vwala BV
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -71,7 +71,7 @@ Biome's own rules carry the [naming](#naming) and [export](#exports) conventions
71
71
  | `no-vwala-class-prefix` | No `vwala:` Tailwind prefix in apps — it only resolves inside the design system's precompiled stylesheet. Apps only. |
72
72
  | `use-alias-imports` | No relative import crossing two or more parent directories (`../../`) — reach it through the project's configured alias. A single `../` to a sibling folder stays fine. Warns only. |
73
73
  | `use-given-when-then-test-names` | Every `test(...)` title reads GIVEN … WHEN … THEN … |
74
- | `use-pnpm-scripts` | No `npm run` / `npx` / `yarn` in a script — use `pnpm run`, `pnpm dlx`. `package.json` only. |
74
+ | `use-pnpm-scripts` | No `npm run` / `npx` / `yarn` in a script — use `pnpm run`, `pnpm dlx`. `package.json` only; `npx` in `preinstall` is exempt. |
75
75
  | `use-tests-folder-location` | Test files live in a `__tests__/` folder, never colocated with the implementation. |
76
76
 
77
77
  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.
@@ -202,10 +202,16 @@ Existence and non-emptiness are all that is checked. The convention asks for a g
202
202
 
203
203
  Vwala repositories install with pnpm. `use-pnpm-scripts` covers the `package.json` scripts and the `pnpm` convention check covers everything Biome cannot parse — a `package-lock.json`, `npm-shrinkwrap.json`, `yarn.lock` or `bun.lock` tracked beside `pnpm-lock.yaml`, a missing `pnpm-lock.yaml`, a root `package.json` that does not pin `"packageManager": "pnpm@<version>"`, and `npm`/`npx`/`yarn` invocations inside git hooks, workflows, shell scripts and Dockerfiles. Markdown is out of scope: documentation quotes a third party's install line as a citation, and a stale README is a review problem rather than a build-breaking one.
204
204
 
205
- Two exemptions are deliberate, and both are load-bearing rather than courtesies:
205
+ Four exemptions are deliberate, and all of them are load-bearing rather than courtesies:
206
206
 
207
207
  - **`npm publish`, `npm view`, `npm pkg`, `npm --version`.** npm is matched on its install and run verbs, not on the bare word, because OIDC trusted publishing needs the npm CLI — this package's own release workflow runs all four.
208
208
  - **`npx --no -- <bin>`.** It resolves the *locally installed* binary and refuses to fetch one, which is both the behaviour you want in a hook and what keeps zizmor's `adhoc-packages` rule quiet. Bare `npx` is still flagged, because it silently pulls from the registry.
209
+ - **`npx` in a `preinstall` script.** `preinstall` runs *before* `node_modules` exists, so `--no` has no local binary to resolve and adding the tool as a devDependency does not help — the hook still runs first. That makes the canonical `"preinstall": "npx only-allow pnpm"` guard the one npx call the rule cannot ask you to rewrite. Only the npx half relaxes: `npm` and `yarn` in a `preinstall` are still flagged, and every other lifecycle hook (`prepare` included) runs after install and stays strict.
210
+ - **Global installs — `npm i -g`, `npm install --global`, `--location=global`.** A runner installing a CLI writes no lockfile and resolves nothing from the project's tree, which is the entire rationale for the rule. This one is the convention check only; a `package.json` script that installs into the machine's global bin is still flagged, because that is a different smell from a CI step. The scan stops at the first shell separator, so `npm ci && npm i -g vercel` still reports the `npm ci`.
211
+
212
+ > **Do not reach for `pnpm dlx only-allow pnpm`.** It looks like the obvious rewrite and it silently disables the guard: `only-allow` decides by reading `npm_config_user_agent`, and `pnpm dlx` spawns the child with *pnpm's own* user agent, so the check passes no matter which package manager started the install. `npm install` then completes and writes a `package-lock.json` — the exact failure the guard exists to prevent. The same trap applies to any tool that inspects `npm_config_user_agent`. Note also that pnpm leaves that variable *unset* when it runs a lifecycle script, so a hand-rolled replacement must treat absent as "fine" and fail only on a present, non-pnpm agent.
213
+
214
+ > **`pnpm add --global` is not a drop-in for `npm install --global` on GitHub runners.** pnpm uses `$PNPM_HOME/bin` as its global bin directory and refuses to install unless that directory is on `PATH`, while `pnpm/action-setup` puts `$PNPM_HOME` itself on `PATH`. A workflow that wants pnpm here has to add `echo "$PNPM_HOME/bin" >> "$GITHUB_PATH"` first. Installing *npm itself* (`npm install --global npm@x`, for a CLI new enough for OIDC trusted publishing) should stay on npm regardless — it is the bootstrap for the first exemption above.
209
215
 
210
216
  > **A repository that deliberately uses another package manager** keeps it — switching is a dedicated change, not a drive-by. The check honours that on its own: it is a no-op unless the repository opts in by naming pnpm in `packageManager` or tracking a `pnpm-lock.yaml`. Biome cannot see a lockfile, though, so the plugin has no such escape hatch — drop its entry from your own `plugins` array.
211
217
 
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@vwala/tooling-config",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "type": "module",
5
5
  "description": "Shared tooling configuration for Vwala repositories",
6
- "license": "UNLICENSED",
6
+ "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "git+https://github.com/vwala-be/tooling-config.git"
@@ -80,7 +80,13 @@ for (const file of files) {
80
80
  // `payment.service.ts` is a name plus two extensions; the convention allows a
81
81
  // dot-separated responsibility suffix, so every part has to be kebab-case
82
82
  // rather than just the part before the first dot.
83
+ // Dotfiles produce a leading empty segment (`.foo.ts` → `["", "foo", "ts"]`);
84
+ // that segment is the hidden-file marker, not a name to validate — same idea
85
+ // as RESERVED_FOLDER's `\..+` exemption for directories.
83
86
  const parts = basename(file).split(".");
87
+ if (parts[0] === "") {
88
+ parts.shift();
89
+ }
84
90
  const offending = parts.find((part) => !KEBAB_CASE.test(part));
85
91
  if (offending !== undefined) {
86
92
  report({
@@ -27,6 +27,10 @@
27
27
  * trusted publishing needs the npm CLI, and this package's own release workflow
28
28
  * runs all four. `npx --no` is allowed for the same reason the shipped
29
29
  * commit-msg hook uses it: it resolves the LOCAL binary and refuses to fetch.
30
+ * Global installs (`npm i -g`, `npm install --global`) are allowed too: a CI
31
+ * runner installing a CLI writes no lockfile and resolves nothing from the
32
+ * project's tree, which is the whole of the rationale above. Installing npm
33
+ * itself that way is the bootstrap for an exemption this script already grants.
30
34
  *
31
35
  * Markdown is deliberately out of scope. Documentation quotes a third party's
32
36
  * install line as a citation, and a stale README is a review problem rather
@@ -50,9 +54,19 @@ const COMMENT_LINE = /^\s*(#|\/\/)/;
50
54
  // alternation Rust's regex forces on the plugin.
51
55
  const NPM_VERBS =
52
56
  "install|i|ci|add|run|run-script|exec|x|test|start|update|uninstall|remove|rm|link|rebuild|prune|dedupe|init|create";
57
+ // A global flag anywhere in the same command exempts the install, which is the
58
+ // one deliberate divergence from the plugin. `npm install --global vercel@x` on
59
+ // a runner installs a CLI: it writes no lockfile and resolves nothing from the
60
+ // project's tree, so it cannot cause the divergence this rule exists to
61
+ // prevent. `pnpm add --global` is not a drop-in on GitHub runners —
62
+ // pnpm/action-setup puts `$PNPM_HOME` on PATH but pnpm wants `$PNPM_HOME/bin`
63
+ // there, so the install errors out until the workflow adds that line itself.
64
+ // The scan stops at the first shell separator so `npm ci && npm i -g x` still
65
+ // reports the `npm ci`.
66
+ const GLOBAL_FLAG = String.raw`(?![^;&|]*[ \t](?:-g|--global|--location=global)\b)`;
53
67
  const FORBIDDEN_INVOCATION = new RegExp(
54
68
  String.raw`(?:^|[;&|(]|\bRUN\s+|\brun:\s*)\s*` +
55
- String.raw`(?:npm[ \t]+(?:${NPM_VERBS})\b|yarn(?=[ \t]|$)|npx(?![ \t]+--no)(?=[ \t]|$))`,
69
+ String.raw`(?:npm[ \t]+(?:${NPM_VERBS})\b${GLOBAL_FLAG}|yarn(?=[ \t]|$)|npx(?![ \t]+--no)(?=[ \t]|$))`,
56
70
  );
57
71
 
58
72
  const files = git(["ls-files"]).filter(
@@ -36,6 +36,24 @@
36
36
  // exception is spelled out by expanding the alternatives that may follow
37
37
  // `npx `.
38
38
  //
39
+ // `preinstall` is exempt from the npx half, which is why the query binds the
40
+ // member's own name as well as its value. `npx --no` cannot work there:
41
+ // `preinstall` runs BEFORE node_modules exists, so there is no local binary to
42
+ // resolve and `--no` refuses to fetch one — declaring the tool as a
43
+ // devDependency does not help, because the hook still runs first. The canonical
44
+ // `"preinstall": "npx only-allow pnpm"` guard is therefore unsatisfiable under
45
+ // the rule as written. `pnpm dlx` is NOT the substitute for that particular
46
+ // script: it spawns the child with pnpm's own `npm_config_user_agent`, so
47
+ // `only-allow` sees pnpm no matter which package manager started the install
48
+ // and passes every time — the guard silently stops guarding. npm and yarn stay
49
+ // flagged in `preinstall`; only the fetch-a-binary half relaxes.
50
+ //
51
+ // Global installs (`npm i -g`) stay flagged here but are exempt in
52
+ // _scripts/check-pnpm.mjs. A CI runner installing a CLI does not touch the
53
+ // project's dependency tree; a package.json script that installs into the
54
+ // machine's global bin is a different smell, and Rust's regex has no lookahead
55
+ // to express "install, but not with a global flag somewhere after it".
56
+ //
39
57
  // biome.json scopes this to `["**/package.json"]`, which matches the root file
40
58
  // and every nested one. The glob is not redundant with `language json`: without
41
59
  // it the plugin would also lint tsconfig.json, app.json, and the fixture
@@ -51,10 +69,16 @@
51
69
  // See: .agents/skills/vwala-conventions/references/prefer-pnpm.md
52
70
  language json
53
71
 
54
- JsonMember(value=$command) as $node where {
72
+ JsonMember(name=$name, value=$command) as $node where {
55
73
  $node <: within JsonMember(name=$section) where {
56
74
  $section <: r"\"scripts\""
57
75
  } ,
58
- $command <: r"(?:\"|.*[;&|(])[ \t]*(?:npm[ \t]+(?:install|i|ci|add|run|run-script|exec|x|test|start|update|uninstall|remove|rm|link|rebuild|prune|dedupe|init|create)\b|yarn[ \t\";&|]|npx[ \t]+(?:--no[a-zA-Z0-9]|--n[^o]|--[^n]|-[^-]|[^-\t ])).*",
76
+ or {
77
+ $command <: r"(?:\"|.*[;&|(])[ \t]*(?:npm[ \t]+(?:install|i|ci|add|run|run-script|exec|x|test|start|update|uninstall|remove|rm|link|rebuild|prune|dedupe|init|create)\b|yarn[ \t\";&|]).*",
78
+ and {
79
+ $name <: not r"\"preinstall\"",
80
+ $command <: r"(?:\"|.*[;&|(])[ \t]*npx[ \t]+(?:--no[a-zA-Z0-9]|--n[^o]|--[^n]|-[^-]|[^-\t ]).*"
81
+ }
82
+ },
59
83
  register_diagnostic(span=$command, message="Run this through pnpm — `pnpm install`, `pnpm add`, `pnpm run`, `pnpm dlx`. npm and yarn in a pnpm repo write a second lockfile and resolve a different tree than CI installs. `npx --no -- <bin>` is the one exception: it runs the locally installed binary and refuses to fetch.", severity="error")
60
84
  }