@nielspeter/eess 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -1
- package/dist/baseline-generator.d.ts +9 -0
- package/dist/baseline-generator.d.ts.map +1 -1
- package/dist/baseline-generator.js +9 -0
- package/dist/baseline-generator.js.map +1 -1
- package/dist/baseline.d.ts +1 -1
- package/dist/cardinality.d.ts.map +1 -1
- package/dist/cardinality.js +20 -5
- package/dist/cardinality.js.map +1 -1
- package/dist/cli-config.d.ts +59 -0
- package/dist/cli-config.d.ts.map +1 -0
- package/dist/cli-config.js +84 -0
- package/dist/cli-config.js.map +1 -0
- package/dist/collect-result.d.ts +94 -0
- package/dist/collect-result.d.ts.map +1 -0
- package/dist/collect-result.js +142 -0
- package/dist/collect-result.js.map +1 -0
- package/dist/combinators.d.ts +14 -0
- package/dist/combinators.d.ts.map +1 -1
- package/dist/combinators.js +53 -16
- package/dist/combinators.js.map +1 -1
- package/dist/condition.d.ts +37 -0
- package/dist/condition.d.ts.map +1 -1
- package/dist/condition.js +48 -1
- package/dist/condition.js.map +1 -1
- package/dist/correspondence.d.ts +30 -0
- package/dist/correspondence.d.ts.map +1 -1
- package/dist/correspondence.js +36 -1
- package/dist/correspondence.js.map +1 -1
- package/dist/dedupe-config-findings.d.ts.map +1 -1
- package/dist/dedupe-config-findings.js +27 -0
- package/dist/dedupe-config-findings.js.map +1 -1
- package/dist/diff-aware.d.ts +8 -9
- package/dist/diff-aware.d.ts.map +1 -1
- package/dist/diff-aware.js +38 -17
- package/dist/diff-aware.js.map +1 -1
- package/dist/emitter-findings.d.ts +167 -0
- package/dist/emitter-findings.d.ts.map +1 -0
- package/dist/emitter-findings.js +237 -0
- package/dist/emitter-findings.js.map +1 -0
- package/dist/errors.d.ts +48 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +61 -0
- package/dist/errors.js.map +1 -1
- package/dist/exclusion-comments.d.ts +36 -1
- package/dist/exclusion-comments.d.ts.map +1 -1
- package/dist/exclusion-comments.js +185 -37
- package/dist/exclusion-comments.js.map +1 -1
- package/dist/execute-rule.d.ts +12 -3
- package/dist/execute-rule.d.ts.map +1 -1
- package/dist/execute-rule.js +184 -7
- package/dist/execute-rule.js.map +1 -1
- package/dist/file-walk.d.ts +22 -0
- package/dist/file-walk.d.ts.map +1 -0
- package/dist/file-walk.js +51 -0
- package/dist/file-walk.js.map +1 -0
- package/dist/format-json.d.ts +13 -0
- package/dist/format-json.d.ts.map +1 -1
- package/dist/format-json.js +24 -0
- package/dist/format-json.js.map +1 -1
- package/dist/index.d.ts +14 -46
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -41
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +55 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +92 -0
- package/dist/internal.js.map +1 -0
- package/dist/mask-non-comment.d.ts +49 -0
- package/dist/mask-non-comment.d.ts.map +1 -0
- package/dist/mask-non-comment.js +261 -0
- package/dist/mask-non-comment.js.map +1 -0
- package/dist/owns-empty-discovery.d.ts.map +1 -1
- package/dist/owns-empty-discovery.js +12 -4
- package/dist/owns-empty-discovery.js.map +1 -1
- package/dist/path-suffix.d.ts +57 -0
- package/dist/path-suffix.d.ts.map +1 -0
- package/dist/path-suffix.js +73 -0
- package/dist/path-suffix.js.map +1 -0
- package/dist/predicate.d.ts +12 -0
- package/dist/predicate.d.ts.map +1 -1
- package/dist/predicate.js +20 -1
- package/dist/predicate.js.map +1 -1
- package/dist/preset-dispatch.d.ts +6 -34
- package/dist/preset-dispatch.d.ts.map +1 -1
- package/dist/preset-dispatch.js +30 -52
- package/dist/preset-dispatch.js.map +1 -1
- package/dist/report.d.ts +31 -7
- package/dist/report.d.ts.map +1 -1
- package/dist/report.js +174 -15
- package/dist/report.js.map +1 -1
- package/dist/rule-builder-like.d.ts +8 -2
- package/dist/rule-builder-like.d.ts.map +1 -1
- package/dist/rule-builder.d.ts +15 -0
- package/dist/rule-builder.d.ts.map +1 -1
- package/dist/rule-builder.js +41 -36
- package/dist/rule-builder.js.map +1 -1
- package/dist/rule-description.d.ts +50 -0
- package/dist/rule-description.d.ts.map +1 -1
- package/dist/rule-description.js +58 -0
- package/dist/rule-description.js.map +1 -1
- package/dist/selection-memo.d.ts +1 -3
- package/dist/selection-memo.d.ts.map +1 -1
- package/dist/selection-memo.js +1 -3
- package/dist/selection-memo.js.map +1 -1
- package/dist/silent-exclusion.d.ts +12 -0
- package/dist/silent-exclusion.d.ts.map +1 -1
- package/dist/silent-exclusion.js +22 -0
- package/dist/silent-exclusion.js.map +1 -1
- package/dist/terminal-builder.d.ts +29 -15
- package/dist/terminal-builder.d.ts.map +1 -1
- package/dist/terminal-builder.js +97 -51
- package/dist/terminal-builder.js.map +1 -1
- package/dist/vacuity-findings.d.ts +0 -6
- package/dist/vacuity-findings.d.ts.map +1 -1
- package/dist/vacuity-findings.js +27 -57
- package/dist/vacuity-findings.js.map +1 -1
- package/dist/violation.d.ts +22 -1
- package/dist/violation.d.ts.map +1 -1
- package/dist/violation.js.map +1 -1
- package/dist/watch.d.ts +71 -0
- package/dist/watch.d.ts.map +1 -0
- package/dist/watch.js +129 -0
- package/dist/watch.js.map +1 -0
- package/package.json +6 -1
package/dist/rule-builder.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { assertionAdviceFor } from './assertion-advice.js';
|
|
2
|
+
import { collectResult } from './collect-result.js';
|
|
3
|
+
import { selectMatching, matchingElements } from './correspondence.js';
|
|
4
|
+
import { recordPredicate } from './predicate.js';
|
|
2
5
|
import { countDeclaredGlobs, stampGlobs } from './glob-site.js';
|
|
3
6
|
import { TerminalBuilder, assertionLessViolation } from './terminal-builder.js';
|
|
4
7
|
import { assertsCardinality as conditionAssertsCardinality } from './cardinality.js';
|
|
8
|
+
import { ruleDescriptionOf, ruleDescriptionFrom } from './rule-description.js';
|
|
9
|
+
import { conditionContextFrom } from './condition.js';
|
|
5
10
|
/**
|
|
6
11
|
* A declared glob's own label in a dead-glob finding — the predicate/
|
|
7
12
|
* condition's description, disambiguated with the literal glob only when
|
|
@@ -18,12 +23,31 @@ function describeOrigin(description, glob, siteCount) {
|
|
|
18
23
|
* rather than a method body, to keep the class itself under this repo's own
|
|
19
24
|
* 300-line class-length gate (`arch.internal.rules.ts`).
|
|
20
25
|
*/
|
|
21
|
-
|
|
26
|
+
/**
|
|
27
|
+
* The globs a rule declares, stamped with where each came from.
|
|
28
|
+
*
|
|
29
|
+
* Exported (as family plumbing) so `eess-ts` can call it instead of keeping its
|
|
30
|
+
* own copy — they were 94% similar, and the difference was not cosmetic: only
|
|
31
|
+
* the eess-ts copy honoured `originLabel`. The kernel's `Predicate` has carried
|
|
32
|
+
* that field all along and this function ignored it, so a preset's label was
|
|
33
|
+
* dropped for `eess-md`, `eess-mermaid` and `eess-gherkin`. Found by unifying.
|
|
34
|
+
*/
|
|
35
|
+
export function declaredGlobsOf(
|
|
36
|
+
// `readonly`, widened so a caller holding a frozen declaration can pass it
|
|
37
|
+
// without a copy. Strictly more permissive; the body only iterates.
|
|
38
|
+
predicates, conditions) {
|
|
22
39
|
const trees = [];
|
|
23
40
|
for (const predicate of predicates) {
|
|
24
41
|
if (predicate.globs) {
|
|
25
42
|
const count = countDeclaredGlobs(predicate.globs);
|
|
26
|
-
trees.push(stampGlobs(predicate.globs, 'selector', (g) =>
|
|
43
|
+
trees.push(stampGlobs(predicate.globs, 'selector', (g) =>
|
|
44
|
+
// A preset's `originLabel` names the option the user wrote rather
|
|
45
|
+
// than the calls it expanded into. Used VERBATIM, skipping
|
|
46
|
+
// `describeOrigin`: that appends `("glob")` to disambiguate a
|
|
47
|
+
// predicate holding several sites, and a label already names exactly
|
|
48
|
+
// one option and one glob — left in, the finding read
|
|
49
|
+
// `shared: "**/x/**" ("**/x/**")`.
|
|
50
|
+
predicate.originLabel ?? describeOrigin(predicate.description, g, count)));
|
|
27
51
|
}
|
|
28
52
|
}
|
|
29
53
|
for (const condition of conditions) {
|
|
@@ -139,22 +163,18 @@ export class RuleBuilder extends TerminalBuilder {
|
|
|
139
163
|
* @param opts.identify - map an element to its message metadata (name/file/line)
|
|
140
164
|
*/
|
|
141
165
|
select(opts) {
|
|
142
|
-
|
|
143
|
-
return { elements: filtered, label: opts.label, identify: opts.identify };
|
|
166
|
+
return selectMatching(this.getElements(), this._predicates, opts);
|
|
144
167
|
}
|
|
145
168
|
/**
|
|
146
169
|
* Return a structured description of this rule without executing it.
|
|
147
170
|
* Used by the `explain` CLI subcommand.
|
|
148
171
|
*/
|
|
149
172
|
describeRule() {
|
|
150
|
-
return {
|
|
173
|
+
return ruleDescriptionFrom({
|
|
174
|
+
metadata: this._metadata,
|
|
175
|
+
reason: this._reason,
|
|
151
176
|
rule: this.buildRuleDescription(),
|
|
152
|
-
|
|
153
|
-
because: this._reason,
|
|
154
|
-
suggestion: this._metadata?.suggestion,
|
|
155
|
-
docs: this._metadata?.docs,
|
|
156
|
-
imperative: this._metadata?.imperative,
|
|
157
|
-
};
|
|
177
|
+
});
|
|
158
178
|
}
|
|
159
179
|
/**
|
|
160
180
|
* ADR-010: is this rule's assertion satisfied by an empty selection, as a
|
|
@@ -231,13 +251,7 @@ export class RuleBuilder extends TerminalBuilder {
|
|
|
231
251
|
*/
|
|
232
252
|
addPredicate(predicate) {
|
|
233
253
|
const next = this.copy();
|
|
234
|
-
next._predicates.
|
|
235
|
-
// Bug 0155 state 2: a predicate-only method used after `.should()`. Dual-use
|
|
236
|
-
// methods dispatch to conditions in that phase and never reach here, so this
|
|
237
|
-
// is a filter written where an assertion was meant — the one state whose fix
|
|
238
|
-
// is "move it before .should()", not "add a condition".
|
|
239
|
-
if (next._phase === 'condition')
|
|
240
|
-
next._misplaced.push(predicate.description);
|
|
254
|
+
recordPredicate(predicate, next._predicates, next._misplaced, next._phase);
|
|
241
255
|
return next;
|
|
242
256
|
}
|
|
243
257
|
/**
|
|
@@ -292,14 +306,7 @@ export class RuleBuilder extends TerminalBuilder {
|
|
|
292
306
|
* Build the rule description from predicates and conditions.
|
|
293
307
|
*/
|
|
294
308
|
buildRuleDescription() {
|
|
295
|
-
|
|
296
|
-
const conditionDesc = this._conditions.map((c) => c.description).join(' and ');
|
|
297
|
-
const parts = [];
|
|
298
|
-
if (predicateDesc)
|
|
299
|
-
parts.push(`that ${predicateDesc}`);
|
|
300
|
-
if (conditionDesc)
|
|
301
|
-
parts.push(`should ${conditionDesc}`);
|
|
302
|
-
return parts.join(' ');
|
|
309
|
+
return ruleDescriptionOf(this._predicates, this._conditions);
|
|
303
310
|
}
|
|
304
311
|
/**
|
|
305
312
|
* Execute the full pipeline: filter elements with predicates, evaluate
|
|
@@ -319,7 +326,7 @@ export class RuleBuilder extends TerminalBuilder {
|
|
|
319
326
|
*/
|
|
320
327
|
collectViolations() {
|
|
321
328
|
const allElements = this.getElements();
|
|
322
|
-
const filtered = allElements
|
|
329
|
+
const filtered = matchingElements(allElements, this._predicates);
|
|
323
330
|
const examined = filtered.length;
|
|
324
331
|
if (filtered.length === 0) {
|
|
325
332
|
const sourceEmpty = this.sourceEmpty();
|
|
@@ -328,7 +335,7 @@ export class RuleBuilder extends TerminalBuilder {
|
|
|
328
335
|
// useful to say about one glob's fate against zero loaded files, and
|
|
329
336
|
// `sourceEmpty` outranks it in `evidencedViolations()` regardless.
|
|
330
337
|
const deadGlob = sourceEmpty ? undefined : this.deadGlobDiagnosis();
|
|
331
|
-
return
|
|
338
|
+
return collectResult([], { examined, sourceEmpty, deadGlob });
|
|
332
339
|
}
|
|
333
340
|
// Bug 0155 — gate-first, before the conditions run. See
|
|
334
341
|
// `assertionLessViolation` for why this is a finding and not a warning,
|
|
@@ -337,7 +344,7 @@ export class RuleBuilder extends TerminalBuilder {
|
|
|
337
344
|
// assertion too — see `assertionLessViolation`.
|
|
338
345
|
if (!this.assertsSomething() && this._expectEmpty === undefined) {
|
|
339
346
|
const ruleId = this._metadata?.id ?? (this.buildRuleDescription() || 'unnamed');
|
|
340
|
-
return
|
|
347
|
+
return collectResult([assertionLessViolation(ruleId, this.assertionAdvice())], { examined });
|
|
341
348
|
}
|
|
342
349
|
// Step 4: Build context for conditions
|
|
343
350
|
const context = this.buildConditionContext();
|
|
@@ -346,7 +353,7 @@ export class RuleBuilder extends TerminalBuilder {
|
|
|
346
353
|
for (const condition of this._conditions) {
|
|
347
354
|
violations.push(...condition.evaluate(filtered, context));
|
|
348
355
|
}
|
|
349
|
-
return
|
|
356
|
+
return collectResult(violations, { examined });
|
|
350
357
|
}
|
|
351
358
|
/**
|
|
352
359
|
* Build the `ConditionContext` passed to each condition.
|
|
@@ -356,13 +363,11 @@ export class RuleBuilder extends TerminalBuilder {
|
|
|
356
363
|
* Call `super.buildConditionContext()` and spread the result.
|
|
357
364
|
*/
|
|
358
365
|
buildConditionContext() {
|
|
359
|
-
return {
|
|
366
|
+
return conditionContextFrom({
|
|
367
|
+
metadata: this._metadata,
|
|
368
|
+
reason: this._reason,
|
|
360
369
|
rule: this.buildRuleDescription(),
|
|
361
|
-
|
|
362
|
-
ruleId: this._metadata?.id,
|
|
363
|
-
suggestion: this._metadata?.suggestion,
|
|
364
|
-
docs: this._metadata?.docs,
|
|
365
|
-
};
|
|
370
|
+
});
|
|
366
371
|
}
|
|
367
372
|
}
|
|
368
373
|
//# sourceMappingURL=rule-builder.js.map
|
package/dist/rule-builder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-builder.js","sourceRoot":"","sources":["../src/rule-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"rule-builder.js","sourceRoot":"","sources":["../src/rule-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,OAAO,EAAE,cAAc,EAAE,gBAAgB,E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AAC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;QAC9F,CAAC;QAED,uCAAuC;QACvC,MAAM,OAAO,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAA;QAE5C,wDAAwD;QACxD,MAAM,UAAU,GAAoB,EAAE,CAAA;QACtC,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACzC,UAAU,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAA;QAC3D,CAAC;QAED,OAAO,aAAa,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;IAChD,CAAC;IAED;;;;;;OAMG;IACO,qBAAqB;QAC7B,OAAO,oBAAoB,CAAC;YAC1B,QAAQ,EAAE,IAAI,CAAC,SAAS;YACxB,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,IAAI,EAAE,IAAI,CAAC,oBAAoB,EAAE;SAClC,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RuleMetadata } from './rule-metadata.js';
|
|
1
2
|
/**
|
|
2
3
|
* Structured description of a rule, returned by `.describe()`.
|
|
3
4
|
* Used by the `explain` CLI subcommand to dump active rules as JSON.
|
|
@@ -43,4 +44,53 @@ export interface Describable {
|
|
|
43
44
|
* two test copies already did.
|
|
44
45
|
*/
|
|
45
46
|
export declare function isDescribable(value: unknown): value is Describable;
|
|
47
|
+
/**
|
|
48
|
+
* The metadata half of a rule's description — one projection, four callers.
|
|
49
|
+
*
|
|
50
|
+
* `id`, `because`, `suggestion` and `docs` are read off `RuleMetadata` the same
|
|
51
|
+
* way everywhere. `rule` and `imperative` are the two axes that genuinely vary,
|
|
52
|
+
* so they are parameters rather than something this function guesses:
|
|
53
|
+
*
|
|
54
|
+
* - `rule` — the base `TerminalBuilder` says `id ?? 'unnamed'` (a SENTINEL that
|
|
55
|
+
* `dedupe-config-findings.ts` keys on, not an identity), a `RuleBuilder` says
|
|
56
|
+
* the assembled `ruleDescriptionOf(...)` sentence, and several `eess-ts`
|
|
57
|
+
* subclasses override it again on top of `...super.describeRule()`.
|
|
58
|
+
* - `imperativeFallback` — what to say for an agent prompt when the author
|
|
59
|
+
* declared no `imperative`. `eess-ts`'s `RuleDeclaration` falls back to the
|
|
60
|
+
* reason and its `describeRuleOf` to a derived Do-NOT/MUST sentence; the
|
|
61
|
+
* kernel has no fallback, and that is not an oversight this extraction
|
|
62
|
+
* quietly fixed — `imperative` is read only by `eess-ts`'s
|
|
63
|
+
* `explain --format agent`, and `eess-mermaid`'s `explain` does not project
|
|
64
|
+
* the field at all. The kernel has no consumer to be wrong for.
|
|
65
|
+
*
|
|
66
|
+
* The four bodies were otherwise identical, which `no-copy-paste` reported as a
|
|
67
|
+
* 93% cluster.
|
|
68
|
+
*/
|
|
69
|
+
export declare function ruleDescriptionFrom(opts: {
|
|
70
|
+
metadata: RuleMetadata | undefined;
|
|
71
|
+
reason: string | undefined;
|
|
72
|
+
rule: string;
|
|
73
|
+
imperativeFallback?: string;
|
|
74
|
+
}): RuleDescription;
|
|
75
|
+
/**
|
|
76
|
+
* A rule's English description, assembled from what it declared.
|
|
77
|
+
*
|
|
78
|
+
* `subject` is the noun the rule opens with when its builder has one — the
|
|
79
|
+
* GraphQL builders say `schema that ... should ...` and
|
|
80
|
+
* `resolvers that ... should ...`; the general builders open with `that`. That
|
|
81
|
+
* one word was the only difference between four copies of this function, which
|
|
82
|
+
* `no-copy-paste` reported as a cluster at 100%.
|
|
83
|
+
*
|
|
84
|
+
* An empty predicate or condition list contributes nothing rather than an empty
|
|
85
|
+
* clause, so a rule that never reached `.should()` reads `that X` and not
|
|
86
|
+
* `that X should ` — the missing half is what `assertionAdvice` then reports.
|
|
87
|
+
*
|
|
88
|
+
* `slice-rule-builder.ts` is deliberately NOT a caller: its description is a
|
|
89
|
+
* different sentence (`slices [a, b] should ...`), not this one with a prefix.
|
|
90
|
+
*/
|
|
91
|
+
export declare function ruleDescriptionOf(predicates: readonly {
|
|
92
|
+
description: string;
|
|
93
|
+
}[], conditions: readonly {
|
|
94
|
+
description: string;
|
|
95
|
+
}[], subject?: string): string;
|
|
46
96
|
//# sourceMappingURL=rule-description.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-description.d.ts","sourceRoot":"","sources":["../src/rule-description.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,eAAe,CAAA;CACpC;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAIlE"}
|
|
1
|
+
{"version":3,"file":"rule-description.d.ts","sourceRoot":"","sources":["../src/rule-description.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,eAAe,CAAA;CACpC;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAIlE;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACxC,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAA;IAClC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B,GAAG,eAAe,CASlB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,SAAS;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,EAAE,EAC9C,UAAU,EAAE,SAAS;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,EAAE,EAC9C,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,CAOR"}
|
package/dist/rule-description.js
CHANGED
|
@@ -15,4 +15,62 @@ export function isDescribable(value) {
|
|
|
15
15
|
return false;
|
|
16
16
|
return typeof value.describeRule === 'function';
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* The metadata half of a rule's description — one projection, four callers.
|
|
20
|
+
*
|
|
21
|
+
* `id`, `because`, `suggestion` and `docs` are read off `RuleMetadata` the same
|
|
22
|
+
* way everywhere. `rule` and `imperative` are the two axes that genuinely vary,
|
|
23
|
+
* so they are parameters rather than something this function guesses:
|
|
24
|
+
*
|
|
25
|
+
* - `rule` — the base `TerminalBuilder` says `id ?? 'unnamed'` (a SENTINEL that
|
|
26
|
+
* `dedupe-config-findings.ts` keys on, not an identity), a `RuleBuilder` says
|
|
27
|
+
* the assembled `ruleDescriptionOf(...)` sentence, and several `eess-ts`
|
|
28
|
+
* subclasses override it again on top of `...super.describeRule()`.
|
|
29
|
+
* - `imperativeFallback` — what to say for an agent prompt when the author
|
|
30
|
+
* declared no `imperative`. `eess-ts`'s `RuleDeclaration` falls back to the
|
|
31
|
+
* reason and its `describeRuleOf` to a derived Do-NOT/MUST sentence; the
|
|
32
|
+
* kernel has no fallback, and that is not an oversight this extraction
|
|
33
|
+
* quietly fixed — `imperative` is read only by `eess-ts`'s
|
|
34
|
+
* `explain --format agent`, and `eess-mermaid`'s `explain` does not project
|
|
35
|
+
* the field at all. The kernel has no consumer to be wrong for.
|
|
36
|
+
*
|
|
37
|
+
* The four bodies were otherwise identical, which `no-copy-paste` reported as a
|
|
38
|
+
* 93% cluster.
|
|
39
|
+
*/
|
|
40
|
+
export function ruleDescriptionFrom(opts) {
|
|
41
|
+
return {
|
|
42
|
+
rule: opts.rule,
|
|
43
|
+
id: opts.metadata?.id,
|
|
44
|
+
because: opts.reason,
|
|
45
|
+
suggestion: opts.metadata?.suggestion,
|
|
46
|
+
docs: opts.metadata?.docs,
|
|
47
|
+
imperative: opts.metadata?.imperative ?? opts.imperativeFallback,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A rule's English description, assembled from what it declared.
|
|
52
|
+
*
|
|
53
|
+
* `subject` is the noun the rule opens with when its builder has one — the
|
|
54
|
+
* GraphQL builders say `schema that ... should ...` and
|
|
55
|
+
* `resolvers that ... should ...`; the general builders open with `that`. That
|
|
56
|
+
* one word was the only difference between four copies of this function, which
|
|
57
|
+
* `no-copy-paste` reported as a cluster at 100%.
|
|
58
|
+
*
|
|
59
|
+
* An empty predicate or condition list contributes nothing rather than an empty
|
|
60
|
+
* clause, so a rule that never reached `.should()` reads `that X` and not
|
|
61
|
+
* `that X should ` — the missing half is what `assertionAdvice` then reports.
|
|
62
|
+
*
|
|
63
|
+
* `slice-rule-builder.ts` is deliberately NOT a caller: its description is a
|
|
64
|
+
* different sentence (`slices [a, b] should ...`), not this one with a prefix.
|
|
65
|
+
*/
|
|
66
|
+
export function ruleDescriptionOf(predicates, conditions, subject) {
|
|
67
|
+
const predicateDesc = predicates.map((p) => p.description).join(' and ');
|
|
68
|
+
const conditionDesc = conditions.map((c) => c.description).join(' and ');
|
|
69
|
+
const parts = subject === undefined ? [] : [subject];
|
|
70
|
+
if (predicateDesc)
|
|
71
|
+
parts.push(`that ${predicateDesc}`);
|
|
72
|
+
if (conditionDesc)
|
|
73
|
+
parts.push(`should ${conditionDesc}`);
|
|
74
|
+
return parts.join(' ');
|
|
75
|
+
}
|
|
18
76
|
//# sourceMappingURL=rule-description.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-description.js","sourceRoot":"","sources":["../src/rule-description.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rule-description.js","sourceRoot":"","sources":["../src/rule-description.ts"],"names":[],"mappings":"AAsCA;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAA;IAC7D,IAAI,CAAC,CAAC,cAAc,IAAI,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IAC5C,OAAO,OAAO,KAAK,CAAC,YAAY,KAAK,UAAU,CAAA;AACjD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAKnC;IACC,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE;QACrB,OAAO,EAAE,IAAI,CAAC,MAAM;QACpB,UAAU,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU;QACrC,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI;QACzB,UAAU,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,IAAI,IAAI,CAAC,kBAAkB;KACjE,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,iBAAiB,CAC/B,UAA8C,EAC9C,UAA8C,EAC9C,OAAgB;IAEhB,MAAM,aAAa,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACxE,MAAM,aAAa,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACxE,MAAM,KAAK,GAAa,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAC9D,IAAI,aAAa;QAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,aAAa,EAAE,CAAC,CAAA;IACtD,IAAI,aAAa;QAAE,KAAK,CAAC,IAAI,CAAC,UAAU,aAAa,EAAE,CAAC,CAAA;IACxD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACxB,CAAC"}
|
package/dist/selection-memo.d.ts
CHANGED
|
@@ -38,9 +38,7 @@
|
|
|
38
38
|
* const selectionOf = selectionMemo<ArchFunction>()
|
|
39
39
|
*
|
|
40
40
|
* private selected(): ArchFunction[] {
|
|
41
|
-
* return selectionOf(this, () =>
|
|
42
|
-
* this.getElements().filter((e) => this._predicates.every((p) => p.test(e))),
|
|
43
|
-
* )
|
|
41
|
+
* return selectionOf(this, () => matchingElements(this.getElements(), this._predicates))
|
|
44
42
|
* }
|
|
45
43
|
*/
|
|
46
44
|
export declare function selectionMemo<T>(): (owner: object, compute: () => T[]) => T[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection-memo.d.ts","sourceRoot":"","sources":["../src/selection-memo.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"selection-memo.d.ts","sourceRoot":"","sources":["../src/selection-memo.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,aAAa,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,CAmB7E"}
|
package/dist/selection-memo.js
CHANGED
|
@@ -39,9 +39,7 @@ import { registerCacheReset } from './cache-registry.js';
|
|
|
39
39
|
* const selectionOf = selectionMemo<ArchFunction>()
|
|
40
40
|
*
|
|
41
41
|
* private selected(): ArchFunction[] {
|
|
42
|
-
* return selectionOf(this, () =>
|
|
43
|
-
* this.getElements().filter((e) => this._predicates.every((p) => p.test(e))),
|
|
44
|
-
* )
|
|
42
|
+
* return selectionOf(this, () => matchingElements(this.getElements(), this._predicates))
|
|
45
43
|
* }
|
|
46
44
|
*/
|
|
47
45
|
export function selectionMemo() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection-memo.js","sourceRoot":"","sources":["../src/selection-memo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAExD
|
|
1
|
+
{"version":3,"file":"selection-memo.js","sourceRoot":"","sources":["../src/selection-memo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAM,UAAU,aAAa;IAC3B,IAAI,KAAK,GAAG,IAAI,OAAO,EAAe,CAAA;IACtC,6EAA6E;IAC7E,0EAA0E;IAC1E,6EAA6E;IAC7E,4EAA4E;IAC5E,6EAA6E;IAC7E,6EAA6E;IAC7E,0EAA0E;IAC1E,kBAAkB,CAAC,GAAG,EAAE;QACtB,KAAK,GAAG,IAAI,OAAO,EAAe,CAAA;IACpC,CAAC,CAAC,CAAA;IACF,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACxB,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAC/B,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,MAAM,CAAA;QACvC,MAAM,QAAQ,GAAG,OAAO,EAAE,CAAA;QAC1B,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;QAC1B,OAAO,QAAQ,CAAA;IACjB,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -34,5 +34,17 @@ export declare function silent(pattern: string | RegExp): SilentExclusion;
|
|
|
34
34
|
* Check whether a value is a SilentExclusion.
|
|
35
35
|
*/
|
|
36
36
|
export declare function isSilent(value: unknown): value is SilentExclusion;
|
|
37
|
+
/**
|
|
38
|
+
* Record `patterns` into a builder's exclusion state, tracking which are silent.
|
|
39
|
+
*
|
|
40
|
+
* A free function over the two collections rather than a method, because the two
|
|
41
|
+
* builders that need it sit in incompatible class hierarchies — `eess-ts` has
|
|
42
|
+
* `RuleDeclaration -> TerminalBuilder -> RuleBuilder` where the kernel has two
|
|
43
|
+
* levels — so inheritance cannot share it. It mutates only what it is handed,
|
|
44
|
+
* so no private state crosses a package boundary.
|
|
45
|
+
*
|
|
46
|
+
* The two copies were byte-identical (`no-copy-paste` reported 100%).
|
|
47
|
+
*/
|
|
48
|
+
export declare function recordExclusions(patterns: readonly (string | RegExp | SilentExclusion)[], exclusions: (string | RegExp)[], silentIndices: Set<number>): void;
|
|
37
49
|
export {};
|
|
38
50
|
//# sourceMappingURL=silent-exclusion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"silent-exclusion.d.ts","sourceRoot":"","sources":["../src/silent-exclusion.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,QAAA,MAAM,MAAM,EAAE,OAAO,MAAmC,CAAA;AAExD;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;IACjC,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,CAAA;CACxB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,eAAe,CAEhE;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAEjE"}
|
|
1
|
+
{"version":3,"file":"silent-exclusion.d.ts","sourceRoot":"","sources":["../src/silent-exclusion.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,QAAA,MAAM,MAAM,EAAE,OAAO,MAAmC,CAAA;AAExD;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;IACjC,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,CAAA;CACxB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,eAAe,CAEhE;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAEjE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,eAAe,CAAC,EAAE,EACxD,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAC/B,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,GACzB,IAAI,CASN"}
|
package/dist/silent-exclusion.js
CHANGED
|
@@ -27,4 +27,26 @@ export function silent(pattern) {
|
|
|
27
27
|
export function isSilent(value) {
|
|
28
28
|
return typeof value === 'object' && value !== null && SILENT in value;
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Record `patterns` into a builder's exclusion state, tracking which are silent.
|
|
32
|
+
*
|
|
33
|
+
* A free function over the two collections rather than a method, because the two
|
|
34
|
+
* builders that need it sit in incompatible class hierarchies — `eess-ts` has
|
|
35
|
+
* `RuleDeclaration -> TerminalBuilder -> RuleBuilder` where the kernel has two
|
|
36
|
+
* levels — so inheritance cannot share it. It mutates only what it is handed,
|
|
37
|
+
* so no private state crosses a package boundary.
|
|
38
|
+
*
|
|
39
|
+
* The two copies were byte-identical (`no-copy-paste` reported 100%).
|
|
40
|
+
*/
|
|
41
|
+
export function recordExclusions(patterns, exclusions, silentIndices) {
|
|
42
|
+
for (const p of patterns) {
|
|
43
|
+
if (isSilent(p)) {
|
|
44
|
+
exclusions.push(p.pattern);
|
|
45
|
+
silentIndices.add(exclusions.length - 1);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
exclusions.push(p);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
30
52
|
//# sourceMappingURL=silent-exclusion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"silent-exclusion.js","sourceRoot":"","sources":["../src/silent-exclusion.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,GAAkB,MAAM,CAAC,kBAAkB,CAAC,CAAA;AAcxD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,MAAM,CAAC,OAAwB;IAC7C,OAAO,EAAE,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAA;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK,CAAA;AACvE,CAAC"}
|
|
1
|
+
{"version":3,"file":"silent-exclusion.js","sourceRoot":"","sources":["../src/silent-exclusion.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,GAAkB,MAAM,CAAC,kBAAkB,CAAC,CAAA;AAcxD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,MAAM,CAAC,OAAwB;IAC7C,OAAO,EAAE,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAA;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK,CAAA;AACvE,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAAwD,EACxD,UAA+B,EAC/B,aAA0B;IAE1B,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;YAChB,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;YAC1B,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QAC1C,CAAC;aAAM,CAAC;YACN,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACpB,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ArchViolation } from './violation.js';
|
|
2
|
+
import { type CollectResult } from './collect-result.js';
|
|
2
3
|
import type { CheckOptions } from './check-options.js';
|
|
3
4
|
import type { RuleMetadata } from './rule-metadata.js';
|
|
4
5
|
import type { RuleDescription } from './rule-description.js';
|
|
@@ -21,20 +22,7 @@ import type { SilentExclusion } from './silent-exclusion.js';
|
|
|
21
22
|
* family has no separate source/selection stages) or the zero came from
|
|
22
23
|
* narrowing, not upstream emptiness.
|
|
23
24
|
*/
|
|
24
|
-
export
|
|
25
|
-
readonly violations: ArchViolation[];
|
|
26
|
-
readonly examined: number;
|
|
27
|
-
readonly sourceEmpty?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* A specific dead-glob explanation for a zero-examined rule, pre-formatted
|
|
30
|
-
* by the dialect that computed it (`RuleBuilder.deadGlobDiagnosis()`) —
|
|
31
|
-
* the kernel never touches picomatch or a project type to build this
|
|
32
|
-
* itself. `undefined` means no diagnosis is available (no glob declared,
|
|
33
|
-
* or the declared glob isn't actually dead), which falls through to the
|
|
34
|
-
* generic zero-examined finding the same as before this field existed.
|
|
35
|
-
*/
|
|
36
|
-
readonly deadGlob?: string;
|
|
37
|
-
}
|
|
25
|
+
export type { CollectResult } from './collect-result.js';
|
|
38
26
|
/**
|
|
39
27
|
* Abstract base class for builders that share the terminal method pattern
|
|
40
28
|
* (because, rule, excluding, check, warn, severity) but have different
|
|
@@ -106,11 +94,25 @@ export declare abstract class TerminalBuilder {
|
|
|
106
94
|
describeRule(): RuleDescription;
|
|
107
95
|
/** This rule's own account of itself, for `vacuity-findings.ts`. */
|
|
108
96
|
private facts;
|
|
97
|
+
/**
|
|
98
|
+
* What every terminal method hands the filter pipeline.
|
|
99
|
+
*
|
|
100
|
+
* The same four fields were written out at each of `violations`, `check` and
|
|
101
|
+
* `warn` — `no-copy-paste` reported the three at 100% with `applyFilters ->
|
|
102
|
+
* executeCheck` as the only varying axis. `eess-ts`'s `TerminalBuilder`
|
|
103
|
+
* already had exactly this method; the kernel never adopted it.
|
|
104
|
+
*
|
|
105
|
+
* Not just tidier: three terminal methods that build the filter context
|
|
106
|
+
* separately can drift, and a field present on `.check()` but missing on
|
|
107
|
+
* `.violations()` means a rule fails in CI and passes when a preset
|
|
108
|
+
* aggregates it — the same finding, two answers.
|
|
109
|
+
*/
|
|
110
|
+
private filterContext;
|
|
109
111
|
/**
|
|
110
112
|
* Execute the rule and return violations after exclusion filtering.
|
|
111
113
|
* Does not throw — use for programmatic access (presets, aggregation).
|
|
112
114
|
*/
|
|
113
|
-
violations():
|
|
115
|
+
violations(): CollectResult;
|
|
114
116
|
/**
|
|
115
117
|
* Execute the rule and throw `ArchRuleError` if any violations are found.
|
|
116
118
|
* This is the primary terminal method — use in test assertions.
|
|
@@ -166,6 +168,18 @@ export declare abstract class TerminalBuilder {
|
|
|
166
168
|
* exist): the rule's own violations stand as computed.
|
|
167
169
|
*/
|
|
168
170
|
private evidencedViolations;
|
|
171
|
+
/**
|
|
172
|
+
* Which finding a zero-examined rule earns, or `undefined` when it earned none
|
|
173
|
+
* because it declared the emptiness.
|
|
174
|
+
*
|
|
175
|
+
* Extracted from `evidencedViolations` under `check:arch`'s complexity rule.
|
|
176
|
+
* The precedence is the whole content and is unchanged: an empty source
|
|
177
|
+
* outranks every declaration (ADR-010 §3), an explicit declaration is
|
|
178
|
+
* satisfied, `.expectNonEmpty()` is unmet, a cardinality condition is
|
|
179
|
+
* satisfied by emptiness, and a nameable dead glob outranks the generic
|
|
180
|
+
* message because it is strictly more actionable.
|
|
181
|
+
*/
|
|
182
|
+
private zeroExaminedFinding;
|
|
169
183
|
/**
|
|
170
184
|
* Execute the rule with the given severity.
|
|
171
185
|
* `.severity('error')` is equivalent to `.check()`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal-builder.d.ts","sourceRoot":"","sources":["../src/terminal-builder.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"terminal-builder.d.ts","sourceRoot":"","sources":["../src/terminal-builder.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,qBAAqB,CAAA;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM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