Commit 394c9b5
committed
feat(tools/prim): add
Three additions:
1. **`prim lint`** — new structural lint subcommand for primordials
destructure blocks. Currently encodes one rule:
- `ctor-rename`: constructor primordials (`Array`, `Set`,
`TypeError`, etc.) MUST be aliased `<Name>: <Name>Ctor` when
destructured from `primordials` or any configured
primordials-shaped source. Bare `{ Array } = primordials`
shadows the global and is reported as a violation.
The set of primordials-shaped sources is configurable via
`--primordials-source <name>` (repeatable). Defaults cover
`primordials` (Node bootstrap global) and the
`internal/socketsecurity/safe-references` re-export module used
in socket-btm additions. Exits 1 if any violation found.
2. **`--surface <path>`** flag on coverage/gaps/audit. Lets users
point prim at any primordials source file, overriding the default
sibling/installed lookup. Use case: auditing socket-btm's
additions against Node's `lib/internal/per_context/primordials.js`
surface instead of socket-lib's surface.
3. **Node bootstrap surface derivation**. When `--surface` points at
a `per_context/primordials.js`-style file, the loader recognizes
the path and dynamically computes the full surface by enumerating
the static + prototype methods of the upstream globals (Array,
Object, String, Number, Map, Set, Error, RegExp, JSON, Math,
Reflect, etc.) the same way Node does at bootstrap. This goes from
~20 detected names (text-only regex) to 541 detected names
(matches what Node actually installs).
Also: `audit.mts` now resolves constructor primordial names against
the surface — picks `<Name>Ctor` if the surface uses socket-lib's
convention, falls back to bare `<Name>` if the surface uses Node's
bootstrap convention. Eliminates spurious "ArrayCtor missing" gaps
when auditing against Node's surface.lint subcommand + Node bootstrap surface support1 parent 5d83ce7 commit 394c9b5
5 files changed
Lines changed: 615 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
266 | 283 | | |
267 | 284 | | |
268 | 285 | | |
| |||
275 | 292 | | |
276 | 293 | | |
277 | 294 | | |
278 | | - | |
| 295 | + | |
279 | 296 | | |
280 | 297 | | |
281 | 298 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
| |||
36 | 41 | | |
37 | 42 | | |
38 | 43 | | |
| 44 | + | |
39 | 45 | | |
40 | 46 | | |
41 | 47 | | |
| |||
50 | 56 | | |
51 | 57 | | |
52 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
53 | 62 | | |
54 | 63 | | |
55 | 64 | | |
| |||
58 | 67 | | |
59 | 68 | | |
60 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
61 | 79 | | |
62 | 80 | | |
63 | 81 | | |
| |||
92 | 110 | | |
93 | 111 | | |
94 | 112 | | |
| 113 | + | |
| 114 | + | |
95 | 115 | | |
96 | 116 | | |
97 | 117 | | |
| |||
152 | 172 | | |
153 | 173 | | |
154 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
155 | 197 | | |
156 | 198 | | |
157 | | - | |
| 199 | + | |
158 | 200 | | |
159 | 201 | | |
160 | 202 | | |
| |||
220 | 262 | | |
221 | 263 | | |
222 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
223 | 280 | | |
224 | 281 | | |
225 | 282 | | |
| |||
0 commit comments