@feigi/fleet-ctl 3.23.35 → 3.23.37

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.
Files changed (204) hide show
  1. package/package.json +1 -1
  2. package/scripts/main-checkout.mjs +1 -1
  3. package/scripts/member-write-guard.mjs +1 -1
  4. package/scripts/repo-root.mjs +1 -1
  5. package/skills/run-team/references/reaping.md +1 -1
  6. package/scripts/agent-test-dir-prose.test.mjs +0 -59
  7. package/scripts/agent-test.test.mjs +0 -1640
  8. package/scripts/ambient-git-vars-mjs-prose.test.mjs +0 -397
  9. package/scripts/ambient-git-vars-prose.test.mjs +0 -192
  10. package/scripts/ancestry-check-position-prose.test.mjs +0 -175
  11. package/scripts/apply-ruleset.test.mjs +0 -421
  12. package/scripts/arg-header-probes-prose.test.mjs +0 -394
  13. package/scripts/arg.test.mjs +0 -1354
  14. package/scripts/board-cli.test.mjs +0 -710
  15. package/scripts/board-identity.test.mjs +0 -429
  16. package/scripts/board-liveness-banner.test.mjs +0 -119
  17. package/scripts/board-prev-shape.test.mjs +0 -228
  18. package/scripts/board-tryparse-null.test.mjs +0 -119
  19. package/scripts/board.test.mjs +0 -3121
  20. package/scripts/brief-after-cut-prose.test.mjs +0 -53
  21. package/scripts/candidates-exit3-prose.test.mjs +0 -302
  22. package/scripts/candidates.test.mjs +0 -2312
  23. package/scripts/caveat-unification-prose.test.mjs +0 -98
  24. package/scripts/cell-readout.test.mjs +0 -615
  25. package/scripts/ci-comment-rot-prose.test.mjs +0 -2025
  26. package/scripts/ci-completes-premise-prose.test.mjs +0 -257
  27. package/scripts/ci-state-prose.test.mjs +0 -113
  28. package/scripts/ci-state.test.mjs +0 -1933
  29. package/scripts/ci-vacuous-green.test.mjs +0 -368
  30. package/scripts/citation-sweep-prose.test.mjs +0 -1712
  31. package/scripts/claim-lifecycle.test.mjs +0 -187
  32. package/scripts/claim-ticket.test.mjs +0 -1122
  33. package/scripts/closing-keyword-prose.test.mjs +0 -193
  34. package/scripts/cockpit-launch-idempotent-prose.test.mjs +0 -165
  35. package/scripts/cockpit-tick-nonblocking.test.mjs +0 -210
  36. package/scripts/compute-board.test.mjs +0 -1214
  37. package/scripts/compute-spend.test.mjs +0 -517
  38. package/scripts/consumer-technology-prose.test.mjs +0 -126
  39. package/scripts/cross-repo-citation-prose.test.mjs +0 -155
  40. package/scripts/cwd-isolation-pins.mjs +0 -83
  41. package/scripts/dedupe-guard-prose.test.mjs +0 -243
  42. package/scripts/delete-merged-branch.test.mjs +0 -576
  43. package/scripts/derive-testcmd.test.mjs +0 -595
  44. package/scripts/diff-stats.test.mjs +0 -404
  45. package/scripts/dispatch-block-golden-prose.test.mjs +0 -1130
  46. package/scripts/dispatch-block-pins-prose.test.mjs +0 -615
  47. package/scripts/dispositions-check.test.mjs +0 -936
  48. package/scripts/dispositions-gate-prose.test.mjs +0 -129
  49. package/scripts/drop-merged-label.test.mjs +0 -479
  50. package/scripts/exec-stub.mjs +0 -93
  51. package/scripts/exec-stub.test.mjs +0 -69
  52. package/scripts/expected-jobs-prose.test.mjs +0 -80
  53. package/scripts/fan-out-authorization-prose.test.mjs +0 -80
  54. package/scripts/filing-bar-seat-prose.test.mjs +0 -242
  55. package/scripts/filing-claim-bar-prose.test.mjs +0 -166
  56. package/scripts/finisher-died-prose.test.mjs +0 -31
  57. package/scripts/finisher-dispatch-premise-prose.test.mjs +0 -312
  58. package/scripts/finisher-halt-prose.test.mjs +0 -106
  59. package/scripts/finisher-name-prose.test.mjs +0 -134
  60. package/scripts/finisher-own-tree-prose.test.mjs +0 -299
  61. package/scripts/finisher-pin-race-prose.test.mjs +0 -339
  62. package/scripts/finisher-test-verdict-prose.test.mjs +0 -102
  63. package/scripts/fix-applier-correction-rules-prose.test.mjs +0 -202
  64. package/scripts/fix-applier-result-file-prose.test.mjs +0 -149
  65. package/scripts/fleet-bootstrap.test.mjs +0 -75
  66. package/scripts/fleet-heartbeat.test.mjs +0 -450
  67. package/scripts/fleet-provenance.test.mjs +0 -138
  68. package/scripts/fleet-run.test.mjs +0 -90
  69. package/scripts/fleet-state.test.mjs +0 -460
  70. package/scripts/fleet-tick-prose.test.mjs +0 -300
  71. package/scripts/fleet-tick.test.mjs +0 -2444
  72. package/scripts/force-with-lease-reason-prose.test.mjs +0 -184
  73. package/scripts/frontmatter-check.test.mjs +0 -436
  74. package/scripts/git-env.test.mjs +0 -149
  75. package/scripts/git-status-untracked-mode-sweep.test.mjs +0 -216
  76. package/scripts/gone-walk.test.mjs +0 -213
  77. package/scripts/gp-sep-invariant-prose.test.mjs +0 -188
  78. package/scripts/head-moved-after-label-prose.test.mjs +0 -233
  79. package/scripts/immutable-body-claim-prose.test.mjs +0 -204
  80. package/scripts/implementer-model-tier.test.mjs +0 -235
  81. package/scripts/inflight-citation-prose.test.mjs +0 -144
  82. package/scripts/inflight-exit2-prose.test.mjs +0 -81
  83. package/scripts/inflight-probe-guard-prose.test.mjs +0 -109
  84. package/scripts/inflight-scan-scope-prose.test.mjs +0 -57
  85. package/scripts/inflight.test.mjs +0 -2882
  86. package/scripts/injection-control-prose.test.mjs +0 -404
  87. package/scripts/install-root-audit.test.mjs +0 -464
  88. package/scripts/instrument-check-prose.test.mjs +0 -235
  89. package/scripts/instruments.test.mjs +0 -787
  90. package/scripts/is-cli.test.mjs +0 -99
  91. package/scripts/issue-tracker-prose.test.mjs +0 -71
  92. package/scripts/json.test.mjs +0 -364
  93. package/scripts/ledger-dispatch.test.mjs +0 -927
  94. package/scripts/ledger-grammar.test.mjs +0 -227
  95. package/scripts/ledger-read-require-file.test.mjs +0 -197
  96. package/scripts/ledger-rotate.test.mjs +0 -142
  97. package/scripts/ledger.test.mjs +0 -3436
  98. package/scripts/line-distance-prose.test.mjs +0 -245
  99. package/scripts/liveness-rationale-prose.test.mjs +0 -83
  100. package/scripts/locale-pin-prose.test.mjs +0 -189
  101. package/scripts/main-checkout.test.mjs +0 -332
  102. package/scripts/member-outcome-prose.test.mjs +0 -167
  103. package/scripts/member-outcomes-header.test.mjs +0 -129
  104. package/scripts/member-outcomes-prose.test.mjs +0 -63
  105. package/scripts/member-outcomes.test.mjs +0 -638
  106. package/scripts/member-prompt-prose.test.mjs +0 -165
  107. package/scripts/member-record.test.mjs +0 -541
  108. package/scripts/member-write-guard.test.mjs +0 -214
  109. package/scripts/merge-commit-probe-prose.test.mjs +0 -122
  110. package/scripts/merge-gate.test.mjs +0 -613
  111. package/scripts/muted-git-guard-sweep.test.mjs +0 -493
  112. package/scripts/net-ssh-precedence-prose.test.mjs +0 -91
  113. package/scripts/net-watchdog-prose.test.mjs +0 -79
  114. package/scripts/net.test.mjs +0 -211
  115. package/scripts/no-ci-gate-prose.test.mjs +0 -108
  116. package/scripts/no-undo-audit.test.mjs +0 -3961
  117. package/scripts/no-wave.test.mjs +0 -138
  118. package/scripts/node-floor-sweep.test.mjs +0 -611
  119. package/scripts/pointer-target-prose.test.mjs +0 -186
  120. package/scripts/pr-cost.test.mjs +0 -521
  121. package/scripts/pr-overlap.test.mjs +0 -692
  122. package/scripts/printf-die-sweep.test.mjs +0 -384
  123. package/scripts/prompt-renderer.mjs +0 -40
  124. package/scripts/prompt-renderer.test.mjs +0 -68
  125. package/scripts/prose-pin.mjs +0 -807
  126. package/scripts/prose-pin.test.mjs +0 -1034
  127. package/scripts/prove-merge.test.mjs +0 -995
  128. package/scripts/pull-table-relabel-prose.test.mjs +0 -60
  129. package/scripts/quiet-payload-prose.test.mjs +0 -222
  130. package/scripts/reap-cherry-check-prose.test.mjs +0 -80
  131. package/scripts/reap.test.mjs +0 -4432
  132. package/scripts/reaping-prose.test.mjs +0 -239
  133. package/scripts/reaping-reap-authorizers-prose.test.mjs +0 -112
  134. package/scripts/reaping-release-authorizers-prose.test.mjs +0 -85
  135. package/scripts/recipe-derivation-prose.test.mjs +0 -112
  136. package/scripts/recipe-prove.test.mjs +0 -1042
  137. package/scripts/refuter-scratch-prose.test.mjs +0 -135
  138. package/scripts/release-label-required-prose.test.mjs +0 -71
  139. package/scripts/release-label-split-prose.test.mjs +0 -184
  140. package/scripts/release-ticket-reap-pairing-prose.test.mjs +0 -63
  141. package/scripts/release-ticket.test.mjs +0 -5099
  142. package/scripts/renovate-release-contract.test.mjs +0 -379
  143. package/scripts/repo-root.test.mjs +0 -873
  144. package/scripts/reporter-output-rule-prose.test.mjs +0 -208
  145. package/scripts/review-agent-report-only.test.mjs +0 -49
  146. package/scripts/review-core-booking.test.mjs +0 -35
  147. package/scripts/review-core-cwd-isolation.test.mjs +0 -374
  148. package/scripts/review-core-reads.test.mjs +0 -478
  149. package/scripts/review-core-refuter-scratch.test.mjs +0 -148
  150. package/scripts/review-core-scratch-refusal.test.mjs +0 -64
  151. package/scripts/review-core-shared-test-run.test.mjs +0 -275
  152. package/scripts/review-core-snapshot-path.test.mjs +0 -830
  153. package/scripts/review-core-specialist-scratch.test.mjs +0 -191
  154. package/scripts/review-core-testcmd.test.mjs +0 -335
  155. package/scripts/review-core-unrun.test.mjs +0 -566
  156. package/scripts/review-core-unverified-discriminant.test.mjs +0 -208
  157. package/scripts/review-eval-resolver-path.test.mjs +0 -55
  158. package/scripts/review-host-fixture.mjs +0 -89
  159. package/scripts/review-in-run-retry.test.mjs +0 -211
  160. package/scripts/review-no-vendor-dispatch.test.mjs +0 -45
  161. package/scripts/review-path-default.test.mjs +0 -796
  162. package/scripts/review-runner-spawns.test.mjs +0 -95
  163. package/scripts/review-runner.test.mjs +0 -166
  164. package/scripts/review-tier-audit.test.mjs +0 -140
  165. package/scripts/run-artifact-pr-prose.test.mjs +0 -341
  166. package/scripts/run-merge-bot-prose.test.mjs +0 -1413
  167. package/scripts/run-team-local-hook.test.mjs +0 -442
  168. package/scripts/scratch-partition-invariant-prose.test.mjs +0 -74
  169. package/scripts/scripts-path-citation-sweep.test.mjs +0 -73
  170. package/scripts/section-between-guard-prose.test.mjs +0 -379
  171. package/scripts/select-dimensions.test.mjs +0 -674
  172. package/scripts/shared-refusal.test.mjs +0 -388
  173. package/scripts/shell-traps-prose.test.mjs +0 -504
  174. package/scripts/shortlist.test.mjs +0 -380
  175. package/scripts/slow-transport.mjs +0 -72
  176. package/scripts/snapshot-repo.test.mjs +0 -1006
  177. package/scripts/snapshot-runner-audience-prose.test.mjs +0 -130
  178. package/scripts/spend-view.test.mjs +0 -312
  179. package/scripts/staleness-qualifier-prose.test.mjs +0 -251
  180. package/scripts/staleness-verdict-prose.test.mjs +0 -142
  181. package/scripts/staleness.test.mjs +0 -893
  182. package/scripts/stalled-member-liveness-prose.test.mjs +0 -219
  183. package/scripts/stash-prohibition-prose.test.mjs +0 -313
  184. package/scripts/strip-comments.mjs +0 -44
  185. package/scripts/temp-dir.mjs +0 -47
  186. package/scripts/ticket-router.test.mjs +0 -981
  187. package/scripts/tier-check.test.mjs +0 -828
  188. package/scripts/tier-outcomes-header.test.mjs +0 -518
  189. package/scripts/tier-outcomes.test.mjs +0 -572
  190. package/scripts/tier-roles.test.mjs +0 -535
  191. package/scripts/tracker-block-copy-prose.test.mjs +0 -288
  192. package/scripts/triage-labels-gloss-prose.test.mjs +0 -97
  193. package/scripts/unattended-git-sweep.test.mjs +0 -142
  194. package/scripts/verify-sha-exit2-prose.test.mjs +0 -269
  195. package/scripts/verify-sha.test.mjs +0 -692
  196. package/scripts/watcher-degraded-block.test.mjs +0 -369
  197. package/scripts/watcher-key-prose.test.mjs +0 -106
  198. package/scripts/within-run-pair-prose.test.mjs +0 -212
  199. package/scripts/worktree-audit.test.mjs +0 -1408
  200. package/scripts/worktree-head-prose.test.mjs +0 -276
  201. package/scripts/worktree-listing-sweep.test.mjs +0 -217
  202. package/scripts/worktree-model-prose.test.mjs +0 -216
  203. package/scripts/worktree-porcelain.mjs +0 -35
  204. package/scripts/worktree-porcelain.test.mjs +0 -102
@@ -1,611 +0,0 @@
1
- // #1754. The minimum Node version this plugin's CONSUMERS need is a measured
2
- // fact in exactly one machine-readable place — the root `package.json`'s
3
- // `engines.node` — and this sweep is what keeps a shipped script from
4
- // outrunning it silently.
5
- //
6
- // Four ways to red — the ticket's own three failure modes, plus #1763's:
7
- // 1. a shipped node script reaches for an API above the declared floor
8
- // ("every shipped node script stays within the declared floor", below);
9
- // 2. the declaration is missing or carries anything load-bearing beyond
10
- // the floor itself ("package.json declares the consumer floor...");
11
- // 3. README's stated floor and package.json's declaration disagree
12
- // ("README's stated floor agrees with package.json's declaration");
13
- // 4. a shipped node script imports a relative module that is not `.mjs`
14
- // ("every relative import in a shipped node script names a .mjs module").
15
- // Not an API but a LOADER behaviour: nothing that ships sets a `type`
16
- // field (the root package.json never reaches an installed plugin, whose
17
- // root is `plugin/`, and carries only `engines` anyway — check 2), so a
18
- // `.js` file is CommonJS to Node until syntax detection turned on by
19
- // default (20.19.0 on the 20 line, 22.7.0 on 22). At the declared floor
20
- // an `import`/`export` in one fails to load — measured for #1763 on
21
- // review-eval.mjs's import of the old review-core.js under 20.11.0,
22
- // 20.18.3 and 22.6.0: "Named export 'digestOf' not found. The requested
23
- // module './review-core.js' is a CommonJS module". `.mjs` is ESM on
24
- // every Node this floor admits, and on Bun, with no manifest at all.
25
- // Static specifiers only: an `import()` of a COMPUTED path is invisible
26
- // to it, the same textual-scan limit the API table below states. A
27
- // TRAILING `code; // note` on the same line as a real import is closed
28
- // here too, quote-aware: `stripComments()`'s own known ceiling leaves
29
- // that text standing, which is safe for the declaration pins it was
30
- // built for (surviving text only ever ADDS a match there) but not for
31
- // this scan, where it can COIN a fake `from "<rel>"` beside a real,
32
- // correct import on the same line (measured: appending `// … from
33
- // "./old.js"` after a genuine `.mjs` import falsely reds this check).
34
- // "Shipped node script" is `trackedNodeScripts()`'s answer (repo-root.mjs):
35
- // every tracked `.mjs`, and every other tracked file whose first line is a
36
- // node shebang. Until #1855 the sweep read the `.mjs` half alone, so the three
37
- // extensionless entrypoints that run under the consumer's own node exactly as
38
- // the `.mjs` files do — `fleet-run` (the Resolver, copied to
39
- // `~/.fleet/bin/fleet-run`), `fleet-bootstrap`, `fleet-provenance` — could
40
- // reach above the floor unseen (measured: `Object.groupBy(` appended to
41
- // `fleet-run` left this suite green). They are CommonJS, so every table entry
42
- // below that is matched at a module site matches its `require(…)` form too.
43
- // Non-vacuity is asserted explicitly, same discipline every other sweep in
44
- // this directory uses (see repo-root.mjs's own header, `check-tracked.sh`):
45
- // an empty shipped-file list is a broken glob, not "nothing to check" — and
46
- // so is an empty `.mjs` half. The shebang half is held to more than that:
47
- // each of the three entrypoints must be in it by name (#1884).
48
- //
49
- // THE DETECTION MECHANISM, and its limits, stated plainly because this is
50
- // the hardest call in the ticket:
51
- //
52
- // `API_FLOORS` below is a CURATED table — API name, a regex signature, and
53
- // the Node release that first shipped it (each verified against a Node
54
- // release note or blog post at authoring time, cited inline). There is no
55
- // general, load-bearing "what Node version does this syntax need" oracle
56
- // available without a new dependency, and the design guidance forbids one
57
- // (the root manifest "introduces no publish path and no dependency graph").
58
- // This is therefore a KNOWN-API scan, not a semantic analyzer: it catches
59
- // exactly the APIs enumerated below, reached for in exactly the textual
60
- // shape each pattern matches, and nothing else. A shipped file reaching for
61
- // some OTHER version-gated API not yet in this table is a false negative —
62
- // the same class of gap `printf-die-sweep.test.mjs`'s own header names for
63
- // its `\c`-escape fixtures, and the remedy is the same: extend the table the
64
- // day a real one is measured, not attempt to enumerate every Node API ever
65
- // added up front.
66
- //
67
- // Scanned through `stripComments()` (not raw source), reusing the shared
68
- // stripper the rest of this suite already trusts for exactly this class of
69
- // false positive: a comment that merely NAMES an API — this very file's own
70
- // header does, repeatedly — must not raise the floor a mutant would need to
71
- // actually regress. `.at(`, `Object.groupBy(` etc. below are still
72
- // heuristic textual matches, not parsed call sites: a local method that
73
- // happens to share a name (a custom `.with(`, most plausibly) would
74
- // false-positive. Accepted, not fixed here, for the same reason the false
75
- // negative above is accepted — a real parser is out of scope for this
76
- // ticket's root-manifest constraint, and every regex below is anchored
77
- // tightly enough that no shipped file trips it today (see the "stays within
78
- // the declared floor" test).
79
- //
80
- // KNOWN LIMIT shared with every `*-sweep.test.mjs` sibling in this
81
- // directory: needs an ambient `.git` to ask what ships. Absent one, the
82
- // integration tests below DECLINE with a reason rather than running; the
83
- // unit tests further down (pure functions, no repo needed) still run and
84
- // still police the mechanism itself.
85
- //
86
- // Zero deps: `node --test plugin/scripts/node-floor-sweep.test.mjs`.
87
-
88
- import { test } from "node:test";
89
- import assert from "node:assert/strict";
90
- import { readFileSync } from "node:fs";
91
- import { join } from "node:path";
92
- import { fileURLToPath } from "node:url";
93
- import { repoRoot, skipWithoutRepo, trackedNodeScripts } from "./repo-root.mjs";
94
- import { stripComments } from "./strip-comments.mjs";
95
-
96
- const DIR = fileURLToPath(new URL(".", import.meta.url));
97
- const ROOT = repoRoot(DIR);
98
- const SKIP_WITHOUT_REPO = skipWithoutRepo(ROOT, "the node-floor sweep");
99
- const NODE_SCRIPTS = ROOT === null ? [] : trackedNodeScripts(ROOT);
100
-
101
- // Regex metacharacters escaped so a caller's literal stays a literal — the
102
- // one-liner prose-pin.mjs and ledger.mjs use, not `RegExp.escape`, which Node
103
- // first shipped in v24.0.0 (V8 13.6), above the floor this file polices.
104
- const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
105
-
106
- // A named binding taken from builtin `mod` at its MODULE SITE, in either module
107
- // system: ESM's `import { name } from "mod"`, or the CommonJS twin the
108
- // extensionless entrypoints write (#1855), `const { name } = require("mod")`.
109
- // Both arguments are escaped before they reach the pattern (#1888): each
110
- // matches only its own spelling, whatever a floor-table entry passes. The
111
- // `\b` anchors still assume `name` starts and ends with a word character —
112
- // true of both entries that call this, and of any identifier with no `$` at
113
- // either end.
114
- function moduleSiteBinding(name, mod) {
115
- const n = escapeRe(name);
116
- const m = escapeRe(mod);
117
- return new RegExp(
118
- `import\\s*\\{[^}]*\\b${n}\\b[^}]*\\}\\s*from\\s*["']${m}["']`
119
- + `|\\b(?:const|let|var)\\s*\\{[^{}]*\\b${n}\\b[^{}]*\\}\\s*=\\s*require\\(\\s*["']${m}["']\\s*\\)`,
120
- );
121
- }
122
-
123
- // name: what a failure message calls it. pattern: non-global regex over
124
- // COMMENT-STRIPPED source. since: "MAJOR.MINOR.PATCH", the first Node
125
- // release that shipped it (stable, unflagged), each verified at authoring
126
- // time — see the header for which release note.
127
- const API_FLOORS = [
128
- // Node v16.6.0 blog/changelog: "introduces the new Array.prototype.at
129
- // method". Heuristic: any `.at(` call — see header's accepted false-
130
- // positive note.
131
- { name: "Array.prototype.at()", pattern: /\.at\(/, since: "16.6.0" },
132
- // Node v16.9.0 blog/changelog: "Object.hasOwn is a static alias for
133
- // Object.prototype.hasOwnProperty.call".
134
- { name: "Object.hasOwn()", pattern: /\bObject\.hasOwn\(/, since: "16.9.0" },
135
- // Node v17.0.0 added the global structuredClone().
136
- { name: "structuredClone()", pattern: /\bstructuredClone\(/, since: "17.0.0" },
137
- // node/#46718: "util,doc: mark parseArgs() as stable", landed in Node
138
- // v20.0.0 (SEMVER-MAJOR). Matched at the import or require site, not the
139
- // bare word, so a comment discussing the sibling module (arg.mjs does, at
140
- // length) cannot trip it even unstripped.
141
- { name: "util.parseArgs()", pattern: moduleSiteBinding("parseArgs", "node:util"), since: "20.0.0" },
142
- // ES2023 array copy methods — Node 20+ per release notes; Node 18/19 ship
143
- // only findLast/findLastIndex from the same proposal.
144
- { name: "Array.prototype.toSorted()", pattern: /\.toSorted\(/, since: "20.0.0" },
145
- { name: "Array.prototype.toReversed()", pattern: /\.toReversed\(/, since: "20.0.0" },
146
- { name: "Array.prototype.toSpliced()", pattern: /\.toSpliced\(/, since: "20.0.0" },
147
- { name: "Array.prototype.with()", pattern: /\.with\(/, since: "20.0.0" },
148
- // node/#48740 (SEMVER-MINOR), Node v20.11.0: "esm: add import.meta.dirname
149
- // and import.meta.filename".
150
- {
151
- name: "import.meta.dirname / import.meta.filename",
152
- pattern: /\bimport\.meta\.(dirname|filename)\b/,
153
- since: "20.11.0",
154
- },
155
- // util.styleText — introduced Node v20.12.0, stable Node v21.7.0/v22.13.0.
156
- // Using the introduction version as the floor: it exists and is usable (with
157
- // an experimental warning) from 20.12.0, and this table's job is "what
158
- // version must a consumer run", not "warning-free". Matched at the import or
159
- // require site, same discipline as util.parseArgs() above: every unanchored
160
- // pattern declared EARLIER in this table has a `since` at or below the
161
- // declared floor (package.json's `engines.node`), so a false positive there
162
- // is never reported. Every unanchored entry declared LATER, though higher
163
- // still, matches only the global-qualified spelling (`Object.groupBy(` …)
164
- // — `Set.prototype.isSubsetOf()` below excepted, see its own comment —
165
- // so a same-named local function or method never trips the rest;
166
- // `node:sqlite` below is anchored instead, like this entry and
167
- // util.parseArgs() above, and is excluded from that count for the same
168
- // reason. 20.12.0 sits ABOVE that floor, so a same-named local (a custom
169
- // `styleText`) was the first heuristic entry actually live today, not
170
- // merely theoretical — anchoring it is not optional; `isSubsetOf()` below
171
- // is the second, left unanchored instead.
172
- { name: "util.styleText()", pattern: moduleSiteBinding("styleText", "node:util"), since: "20.12.0" },
173
- // Node v21.0.0 shipped Object.groupBy/Map.groupBy (array grouping).
174
- { name: "Object.groupBy()", pattern: /\bObject\.groupBy\(/, since: "21.0.0" },
175
- { name: "Map.groupBy()", pattern: /\bMap\.groupBy\(/, since: "21.0.0" },
176
- // Promise.withResolvers — behind a flag in Node 21.7.0, enabled by default
177
- // Node 22.0.0+.
178
- { name: "Promise.withResolvers()", pattern: /\bPromise\.withResolvers\(/, since: "22.0.0" },
179
- // Array.fromAsync — Node 22.0.0+.
180
- { name: "Array.fromAsync()", pattern: /\bArray\.fromAsync\(/, since: "22.0.0" },
181
- // Set composition/query methods (union … isDisjointFrom) — Node v22.0.0,
182
- // V8 12.4 (nodejs.org's v22-release-announce blog). Only isSubsetOf is
183
- // listed: it is the one member of this family measured in a shipped
184
- // script so far (ledger.mjs, #1954); extend per the header's own rule the
185
- // day a sibling is. Unqualified and unanchored like `.at(` above, just
186
- // above the floor instead of below it — a same-named local method would
187
- // false-positive (see the header's accepted false-positive note).
188
- { name: "Set.prototype.isSubsetOf()", pattern: /\.isSubsetOf\(/, since: "22.0.0" },
189
- // node:sqlite — introduced Node v22.5.0 behind --experimental-sqlite;
190
- // unflagged (still experimental) in Node v22.13.0 (nodejs/node#55890).
191
- // "since" is the unflagged version, same rule this table's header states
192
- // and Promise.withResolvers() above already follows: a shipped `import
193
- // ... from "node:sqlite"`, or `require("node:sqlite")`, on 22.5.0-22.12.x
194
- // still needs the flag and would throw ERR_UNKNOWN_BUILTIN_MODULE without it.
195
- {
196
- name: "node:sqlite",
197
- pattern: /from\s*["']node:sqlite["']|\brequire\(\s*["']node:sqlite["']\s*\)/,
198
- since: "22.13.0",
199
- },
200
- // Node v24.0.0 release notes: "The V8 engine is updated to version 13.6,
201
- // which includes several new JavaScript features: … RegExp.escape" (#1932).
202
- // Matched as a bare reference, not only a call: an escaper is passed as a
203
- // callback as often as it is called — prose-pin.mjs's own `.map(escapeRe)`
204
- // is the spelling a swap to the builtin would take — and a `\(`-suffixed
205
- // pattern misses `.map(RegExp.escape)`. The cost is that a feature-detected
206
- // `typeof RegExp.escape` reds too; accepted, since the escapeRe one-liner
207
- // above is floor-safe unconditionally and leaves nothing to detect.
208
- { name: "RegExp.escape()", pattern: /\bRegExp\.escape\b/, since: "24.0.0" },
209
- ];
210
-
211
- /** "MAJOR.MINOR.PATCH" -> [major, minor, patch], or throws. */
212
- function parseVersion(v) {
213
- const m = /^(\d+)\.(\d+)\.(\d+)$/.exec(String(v));
214
- if (!m) throw new Error(`not a MAJOR.MINOR.PATCH version: ${JSON.stringify(v)}`);
215
- return [Number(m[1]), Number(m[2]), Number(m[3])];
216
- }
217
-
218
- /** <0 if a<b, 0 if equal, >0 if a>b — both [major, minor, patch]. */
219
- function compareVersions(a, b) {
220
- for (let i = 0; i < 3; i += 1) {
221
- if (a[i] !== b[i]) return a[i] - b[i];
222
- }
223
- return 0;
224
- }
225
-
226
- /**
227
- * The declared floor, from `package.json`'s own text. Refuses anything the
228
- * file carries beyond exactly `{"engines":{"node":">=X.Y.Z"}}` — the
229
- * "nothing load-bearing beyond the floor itself" acceptance criterion,
230
- * enforced here rather than left to a reviewer's eye.
231
- */
232
- function parseDeclaredFloor(pkgJsonText) {
233
- let pkg;
234
- try {
235
- pkg = JSON.parse(pkgJsonText);
236
- } catch (e) {
237
- throw new Error(`package.json is not valid JSON: ${e.message}`);
238
- }
239
- const topKeys = Object.keys(pkg);
240
- if (topKeys.length !== 1 || topKeys[0] !== "engines") {
241
- throw new Error(
242
- `package.json must carry nothing load-bearing beyond "engines" — found keys: ${JSON.stringify(topKeys)}`,
243
- );
244
- }
245
- const engineKeys = Object.keys(pkg.engines ?? {});
246
- if (engineKeys.length !== 1 || engineKeys[0] !== "node") {
247
- throw new Error(
248
- `package.json's "engines" must carry nothing beyond "node" — found keys: ${JSON.stringify(engineKeys)}`,
249
- );
250
- }
251
- const raw = pkg.engines.node;
252
- const m = typeof raw === "string" ? /^>=(\d+\.\d+\.\d+)$/.exec(raw) : null;
253
- if (!m) {
254
- throw new Error(
255
- `package.json's engines.node must read exactly ">=MAJOR.MINOR.PATCH", got ${JSON.stringify(raw)}`,
256
- );
257
- }
258
- return { raw, version: parseVersion(m[1]) };
259
- }
260
-
261
- /**
262
- * The floor README's `## Installation` section states, read the same way a
263
- * human does: the first `>=MAJOR.MINOR.PATCH` token in that section.
264
- */
265
- function parseReadmeFloor(readmeText) {
266
- const section = /## Installation\n([\s\S]*?)(?=\n## )/.exec(readmeText);
267
- if (!section) throw new Error("README has no \"## Installation\" section to read a floor from");
268
- const m = />=(\d+\.\d+\.\d+)(?:[-+][0-9A-Za-z.-]*)?/.exec(section[1]);
269
- if (!m) throw new Error("README's \"## Installation\" section states no \">=MAJOR.MINOR.PATCH\" floor");
270
- return { raw: m[0], version: parseVersion(m[1]) };
271
- }
272
-
273
- /** Every `API_FLOORS` entry a comment-stripped source reaches above `floorVersion`. */
274
- function scanFileViolations(source, floorVersion) {
275
- const stripped = stripComments(source);
276
- const hits = [];
277
- for (const api of API_FLOORS) {
278
- if (api.pattern.test(stripped) && compareVersions(parseVersion(api.since), floorVersion) > 0) {
279
- hits.push({ name: api.name, since: api.since });
280
- }
281
- }
282
- return hits;
283
- }
284
-
285
- // A static `import … from "<rel>"`, a bare side-effect `import "<rel>"`, or an
286
- // `import("<rel>")` with a literal specifier, where <rel> starts `./`/`../`.
287
- // Bare and `node:` specifiers never match: only a relative path names a file
288
- // whose extension decides how the loader parses it.
289
- const RELATIVE_IMPORT = /(?:\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(["'`])(\.{1,2}\/[^"'`$]*)\1/g;
290
-
291
- // Quote-aware so a literal `//` inside a specifier or string is left alone;
292
- // this only needs to find the FIRST unquoted `//` to truncate the rest of
293
- // the line, never a full tokenizer.
294
- function stripTrailingLineComment(line) {
295
- let quote = null;
296
- for (let i = 0; i < line.length; i++) {
297
- const c = line[i];
298
- if (quote) {
299
- if (c === "\\") i += 1;
300
- else if (c === quote) quote = null;
301
- } else if (c === '"' || c === "'" || c === "`") {
302
- quote = c;
303
- } else if (c === "/" && line[i + 1] === "/") {
304
- return line.slice(0, i);
305
- }
306
- }
307
- return line;
308
- }
309
-
310
- /** Every relative import specifier in a comment-stripped source that does not name a `.mjs` file. */
311
- function nonMjsRelativeImports(source) {
312
- const hits = [];
313
- const stripped = stripComments(source).split("\n").map(stripTrailingLineComment).join("\n");
314
- for (const m of stripped.matchAll(RELATIVE_IMPORT)) {
315
- if (!m[2].endsWith(".mjs")) hits.push(m[2]);
316
- }
317
- return hits;
318
- }
319
-
320
- // Both halves, not their sum: the `.mjs` half alone is dozens of files, so a
321
- // shebang probe that silently lost every extensionless entrypoint (#1855's
322
- // own gap) would leave a total count comfortably non-empty. And the shebang
323
- // half by NAME, not merely non-empty (#1884): a file is in it on its first
324
- // line alone, a line CI never needs — .github/scripts/install-and-smoke.sh
325
- // runs all three as `node <path>` (and skills/run-team/SKILL.md:282 runs
326
- // fleet-run that way too), so losing it breaks only direct-exec callers
327
- // (`~/.fleet/bin/fleet-run <script>`, and fleet-run's own spawnSync of
328
- // fleet-bootstrap/fleet-provenance) at run time, not any check here. It
329
- // would drop out of every check below while the other two kept the half
330
- // non-empty. Measured: `fleet-run` with its shebang line deleted and
331
- // `Object.groupBy(` appended still ran `node fleet-run --root` to exit 0,
332
- // and left this suite green under a non-empty-half check.
333
- const NODE_SHEBANG_ENTRYPOINTS = ["plugin/scripts/fleet-bootstrap", "plugin/scripts/fleet-provenance", "plugin/scripts/fleet-run"];
334
-
335
- test("the sweep sees the scripts it is supposed to police — .mjs modules and every node-shebang entrypoint", { skip: SKIP_WITHOUT_REPO }, () => {
336
- assert.ok(
337
- NODE_SCRIPTS.some((f) => f.endsWith(".mjs")),
338
- `trackedNodeScripts(ROOT) returned zero shipped .mjs files — this is a broken glob/git call, and every check below would pass vacuously over them`,
339
- );
340
- const missing = NODE_SHEBANG_ENTRYPOINTS.filter((f) => !NODE_SCRIPTS.includes(f));
341
- assert.deepEqual(
342
- missing,
343
- [],
344
- `trackedNodeScripts(ROOT) does not list ${missing.join(", ")} — an entrypoint is listed by its node shebang alone, so one `
345
- + "that lost that first line (or a broken shebang probe) escapes every check below while it still runs as `node <path>`. "
346
- + "Restore the shebang; or, if the file was renamed or retired, update NODE_SHEBANG_ENTRYPOINTS (#1855, #1884)",
347
- );
348
- });
349
-
350
- test("package.json declares the consumer floor, and nothing else load-bearing", { skip: SKIP_WITHOUT_REPO }, () => {
351
- let text;
352
- try {
353
- text = readFileSync(join(ROOT, "package.json"), "utf8");
354
- } catch (e) {
355
- assert.fail(
356
- e.code === "ENOENT"
357
- ? "no package.json at the repo root — the consumer floor must be declared there (#1754)"
358
- : `could not read package.json at the repo root: ${e.message}`,
359
- );
360
- }
361
- const declared = parseDeclaredFloor(text);
362
- assert.match(declared.raw, /^>=\d+\.\d+\.\d+$/);
363
- });
364
-
365
- test("README's stated floor agrees with package.json's declaration", { skip: SKIP_WITHOUT_REPO }, () => {
366
- const declared = parseDeclaredFloor(readFileSync(join(ROOT, "package.json"), "utf8"));
367
- const stated = parseReadmeFloor(readFileSync(join(ROOT, "README.md"), "utf8"));
368
- // Compares the exact matched text, not just the numeric triple: a
369
- // pre-release/build qualifier one side carries and the other doesn't is a
370
- // real disagreement `.version`'s numeric coercion would otherwise erase.
371
- assert.equal(
372
- stated.raw,
373
- declared.raw,
374
- `README's Installation section states ${stated.raw} but package.json declares ${declared.raw} — `
375
- + "correcting one without the other is exactly the drift this check exists to make impossible",
376
- );
377
- });
378
-
379
- test("every shipped node script stays within the declared floor", { skip: SKIP_WITHOUT_REPO }, () => {
380
- const declared = parseDeclaredFloor(readFileSync(join(ROOT, "package.json"), "utf8"));
381
- const violations = [];
382
- for (const rel of NODE_SCRIPTS) {
383
- const source = readFileSync(join(ROOT, rel), "utf8");
384
- for (const hit of scanFileViolations(source, declared.version)) {
385
- violations.push(`${rel}: uses ${hit.name} (Node >=${hit.since}) above the declared floor (${declared.raw})`);
386
- }
387
- }
388
- assert.deepEqual(
389
- violations,
390
- [],
391
- `shipped file(s) reach above the declared consumer floor — rewrite the call, or raise engines.node in package.json (and README to match):\n${violations.join("\n")}`,
392
- );
393
- });
394
-
395
- test("every relative import in a shipped node script names a .mjs module", { skip: SKIP_WITHOUT_REPO }, () => {
396
- const violations = [];
397
- for (const rel of NODE_SCRIPTS) {
398
- for (const spec of nonMjsRelativeImports(readFileSync(join(ROOT, rel), "utf8"))) {
399
- violations.push(`${rel}: imports ${spec}`);
400
- }
401
- }
402
- assert.deepEqual(
403
- violations,
404
- [],
405
- "shipped file(s) import a relative module that is not .mjs — nothing that ships declares a \"type\", so Node "
406
- + "below 20.19.0/22.7.0 (inside the declared floor) loads it as CommonJS and its import/export fails (#1763); "
407
- + `rename it to .mjs:\n${violations.join("\n")}`,
408
- );
409
- });
410
-
411
- // ---------------------------------------------------------------------------
412
- // The mechanism itself, unit-tested with no repo needed. Two directions
413
- // pinned on the scanner, because a suite that only feeds valid input pins
414
- // neither (same discipline printf-die-sweep.test.mjs's header states).
415
- // ---------------------------------------------------------------------------
416
-
417
- test("scanFileViolations reds a shipped file reaching above the floor", () => {
418
- const src = 'import { parseArgs } from "node:util";\nconst last = () => import.meta.dirname;\n';
419
- const names = scanFileViolations(src, parseVersion("16.0.0")).map((h) => h.name);
420
- assert.ok(names.includes("util.parseArgs()"), `expected util.parseArgs() flagged, got: ${names.join(", ")}`);
421
- assert.ok(
422
- names.includes("import.meta.dirname / import.meta.filename"),
423
- `expected import.meta.dirname flagged, got: ${names.join(", ")}`,
424
- );
425
- });
426
-
427
- test("scanFileViolations stays green once the declared floor covers the same source", () => {
428
- const src = 'import { parseArgs } from "node:util";\nconst last = () => import.meta.dirname;\n';
429
- assert.deepEqual(scanFileViolations(src, parseVersion("20.11.0")), []);
430
- });
431
-
432
- test("scanFileViolations ignores an API merely NAMED in a comment", () => {
433
- const src = "// import.meta.dirname is discussed in the sibling module\nconst x = 1;\n";
434
- assert.deepEqual(scanFileViolations(src, parseVersion("16.0.0")), []);
435
- });
436
-
437
- test("scanFileViolations matches util.styleText() only at the import site, not a same-named local", () => {
438
- const collision = 'function styleText(label) { return `[${label}]`; }\nexport const styled = styleText("x");\n';
439
- assert.deepEqual(scanFileViolations(collision, parseVersion("16.0.0")), []);
440
- const real = 'import { styleText } from "node:util";\nconsole.log(styleText("red", "x"));\n';
441
- const names = scanFileViolations(real, parseVersion("16.0.0")).map((h) => h.name);
442
- assert.ok(names.includes("util.styleText()"), `expected util.styleText() flagged, got: ${names.join(", ")}`);
443
- });
444
-
445
- // #1855: the extensionless entrypoints this sweep reads are CommonJS, so each
446
- // entry matched at a MODULE SITE needs its `require` form as well — an
447
- // `import … from` shape can never match a file with no `import` in it.
448
- test("scanFileViolations reds the CommonJS require site of every module-site API", () => {
449
- const src = 'const { parseArgs } = require("node:util");\n'
450
- + 'const { inspect, styleText: paint } = require("node:util");\n'
451
- + 'const { DatabaseSync } = require("node:sqlite");\n';
452
- const names = scanFileViolations(src, parseVersion("16.0.0")).map((h) => h.name).sort();
453
- assert.deepEqual(names, ["node:sqlite", "util.parseArgs()", "util.styleText()"]);
454
- });
455
-
456
- // A single-quoted require site alone — every other CommonJS fixture above
457
- // uses double quotes, which a quote-class regression in moduleSiteBinding's
458
- // require alternative (`["']` narrowed to `["]`) would pass undetected,
459
- // since the pattern is non-global and the double-quoted forms above already
460
- // satisfy it regardless of whether the single-quote branch works.
461
- test("scanFileViolations reds a single-quoted CommonJS require site", () => {
462
- const src = "const { styleText } = require('node:util');\n";
463
- const names = scanFileViolations(src, parseVersion("16.0.0")).map((h) => h.name).sort();
464
- assert.deepEqual(names, ["util.styleText()"]);
465
- });
466
-
467
- test("scanFileViolations passes a CommonJS require of node:util taking neither API, beside same-named locals", () => {
468
- const src = 'const { inspect } = require("node:util");\n'
469
- + "function styleText(label) { return `[${label}]`; }\n"
470
- + "const parseArgs = (argv) => argv.slice(2);\n"
471
- + "module.exports = { styled: styleText(inspect(parseArgs(process.argv))) };\n";
472
- assert.deepEqual(scanFileViolations(src, parseVersion("16.0.0")), []);
473
- });
474
-
475
- // #1888. moduleSiteBinding's two arguments are text to find, never regex
476
- // source, so a floor-table entry cannot widen, narrow or break its own
477
- // pattern by what it happens to spell. Both directions, at both module sites:
478
- // a pattern that stopped matching the literal spelling is as wrong as one
479
- // that started matching what the metacharacter would have admitted.
480
- test("moduleSiteBinding matches a regex metacharacter in its name or module as itself", () => {
481
- const re = moduleSiteBinding("a+b", "x.y");
482
- for (const src of ['import { a+b } from "x.y";', 'const { a+b } = require("x.y");']) {
483
- assert.match(src, re);
484
- }
485
- for (const src of [
486
- 'import { aab } from "x.y";', // `+` read as a quantifier
487
- 'const { aab } = require("x.y");',
488
- 'import { a+b } from "xzy";', // `.` read as any character
489
- 'const { a+b } = require("xzy");',
490
- ]) {
491
- assert.doesNotMatch(src, re);
492
- }
493
- });
494
-
495
- // #1932. RegExp.escape as a call AND as a bare callback reference, each in its
496
- // own source: the pattern is non-global, so one fixture carrying both would
497
- // stay green under a call-only `\(`-suffixed pattern that misses the
498
- // `.map(RegExp.escape)` spelling. The since boundary both ways: red at the
499
- // declared floor, green from the release that shipped it.
500
- test("scanFileViolations reds RegExp.escape called or passed as a callback, below 24.0.0 only", () => {
501
- for (const src of [
502
- "const re = new RegExp(`^${RegExp.escape(name)}$`);\n",
503
- 'const re = new RegExp(words.map(RegExp.escape).join("|"));\n',
504
- ]) {
505
- const names = scanFileViolations(src, parseVersion("20.11.0")).map((h) => h.name);
506
- assert.deepEqual(names, ["RegExp.escape()"], `expected RegExp.escape() flagged in: ${src}`);
507
- assert.deepEqual(scanFileViolations(src, parseVersion("24.0.0")), []);
508
- }
509
- });
510
-
511
- // What the RegExp.escape entry must ACCEPT: the floor-safe one-liner this repo
512
- // writes in its place, passed as a callback the same way, and an identifier
513
- // that merely ends in `RegExp`.
514
- test("scanFileViolations passes the escapeRe one-liner and a same-suffixed escape method", () => {
515
- const src = 'const escapeRe = (s) => s.replace(/[.*+?^${}()|[\\]\\\\]/g, "\\\\$&");\n'
516
- + 'const re = new RegExp(words.map(escapeRe).join("|"));\n'
517
- + "const own = myRegExp.escape(name);\n";
518
- assert.deepEqual(scanFileViolations(src, parseVersion("16.0.0")), []);
519
- });
520
-
521
- test("parseDeclaredFloor refuses a missing engines.node declaration", () => {
522
- assert.throws(() => parseDeclaredFloor("{}"), /engines/);
523
- });
524
-
525
- test("parseDeclaredFloor refuses anything load-bearing beyond the floor", () => {
526
- assert.throws(
527
- () => parseDeclaredFloor('{"engines":{"node":">=20.11.0"},"dependencies":{}}'),
528
- /nothing load-bearing beyond "engines"/,
529
- );
530
- assert.throws(
531
- () => parseDeclaredFloor('{"engines":{"node":">=20.11.0","npm":">=10"}}'),
532
- /nothing beyond "node"/,
533
- );
534
- });
535
-
536
- test("parseDeclaredFloor refuses a syntactically malformed but present engines.node", () => {
537
- assert.throws(
538
- () => parseDeclaredFloor('{"engines":{"node":"20.11.0"}}'),
539
- /must read exactly ">=MAJOR\.MINOR\.PATCH"/,
540
- );
541
- assert.throws(
542
- () => parseDeclaredFloor('{"engines":{"node":">=20.11"}}'),
543
- /must read exactly ">=MAJOR\.MINOR\.PATCH"/,
544
- );
545
- });
546
-
547
- test("parseDeclaredFloor refuses a non-string engines.node", () => {
548
- assert.throws(
549
- () => parseDeclaredFloor('{"engines":{"node":[">=20.11.0"]}}'),
550
- /must read exactly ">=MAJOR\.MINOR\.PATCH"/,
551
- );
552
- });
553
-
554
- test("parseReadmeFloor and parseDeclaredFloor disagreement is caught", () => {
555
- const declared = parseDeclaredFloor('{"engines":{"node":">=20.11.0"}}');
556
- const stated = parseReadmeFloor("## Installation\n\nNeeds Node >=20.10.0.\n\n## Next\n");
557
- assert.notDeepEqual(stated.version, declared.version);
558
- });
559
-
560
- test("parseReadmeFloor and parseDeclaredFloor disagreement on a pre-release qualifier is caught", () => {
561
- const declared = parseDeclaredFloor('{"engines":{"node":">=20.11.0"}}');
562
- const stated = parseReadmeFloor("## Installation\n\nNeeds Node >=20.11.0-rc.1.\n\n## Next\n");
563
- assert.notEqual(stated.raw, declared.raw);
564
- });
565
-
566
- test("parseReadmeFloor refuses a README with no \"## Installation\" section", () => {
567
- assert.throws(
568
- () => parseReadmeFloor("# Some README\n\nNo installation section here.\n\n## Next\n"),
569
- /no "## Installation" section/,
570
- );
571
- });
572
-
573
- test("parseReadmeFloor refuses an Installation section stating no floor", () => {
574
- assert.throws(
575
- () => parseReadmeFloor("## Installation\n\nJust run it.\n\n## Next\n"),
576
- /states no ">=MAJOR\.MINOR\.PATCH"/,
577
- );
578
- });
579
-
580
- test("nonMjsRelativeImports reds every import form that names a relative non-.mjs module", () => {
581
- const src = [
582
- 'import { digestOf } from "./review-core.js";',
583
- "import './side-effect.js';",
584
- 'const m = await import("../lib/dyn.js");',
585
- "const t = await import(`./tpl.js`);",
586
- 'export { x } from "./re-export.cjs";',
587
- ].join("\n");
588
- assert.deepEqual(nonMjsRelativeImports(src), [
589
- "./review-core.js", "./side-effect.js", "../lib/dyn.js", "./tpl.js", "./re-export.cjs",
590
- ]);
591
- });
592
-
593
- test("nonMjsRelativeImports accepts .mjs siblings, builtins, and a .js merely named in a comment or string", () => {
594
- const src = [
595
- 'import { isDigits } from "./arg.mjs";',
596
- 'import { readFileSync } from "node:fs";',
597
- 'const m = await import("../lib/deep.mjs");',
598
- '// import { digestOf } from "./review-core.js"; (the pre-#1763 spelling)',
599
- 'const file = join(DIR, "./review-core.js");',
600
- "const dyn = await import(path);",
601
- ].join("\n");
602
- assert.deepEqual(nonMjsRelativeImports(src), []);
603
- });
604
-
605
- test("nonMjsRelativeImports does not coin a false hit from a trailing comment beside a real import", () => {
606
- const src = [
607
- 'import { isDigits } from "./arg.mjs"; // note: this used to import from "./old-name.js"',
608
- 'const url = "https://example.com/old-name.js"; // a literal "//" inside a string is not a comment start',
609
- ].join("\n");
610
- assert.deepEqual(nonMjsRelativeImports(src), []);
611
- });