@nielspeter/eess-ts 0.6.0 → 0.8.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.
Files changed (100) hide show
  1. package/README.md +1 -1
  2. package/dist/builders/class-rule-builder.d.ts +0 -7
  3. package/dist/builders/class-rule-builder.d.ts.map +1 -1
  4. package/dist/builders/class-rule-builder.js +27 -1
  5. package/dist/builders/class-rule-builder.js.map +1 -1
  6. package/dist/builders/cross-layer-builder.d.ts.map +1 -1
  7. package/dist/builders/cross-layer-builder.js +6 -8
  8. package/dist/builders/cross-layer-builder.js.map +1 -1
  9. package/dist/builders/slice-rule-builder.d.ts.map +1 -1
  10. package/dist/builders/slice-rule-builder.js +7 -1
  11. package/dist/builders/slice-rule-builder.js.map +1 -1
  12. package/dist/conditions/body-analysis-module.d.ts.map +1 -1
  13. package/dist/conditions/body-analysis-module.js +37 -4
  14. package/dist/conditions/body-analysis-module.js.map +1 -1
  15. package/dist/conditions/call.d.ts +4 -3
  16. package/dist/conditions/call.d.ts.map +1 -1
  17. package/dist/conditions/call.js +40 -17
  18. package/dist/conditions/call.js.map +1 -1
  19. package/dist/conditions/function.d.ts.map +1 -1
  20. package/dist/conditions/function.js +22 -8
  21. package/dist/conditions/function.js.map +1 -1
  22. package/dist/conditions/reverse-dependency.d.ts.map +1 -1
  23. package/dist/conditions/reverse-dependency.js +16 -14
  24. package/dist/conditions/reverse-dependency.js.map +1 -1
  25. package/dist/conditions/structural.d.ts.map +1 -1
  26. package/dist/conditions/structural.js +28 -11
  27. package/dist/conditions/structural.js.map +1 -1
  28. package/dist/core/disk-set.d.ts.map +1 -1
  29. package/dist/core/disk-set.js +37 -2
  30. package/dist/core/disk-set.js.map +1 -1
  31. package/dist/core/object-literal-functions.d.ts +4 -1
  32. package/dist/core/object-literal-functions.d.ts.map +1 -1
  33. package/dist/core/object-literal-functions.js +27 -5
  34. package/dist/core/object-literal-functions.js.map +1 -1
  35. package/dist/core/project-relative.d.ts +108 -0
  36. package/dist/core/project-relative.d.ts.map +1 -1
  37. package/dist/core/project-relative.js +179 -2
  38. package/dist/core/project-relative.js.map +1 -1
  39. package/dist/core/through-wrappers.d.ts +24 -0
  40. package/dist/core/through-wrappers.d.ts.map +1 -0
  41. package/dist/core/through-wrappers.js +36 -0
  42. package/dist/core/through-wrappers.js.map +1 -0
  43. package/dist/core/vacuity-diagnosis.d.ts.map +1 -1
  44. package/dist/core/vacuity-diagnosis.js +11 -3
  45. package/dist/core/vacuity-diagnosis.js.map +1 -1
  46. package/dist/helpers/body-traversal.d.ts +14 -14
  47. package/dist/helpers/body-traversal.d.ts.map +1 -1
  48. package/dist/helpers/body-traversal.js +111 -35
  49. package/dist/helpers/body-traversal.js.map +1 -1
  50. package/dist/helpers/callback-extractor.d.ts +6 -1
  51. package/dist/helpers/callback-extractor.d.ts.map +1 -1
  52. package/dist/helpers/callback-extractor.js +45 -10
  53. package/dist/helpers/callback-extractor.js.map +1 -1
  54. package/dist/helpers/global-binding.d.ts +11 -0
  55. package/dist/helpers/global-binding.d.ts.map +1 -0
  56. package/dist/helpers/global-binding.js +232 -0
  57. package/dist/helpers/global-binding.js.map +1 -0
  58. package/dist/index.d.ts +2 -2
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +2 -2
  61. package/dist/index.js.map +1 -1
  62. package/dist/models/arch-function.d.ts +2 -2
  63. package/dist/models/arch-function.d.ts.map +1 -1
  64. package/dist/models/arch-function.js +138 -41
  65. package/dist/models/arch-function.js.map +1 -1
  66. package/dist/models/slice.d.ts.map +1 -1
  67. package/dist/models/slice.js +20 -16
  68. package/dist/models/slice.js.map +1 -1
  69. package/dist/predicates/identity.d.ts +2 -1
  70. package/dist/predicates/identity.d.ts.map +1 -1
  71. package/dist/predicates/identity.js +37 -38
  72. package/dist/predicates/identity.js.map +1 -1
  73. package/dist/presets/agent-guardrails.d.ts.map +1 -1
  74. package/dist/presets/agent-guardrails.js +65 -14
  75. package/dist/presets/agent-guardrails.js.map +1 -1
  76. package/dist/presets/boundaries.js +58 -16
  77. package/dist/presets/boundaries.js.map +1 -1
  78. package/dist/presets/recommended.d.ts +29 -6
  79. package/dist/presets/recommended.d.ts.map +1 -1
  80. package/dist/presets/recommended.js +30 -11
  81. package/dist/presets/recommended.js.map +1 -1
  82. package/dist/rules/errors.d.ts +17 -0
  83. package/dist/rules/errors.d.ts.map +1 -1
  84. package/dist/rules/errors.js +48 -8
  85. package/dist/rules/errors.js.map +1 -1
  86. package/dist/rules/security.d.ts +6 -0
  87. package/dist/rules/security.d.ts.map +1 -1
  88. package/dist/rules/security.js +59 -5
  89. package/dist/rules/security.js.map +1 -1
  90. package/dist/smells/duplicate-bodies.d.ts +1 -1
  91. package/dist/smells/duplicate-bodies.d.ts.map +1 -1
  92. package/dist/smells/duplicate-bodies.js +12 -11
  93. package/dist/smells/duplicate-bodies.js.map +1 -1
  94. package/dist/smells/sibling-files.d.ts.map +1 -1
  95. package/dist/smells/sibling-files.js +16 -7
  96. package/dist/smells/sibling-files.js.map +1 -1
  97. package/dist/smells/smell-builder.d.ts.map +1 -1
  98. package/dist/smells/smell-builder.js +15 -1
  99. package/dist/smells/smell-builder.js.map +1 -1
  100. package/package.json +1 -1
@@ -2,13 +2,14 @@ import { functions } from '../builders/function-rule-builder.js';
2
2
  import { modules } from '../builders/module-rule-builder.js';
3
3
  import { resideInFile } from '../predicates/identity.js';
4
4
  import { not, or } from '../core/combinators.js';
5
- import { isDeadSite } from '../core/glob-evaluator.js';
6
5
  import { isProjectRelative } from '../core/project-relative.js';
6
+ import { isDeadSite } from '../core/glob-evaluator.js';
7
7
  import { pathUniverse } from '../core/path-universe.js';
8
8
  import { collectResult } from '@nielspeter/eess';
9
9
  import { UNSUPPRESSABLE } from '@nielspeter/eess/internal';
10
10
  import { call } from '../helpers/matchers.js';
11
- import { functionNoGenericErrors } from '../rules/errors.js';
11
+ import { moduleNoGenericErrors } from '../rules/errors.js';
12
+ import { moduleNotContain } from '../conditions/body-analysis-module.js';
12
13
  import { noStubComments, noEmptyBodies } from '../rules/hygiene.js';
13
14
  import { smells } from '../smells/index.js';
14
15
  import { overrideFindings, validateOverrides, declareEmptyIfListed, presetDeclarationSpelling, declaredEmptyFindings, assertEnabled, deliver, } from './shared.js';
@@ -78,8 +79,29 @@ const EMITTERS = /(^|\.)(finishPreset|reportViolations|throwIfViolations)$/;
78
79
  * `imperative` metadata so `explain --format agent` and the check JSON give the
79
80
  * agent an actionable fix.
80
81
  *
81
- * Uses function-variant rules so standalone functions, arrow functions, and
82
- * class members are all covered.
82
+ * **What each rule reads** (bug 0337, applying bug 0333's ruling): each rule reads
83
+ * the broadest subject its condition has a variant for, and exactly ONE, because
84
+ * the subject kinds nest — a module's search reads the whole file, so running two
85
+ * of them under one rule id would report the same match twice.
86
+ *
87
+ * | rule | reads |
88
+ * | ----------------------------- | --------------------------------------- |
89
+ * | `no-inline-logic/<api>` | the whole **file** |
90
+ * | `no-generic-errors` | the whole **file** |
91
+ * | `no-stubs` | each **function** body |
92
+ * | `no-empty-bodies` | each **function** body |
93
+ * | `no-copy-paste` | function bodies, pairwise |
94
+ * | `no-verdict-outside-rules` | the whole **file** |
95
+ *
96
+ * The two file-reading rules therefore see a bare top-level call, one in a class's
97
+ * static block, and one in a field initializer. A match with nothing named
98
+ * enclosing it is reported against the file.
99
+ *
100
+ * This paragraph read "Uses function-variant rules so standalone functions, arrow
101
+ * functions, and class members are all covered" until 0337 made two of the six
102
+ * read a module. It is the hover text an adopter sees, and leaving it would have
103
+ * been a comment outliving its mechanism — the defect this change fixed one file
104
+ * over, in `recommended.ts`, and then nearly repeated here.
83
105
  */
84
106
  // Presets collect object-literal functions unconditionally. `functions()`
85
107
  // keeps these anonymous values opt-in because every inline callback would flood
@@ -118,25 +140,47 @@ export function agentGuardrails(p, options) {
118
140
  }
119
141
  };
120
142
  for (const api of options.noInlineLogic ?? []) {
121
- push(functions(p, COLLECT_ALL).that().resideInFile(options.src).should().notContain(call(api)), {
143
+ // `modules()`, not `functions()` — bug 0337, applying bug 0333's ruling to this
144
+ // preset: each rule reads the broadest subject its condition has a variant for,
145
+ // and exactly one, because the subject kinds nest. `moduleNotContain` reads the
146
+ // whole file, so a bare top-level call, one in a class's static block and one in
147
+ // a field initializer are reported — measured silent before this, under a rule
148
+ // the adopter had named `eval`.
149
+ push(modules(p)
150
+ .that()
151
+ .resideInFile(options.src)
152
+ .should()
153
+ .satisfy(moduleNotContain(call(api))), {
122
154
  id: `preset/agent/no-inline-logic/${api}`,
123
- because: `${api} inline in a function is logic that belongs behind a named helper`,
155
+ // NOT "inline in a function" — this rule reads the whole file since bug
156
+ // 0337, so a top-level call would have rendered with a rationale naming a
157
+ // construct the code does not contain. `because` is surfaced on every
158
+ // violation and is the agent-actionable half, so a wrong one sends the
159
+ // author to the wrong place. It is not hashed (`hashViolation` composes
160
+ // `rule::subjectOf`), so correcting it moves no adopter's baseline entry.
161
+ because: `an inline ${api} call is logic that belongs behind a named helper`,
124
162
  suggestion: `extract the ${api} call into a named helper function`,
125
163
  imperative: `Do NOT call ${api} inline — extract it behind a named helper`,
126
164
  }, 'error');
127
165
  }
128
166
  if (options.noGenericErrors) {
129
- push(functions(p, COLLECT_ALL)
130
- .that()
131
- .resideInFile(options.src)
132
- .should()
133
- .satisfy(functionNoGenericErrors()), {
167
+ // `modules()` too, and the reason is this rule's OWN wording: its imperative is
168
+ // "Do NOT throw new Error()", not "…in a function", so a throw at module scope
169
+ // or in a static block was a false green against the rule as written (bug 0337).
170
+ // That test — does the rule's own imperative claim more than its subject reads —
171
+ // is what puts this rule in scope and leaves `no-stubs` out of it.
172
+ push(modules(p).that().resideInFile(options.src).should().satisfy(moduleNoGenericErrors()), {
134
173
  id: 'preset/agent/no-generic-errors',
135
174
  because: 'a generic Error loses the type/context callers need to handle it',
136
175
  suggestion: 'throw a domain-specific error (NotFoundError, ValidationError, …)',
137
176
  imperative: 'Do NOT throw new Error() — throw a domain-specific error class',
138
177
  }, 'error');
139
178
  }
179
+ // `functions()`, deliberately, and bug 0337 measured the case for leaving it:
180
+ // a `// TODO` at the end of a file or above a class IS unreported. That is not a
181
+ // false green, because this rule's imperative says "in a function body" — the
182
+ // wording and the reading agree. Widening it would be new coverage under an
183
+ // existing id, which is a different change with its own adopter cost.
140
184
  if (options.noStubs) {
141
185
  push(functions(p, COLLECT_ALL).that().resideInFile(options.src).should().satisfy(noStubComments()), {
142
186
  id: 'preset/agent/no-stubs',
@@ -145,6 +189,8 @@ export function agentGuardrails(p, options) {
145
189
  imperative: 'Do NOT leave stub comments (TODO/FIXME/"not implemented") in a function body',
146
190
  }, 'error');
147
191
  }
192
+ // `functions()`, per bug 0333's ruling: an empty body is a fact about a function
193
+ // and has no meaning at module scope.
148
194
  if (options.noEmptyBodies) {
149
195
  push(functions(p, COLLECT_ALL).that().resideInFile(options.src).should().satisfy(noEmptyBodies()), {
150
196
  id: 'preset/agent/no-empty-bodies',
@@ -340,9 +386,14 @@ function ruleFilesFindings(p, options) {
340
386
  // of its guards on, and the remedy it printed told the adopter to WIDEN a
341
387
  // correctly-scoped exemption to silence a finding that was wrong.
342
388
  //
343
- // So the derivation is `resideInFile`'s own, taken from the same helper:
344
- // every other site that stamps a `GlobSite` does `relative ? 'normalized' :
345
- // 'absolute'` (`identity.ts:83`, `:114`, `:157`), and this one now does too.
389
+ // So the derivation is `resideInFile`'s own, taken from the same helper: the
390
+ // exemption is applied through `resideInFile(glob)` a few lines above, and this
391
+ // declares the base that predicate declares. Bug 0339 widened what
392
+ // `resideInFile` MATCHES against (a `'**\/'`-led glob reads the root-relative
393
+ // view too) without widening what it DECLARES, because the anchor check is a
394
+ // no-op for an anchored glob and widening it would make the `unanchored` fault
395
+ // unreachable. The two derivations must not drift, which is what the paragraph
396
+ // above is about.
346
397
  const dead = declared.filter((glob) => isDeadSite({
347
398
  glob,
348
399
  kind: 'file-path',
@@ -1 +1 @@
1
- {"version":3,"file":"agent-guardrails.js","sourceRoot":"","sources":["../../src/presets/agent-guardrails.ts"],"names":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,EAAE,EAAE;QACR,IAAI,EAAE,CAAC;QACP,OAAO,EAAE,oBAAoB,IAAI,2DAA2D;QAC5F,OAAO,EACL,2FAA2F;YAC3F,4FAA4F;YAC5F,0CAA0C;QAC5C,UAAU,EACR,iFAAiF;YACjF,kFAAkF;YAClF,oFAAoF;YACpF,iCAAiC;YACjC,cAAc;QAChB,aAAa,EAAE,IAAI;KACpB,CAAC,CAAC,CAAA;IACH,8EAA8E;IAC9E,2EAA2E;IAC3E,OAAO,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;AAC3E,CAAC"}
@@ -1,4 +1,4 @@
1
- import picomatch from 'picomatch';
1
+ import { matchesPath, pathGlobMatcher } from '../core/project-relative.js';
2
2
  import { slices } from '../builders/slice-rule-builder.js';
3
3
  import { modules } from '../builders/module-rule-builder.js';
4
4
  import { smells } from '../smells/index.js';
@@ -66,11 +66,20 @@ export function strictBoundaries(p, options) {
66
66
  const builders = [];
67
67
  // Discover boundary folders from the glob pattern
68
68
  const boundaryGlob = options.folders;
69
- const matcher = picomatch(boundaryGlob);
69
+ const matcher = pathGlobMatcher(boundaryGlob);
70
70
  const boundaryFolders = [];
71
71
  for (const sf of p.getSourceFiles()) {
72
72
  const dir = sf.getFilePath().replace(/\/[^/]+$/, '');
73
- if (matcher(dir) && !boundaryFolders.includes(dir)) {
73
+ // Through the shared matcher — bug 0339. The comment on the `shared` guard
74
+ // below argued for a guard over normalization, and its reason was symmetry:
75
+ // "`folders` is not normalized either". That reason survives, because BOTH
76
+ // read the root-relative view now. What did not survive is the other half of
77
+ // it — that the remedy "states the absolute-path contract and tells the
78
+ // caller how to spell it". From a project path holding a dot-segment there
79
+ // was no spelling that worked: picomatch's default `dot: false` stops `**`
80
+ // crossing it, so the documented `'**\/src/*'` discovered 0 boundaries and
81
+ // the guard told the adopter their correct glob was wrong.
82
+ if (matchesPath(matcher, sf, dir, p.tsConfigPath) && !boundaryFolders.includes(dir)) {
74
83
  boundaryFolders.push(dir);
75
84
  }
76
85
  }
@@ -81,15 +90,27 @@ export function strictBoundaries(p, options) {
81
90
  sliceDef[name] = `${dir}/**`;
82
91
  }
83
92
  // --- Discovery guard: a boundaries preset that finds no boundaries is
84
- // misconfigured (globs match absolute paths — a project-relative glob
85
- // matches nothing). Fail loudly instead of generating zero rules
93
+ // misconfigured. (The parenthetical here used to read "globs match
94
+ // absolute paths — a project-relative glob matches nothing"; bug 0339
95
+ // made that false, and the remedy below no longer says it.) Fail loudly
96
+ // instead of generating zero rules
86
97
  // (the exact false green of ADR-008 / plan 0067), rather than the old
87
98
  // silent skip. ---
88
99
  builders.push(...assertDiscovered(boundaryFolders, {
89
100
  id: 'preset/boundaries/discovery',
90
101
  glob: boundaryGlob,
91
- remedy: `Boundary discovery matches absolute file paths, so '${boundaryGlob}' matched nothing. ` +
92
- `Use a '**/'-prefixed glob (e.g. '**/${boundaryGlob.replace(/^[./]+/, '')}') or the absolute project path.`,
102
+ // The remedy states what is TRUE after bug 0339, and no longer offers a
103
+ // prefix that would be a no-op. Discovery reads the absolute path AND the
104
+ // path named from the project root, so "prefix it with `**/`" is not a
105
+ // fix — for an already-anchored dead glob it produced
106
+ // `'**/**/no-such-dir/**'`, which reproduces the identical finding and
107
+ // loops an agent (ADR-009 rule 2: a remedy must remediate). What is left
108
+ // after the fix is a glob dead in BOTH views, so the honest answer is the
109
+ // causes, not a spelling.
110
+ remedy: `Boundary discovery tried '${boundaryGlob}' against both the absolute file path and the ` +
111
+ `path named from the project root, and it matched no folder. Common causes: a path segment ` +
112
+ `does not match what is on disk, the folder holds no source files your tsconfig includes, or ` +
113
+ `a '.'/'..' segment in the glob (neither occurs in either form — remove it).`,
93
114
  }));
94
115
  // --- Discovery guard for `shared`, mirroring the one above for `folders` ---
95
116
  //
@@ -110,11 +131,15 @@ export function strictBoundaries(p, options) {
110
131
  // middle two rows are indistinguishable from outside — same violation count,
111
132
  // no explanation — which is what the guard fixes.
112
133
  //
113
- // A GUARD, deliberately not normalization. `folders` is not normalized either;
134
+ // A GUARD **and** normalization, since bug 0339 — this paragraph used to argue
135
+ // for the guard alone, on the ground that "`folders` is not normalized either;
114
136
  // its remedy states the absolute-path contract and tells the caller how to
115
- // spell it. Rewriting `shared` globs instead would make one option on this
116
- // preset accept a spelling the other rejects, which is a worse asymmetry than
117
- // the one being fixed.
137
+ // spell it". The symmetry half survives, because both options normalize now.
138
+ // The other half did not: from a project path holding a dot-segment there was
139
+ // no spelling that worked, so the remedy could not state one — and
140
+ // `docs/presets.md` documents the project-relative spelling for both options,
141
+ // which discovered nothing. The guard keeps its job for a glob dead in both
142
+ // views.
118
143
  //
119
144
  // Matched against FILE paths, not `atPath`'s file-or-folder: the allow list is
120
145
  // what this guard is about, and `onlyImportFrom` matches resolved file paths.
@@ -122,14 +147,31 @@ export function strictBoundaries(p, options) {
122
147
  // `shared-isolation` via `atPath` yet creates no allowance, so it is a genuine
123
148
  // fault here and the guard must fire for it.
124
149
  for (const sharedGlob of sharedGlobs) {
125
- const matchesFile = picomatch(sharedGlob);
126
- const matchedFiles = p.getSourceFiles().filter((sf) => matchesFile(sf.getFilePath()));
150
+ const matchesFile = pathGlobMatcher(sharedGlob);
151
+ // The root-relative view too, as `folders` above and as `onlyImportFrom`
152
+ // already did through `candidatesFor` — bug 0339.
153
+ const matchedFiles = p
154
+ .getSourceFiles()
155
+ .filter((sf) => matchesPath(matchesFile, sf, sf.getFilePath(), p.tsConfigPath));
127
156
  builders.push(...assertDiscovered(matchedFiles, {
128
157
  id: 'preset/boundaries/shared-discovery',
129
158
  glob: sharedGlob,
130
- remedy: `A shared glob is matched against absolute file paths, so '${sharedGlob}' matched no file and ` +
131
- `creates no allowance — every import of it is reported as a cross-boundary violation. ` +
132
- `Use a '**/'-prefixed glob ending in '/**' (e.g. '**/${sharedGlob.replace(/^[./]+/, '').replace(/\/\*\*$/, '')}/**') or the absolute project path.`,
159
+ // Two corrections after bug 0339, both because the sentence outlived its
160
+ // mechanism. It said the glob "is matched against absolute file paths"
161
+ // (no longer true — both views are tried) and that it "creates no
162
+ // allowance" (never reliable: the allow list reaches `onlyImportFrom` →
163
+ // `candidatesFor`, which appends the root-relative resolved path
164
+ // UNCONDITIONALLY, so for the residual population — `'*/shared/**'`,
165
+ // `'./src/shared/**'` — an allowance does exist while this guard fires).
166
+ // ADR-009 rule 2 takes the fact the guard can support over the cause it
167
+ // cannot. The `'/**'` advice stays, because a folder glob with no
168
+ // trailing `/**` really does select files for `atPath` and create no
169
+ // allowance — that is this guard's own neighbouring test.
170
+ remedy: `A shared glob is tried against the absolute file path and the path named from the project ` +
171
+ `root, and '${sharedGlob}' matched no file in this project. A shared entry must match FILES ` +
172
+ `to create an allowance, so a folder glob needs a trailing '/**' ` +
173
+ `(e.g. '${sharedGlob.replace(/\/\*\*$/, '')}/**'); otherwise a path segment does not match ` +
174
+ `what is on disk, or the folder holds no source files your tsconfig includes.`,
133
175
  }));
134
176
  }
135
177
  // --- No cycles between boundaries ---
@@ -1 +1 @@
1
- {"version":3,"file":"boundaries.js","sourceRoot":"","sources":["../../src/presets/boundaries.ts"],"names":[],"mappings":"AAGA,OAAO,SAAS,MAAM,WAAW,CAAA;AAGjC,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAA;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAE3C,OAAO,EACL,MAAM,EACN,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,OAAO,GACR,MAAM,aAAa,CAAA;AAsCpB,MAAM,QAAQ,GAAG;IACf,oCAAoC;IACpC,6BAA6B;IAC7B,qCAAqC;IACrC,oCAAoC;IACpC,kCAAkC;IAClC,uCAAuC;CAC/B,CAAA;AAEV;;GAEG;AACH,SAAS,oBAAoB,CA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U,EACR,0JAA0J;YAC5J,UAAU,EAAE,wEAAwE;SACrF,EACD,MAAM,EACN,MAAM,EACN,WAAW,CACZ,CACF,CAAA;IACH,CAAC;IAED,0EAA0E;IAC1E,oEAAoE;IACpE,gFAAgF;IAChF,2EAA2E;IAC3E,OAAO,OAAO,CACZ,CAAC,GAAG,gBAAgB,EAAE,GAAG,qBAAqB,CAAC,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,EAAE,GAAG,QAAQ,CAAC,EAC7F,OAAO,CACR,CAAA;AACH,CAAC"}
@@ -2,6 +2,7 @@ import type { CollectResult } from '@nielspeter/eess';
2
2
  import type { ArchProject } from '../core/project.js';
3
3
  import type { Condition } from '@nielspeter/eess';
4
4
  import type { ArchFunction } from '../models/arch-function.js';
5
+ import type { SourceFile } from 'ts-morph';
5
6
  import type { RuleBuilderLike } from '@nielspeter/eess';
6
7
  import type { PresetBaseOptions } from './shared.js';
7
8
  export interface RecommendedOptions extends PresetBaseOptions<RecommendedRuleId> {
@@ -23,7 +24,8 @@ export interface RecommendedOptions extends PresetBaseOptions<RecommendedRuleId>
23
24
  * needs updating.
24
25
  */
25
26
  declare const SPECS: readonly [{
26
- readonly condition: Condition<ArchFunction>;
27
+ readonly condition: Condition<SourceFile>;
28
+ readonly subject: "module";
27
29
  readonly meta: {
28
30
  readonly id: "preset/recommended/no-eval";
29
31
  readonly because: "eval() executes arbitrary code — a code-injection risk";
@@ -32,7 +34,8 @@ declare const SPECS: readonly [{
32
34
  };
33
35
  readonly default: "error";
34
36
  }, {
35
- readonly condition: Condition<ArchFunction>;
37
+ readonly condition: Condition<SourceFile>;
38
+ readonly subject: "module";
36
39
  readonly meta: {
37
40
  readonly id: "preset/recommended/no-function-constructor";
38
41
  readonly because: "the Function constructor is eval() in disguise";
@@ -41,7 +44,8 @@ declare const SPECS: readonly [{
41
44
  };
42
45
  readonly default: "error";
43
46
  }, {
44
- readonly condition: Condition<ArchFunction>;
47
+ readonly condition: Condition<SourceFile>;
48
+ readonly subject: "module";
45
49
  readonly meta: {
46
50
  readonly id: "preset/recommended/no-silent-catch";
47
51
  readonly because: "a silent catch hides failures";
@@ -51,6 +55,7 @@ declare const SPECS: readonly [{
51
55
  readonly default: "warn";
52
56
  }, {
53
57
  readonly condition: Condition<ArchFunction>;
58
+ readonly subject: "function";
54
59
  readonly meta: {
55
60
  readonly id: "preset/recommended/no-empty-bodies";
56
61
  readonly because: "an empty function body is usually an unfinished stub";
@@ -80,9 +85,27 @@ type RecommendedRuleId = (typeof SPECS)[number]['meta']['id'];
80
85
  * glob is dead) is `error` regardless of severity and fails the build: `'warn'`
81
86
  * grades violations, not a rule that cannot enforce anything.
82
87
  *
83
- * Overlaps `agentGuardrails` on empty bodies and `eval`. For agent-focused
84
- * projects prefer `agentGuardrails` alone, or override the duplicated ids to
85
- * `'off'` in one preset.
88
+ * Overlaps `agentGuardrails` on empty bodies and `eval`, and since bug 0337 the two READ the same
89
+ * code again. Between 0333 and 0337 they did not: this preset's `eval` rule read the whole file
90
+ * while `agentGuardrails` still read function bodies, so "prefer `agentGuardrails` alone" — which
91
+ * this comment once advised, then withdrew — meant less coverage. Both now read module scope for
92
+ * the rules this ruling moved, so running both doubles a finding rather than hiding one; override a
93
+ * duplicated id to `'off'` in one of them if the doubled finding is noise.
94
+ *
95
+ * "the rules this ruling MOVED" and not "the rules whose conditions have a module variant" — review
96
+ * caught the wider phrasing being false as written: `no-stubs`' condition has a module variant and
97
+ * still reads functions, deliberately
98
+ * ([0344](../../../../work/bugs/0344-no-stubs-reads-function-bodies-though-its-condition-has-a-module-variant.md)).
99
+ * This paragraph replaced one that outlived its mechanism; seeding the replacement with a claim that
100
+ * was already half-stale would have been the same defect in a shorter life.
101
+ *
102
+ * **Two tables, kept in step by hand, and that is the standing risk.** 0333 made the subject ruling
103
+ * for this preset's `SPECS` and 0337 applied it to the sibling — two records for one decision,
104
+ * because nothing binds them. Whether they should agree by construction is the open question in
105
+ * [0343](../../../../work/bugs/0343-two-presets-carry-one-subject-ruling-in-two-tables.md) — an OPEN
106
+ * record, deliberately: this sentence used to point at 0337, which is closed and in the folder the
107
+ * corpus gate freezes, so the question it called open had no live home. What exists today is this
108
+ * paragraph.
86
109
  */
87
110
  /**
88
111
  * `report` names a delivery mode; omitting it returns the un-executed builders.
@@ -1 +1 @@
1
- {"version":3,"file":"recommended.d.ts","sourceRoot":"","sources":["../../src/presets/recommended.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAErD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAK9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAUpD,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB,CAAC,iBAAiB,CAAC;IAC9E;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAQD;;;;GAIG;AACH,QAAA,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyC6B,CAAA;AAExC;;;;;GAKG;AACH,KAAK,iBAAiB,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAA;AAI7D;;;;;;;;;;;;;;;;;GAiBG;AACH;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CACzB,CAAC,EAAE,WAAW,EACd,OAAO,EAAE,kBAAkB,GAAG;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,GACnD,eAAe,EAAE,CAAA;AACpB,wBAAgB,WAAW,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,aAAa,CAAA"}
1
+ {"version":3,"file":"recommended.d.ts","sourceRoot":"","sources":["../../src/presets/recommended.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAErD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAQ1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAUpD,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB,CAAC,iBAAiB,CAAC;IAC9E;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AA0BD;;;;GAIG;AACH,QAAA,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6C6B,CAAA;AAwBxC;;;;;GAKG;AACH,KAAK,iBAAiB,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAA;AAI7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CACzB,CAAC,EAAE,WAAW,EACd,OAAO,EAAE,kBAAkB,GAAG;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,GACnD,eAAe,EAAE,CAAA;AACpB,wBAAgB,WAAW,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,aAAa,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import { functions } from '../builders/function-rule-builder.js';
2
- import { functionNoEval, functionNoFunctionConstructor } from '../rules/security.js';
3
- import { functionNoSilentCatch } from '../rules/errors.js';
2
+ import { modules } from '../builders/module-rule-builder.js';
3
+ import { moduleNoEval, moduleNoFunctionConstructor } from '../rules/security.js';
4
+ import { moduleNoSilentCatch } from '../rules/errors.js';
4
5
  import { noEmptyBodies } from '../rules/hygiene.js';
5
6
  import { overrideFindings, validateOverrides, declareEmptyIfListed, presetDeclarationSpelling, declaredEmptyFindings, deliver, } from './shared.js';
6
7
  /**
@@ -10,7 +11,8 @@ import { overrideFindings, validateOverrides, declareEmptyIfListed, presetDeclar
10
11
  */
11
12
  const SPECS = [
12
13
  {
13
- condition: functionNoEval(),
14
+ condition: moduleNoEval(),
15
+ subject: 'module',
14
16
  meta: {
15
17
  id: 'preset/recommended/no-eval',
16
18
  because: 'eval() executes arbitrary code — a code-injection risk',
@@ -20,7 +22,8 @@ const SPECS = [
20
22
  default: 'error',
21
23
  },
22
24
  {
23
- condition: functionNoFunctionConstructor(),
25
+ condition: moduleNoFunctionConstructor(),
26
+ subject: 'module',
24
27
  meta: {
25
28
  id: 'preset/recommended/no-function-constructor',
26
29
  because: 'the Function constructor is eval() in disguise',
@@ -30,7 +33,8 @@ const SPECS = [
30
33
  default: 'error',
31
34
  },
32
35
  {
33
- condition: functionNoSilentCatch(),
36
+ condition: moduleNoSilentCatch(),
37
+ subject: 'module',
34
38
  meta: {
35
39
  id: 'preset/recommended/no-silent-catch',
36
40
  because: 'a silent catch hides failures',
@@ -41,6 +45,7 @@ const SPECS = [
41
45
  },
42
46
  {
43
47
  condition: noEmptyBodies(),
48
+ subject: 'function',
44
49
  meta: {
45
50
  id: 'preset/recommended/no-empty-bodies',
46
51
  because: 'an empty function body is usually an unfinished stub',
@@ -50,6 +55,23 @@ const SPECS = [
50
55
  default: 'warn',
51
56
  },
52
57
  ];
58
+ /**
59
+ * The builder a spec reads its subject with (bug 0333), selected and narrowed in one place so the
60
+ * loop below cannot pair a condition with the wrong one.
61
+ *
62
+ * `satisfy` is called on the concrete builder while its element type is still known — a single
63
+ * `satisfy` after the branch would need the union, which no condition accepts.
64
+ */
65
+ function builderFor(p, spec, include) {
66
+ if (spec.subject === 'module') {
67
+ return modules(p).that().resideInFile(include).should().satisfy(spec.condition);
68
+ }
69
+ return functions(p, { includeObjectLiteralFunctions: true })
70
+ .that()
71
+ .resideInFile(include)
72
+ .should()
73
+ .satisfy(spec.condition);
74
+ }
53
75
  const RULE_IDS = SPECS.map((s) => s.meta.id);
54
76
  export function recommended(p, options = {}) {
55
77
  const include = options.include ?? '**/src/**';
@@ -57,7 +79,8 @@ export function recommended(p, options = {}) {
57
79
  const overrideProblems = overrideFindings(options.overrides, RULE_IDS);
58
80
  const builders = [];
59
81
  const constructed = [];
60
- for (const { condition, meta, default: def } of SPECS) {
82
+ for (const spec of SPECS) {
83
+ const { meta, default: def } = spec;
61
84
  const sev = options.overrides?.[meta.id] ?? def;
62
85
  if (sev === 'off')
63
86
  continue;
@@ -65,11 +88,7 @@ export function recommended(p, options = {}) {
65
88
  builders.push(
66
89
  // Plan 0089's carrier. Applied at construction so it reaches every rule
67
90
  // this preset builds, not only the ones routed through `collectRule`.
68
- declareEmptyIfListed(functions(p, { includeObjectLiteralFunctions: true })
69
- .that()
70
- .resideInFile(include)
71
- .should()
72
- .satisfy(condition)
91
+ declareEmptyIfListed(builderFor(p, spec, include)
73
92
  .rule({ ...meta, declarationSpelling: presetDeclarationSpelling(meta.id) })
74
93
  .asSeverity(sev), meta.id, options));
75
94
  }
@@ -1 +1 @@
1
- {"version":3,"file":"recommended.js","sourceRoot":"","sources":["../../src/presets/recommended.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAA;AAChE,OAAO,EAAE,cAAc,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAA;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGnD,OAAO,EAC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C,IAAI,GAAG,CAAA;QAC/C,IAAI,GAAG,KAAK,KAAK;YAAE,SAAQ;QAC3B,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACzB,QAAQ,CAAC,IAAI;QACX,wEAAwE;QACxE,sEAAsE;QACtE,oBAAoB,CAClB,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC;aACzB,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,mBAAmB,EAAE,yBAAyB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;aAC1E,UAAU,CAAC,GAAG,CAAC,EAClB,IAAI,CAAC,EAAE,EACP,OAAO,CACR,CACF,CAAA;IACH,CAAC;IAED,0EAA0E;IAC1E,oEAAoE;IACpE,4EAA4E;IAC5E,6EAA6E;IAC7E,uBAAuB;IACvB,OAAO,OAAO,CACZ,CAAC,GAAG,gBAAgB,EAAE,GAAG,qBAAqB,CAAC,OAAO,CAAC,WAAW,EAAE,WAAW,CAAC,EAAE,GAAG,QAAQ,CAAC,EAC9F,OAAO,CACR,CAAA;AACH,CAAC"}
@@ -17,6 +17,23 @@ export declare function noGenericErrors(): Condition<ClassDeclaration>;
17
17
  export declare function noTypeErrors(): Condition<ClassDeclaration>;
18
18
  export declare function functionNoGenericErrors(): Condition<ArchFunction>;
19
19
  export declare function functionNoTypeErrors(): Condition<ArchFunction>;
20
+ /**
21
+ * No throwing generic Error anywhere the FILE runs code — bug 0337.
22
+ *
23
+ * The third spelling of one rule, and the broadest: `noGenericErrors` reads a
24
+ * class, `functionNoGenericErrors` a function, this one the whole module. Each is
25
+ * the same `notContain(newExpr('Error'))` over a different subject, so there is no
26
+ * second derivation of what a generic error is.
27
+ *
28
+ * It exists because `agentGuardrails` built `no-generic-errors` over `functions()`
29
+ * while its own imperative says "Do NOT throw new Error()" — not "…in a
30
+ * function". Measured before this: a `throw new Error()` at top level and one in a
31
+ * class's static block were both reported as nothing.
32
+ *
33
+ * A rule reads exactly ONE of these three (bug 0333): the subject kinds nest, so
34
+ * running two for one rule id reports the same throw twice.
35
+ */
36
+ export declare function moduleNoGenericErrors(): Condition<SourceFile>;
20
37
  /**
21
38
  * Catch blocks anywhere a class runs code must reference the caught error variable: member
22
39
  * bodies, parameter defaults, property initializers (an arrow-function event handler included),
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/rules/errors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAoB,MAAM,kBAAkB,CAAA;AAGnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAO9D;;;;;;;;GAQG;AACH,wBAAgB,eAAe,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAE7D;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAE1D;AAID,wBAAgB,uBAAuB,IAAI,SAAS,CAAC,YAAY,CAAC,CAEjE;AAED,wBAAgB,oBAAoB,IAAI,SAAS,CAAC,YAAY,CAAC,CAE9D;AAWD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAe3D;AAED,wBAAgB,qBAAqB,IAAI,SAAS,CAAC,YAAY,CAAC,CAe/D;AAED,wBAAgB,mBAAmB,IAAI,SAAS,CAAC,UAAU,CAAC,CAa3D"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/rules/errors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAoB,MAAM,kBAAkB,CAAA;AAInE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAQ9D;;;;;;;;GAQG;AACH,wBAAgB,eAAe,IAA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