@nielspeter/eess-crossvalidate 0.2.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 +92 -4
- package/dist/files.d.ts +1 -0
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +3 -27
- package/dist/files.js.map +1 -1
- package/dist/gherkin-ts.d.ts +68 -9
- package/dist/gherkin-ts.d.ts.map +1 -1
- package/dist/gherkin-ts.js +99 -40
- package/dist/gherkin-ts.js.map +1 -1
- package/dist/md-gherkin.d.ts +6 -2
- package/dist/md-gherkin.d.ts.map +1 -1
- package/dist/md-gherkin.js +0 -0
- package/dist/md-gherkin.js.map +1 -1
- package/dist/md-mermaid-er.d.ts +6 -2
- package/dist/md-mermaid-er.d.ts.map +1 -1
- package/dist/md-mermaid-er.js +14 -16
- package/dist/md-mermaid-er.js.map +1 -1
- package/dist/md-mermaid.d.ts +42 -5
- package/dist/md-mermaid.d.ts.map +1 -1
- package/dist/md-mermaid.js +148 -17
- package/dist/md-mermaid.js.map +1 -1
- package/dist/md-ts.d.ts +2 -0
- package/dist/md-ts.d.ts.map +1 -1
- package/dist/md-ts.js +2 -0
- package/dist/md-ts.js.map +1 -1
- package/dist/mermaid-ts.d.ts +2 -0
- package/dist/mermaid-ts.d.ts.map +1 -1
- package/dist/mermaid-ts.js +8 -9
- package/dist/mermaid-ts.js.map +1 -1
- package/dist/shared.d.ts +61 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +63 -0
- package/dist/shared.js.map +1 -0
- package/package.json +7 -6
package/dist/md-mermaid-er.js
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import picomatch from 'picomatch';
|
|
2
|
-
import { finishPreset } from '@nielspeter/eess';
|
|
2
|
+
import { finishPreset, collectResult, } from '@nielspeter/eess';
|
|
3
|
+
import { violationsFor } from './shared.js';
|
|
3
4
|
import { parseErDiagram, collectEntities } from '@nielspeter/eess-mermaid';
|
|
5
|
+
// Kernel re-exports (plan 0089 — standalone sufficiency): see mermaid-ts.ts.
|
|
6
|
+
export { finishPreset, collectResult } from '@nielspeter/eess';
|
|
4
7
|
const RULE = 'entity property tables and their erDiagram should agree';
|
|
5
8
|
const ER_HEADER = /^\s*erDiagram\b/;
|
|
6
|
-
const v = (
|
|
7
|
-
rule: RULE,
|
|
8
|
-
ruleId: 'crossval/table-er-agree',
|
|
9
|
-
element: doc.relPath,
|
|
10
|
-
file: doc.file,
|
|
11
|
-
line,
|
|
12
|
-
message,
|
|
13
|
-
because,
|
|
14
|
-
});
|
|
9
|
+
const v = violationsFor(RULE, 'crossval/table-er-agree', ({ doc, line }) => ({ element: doc.relPath, file: doc.file, line }));
|
|
15
10
|
function erEntitiesOf(doc) {
|
|
16
11
|
return doc.codeBlocks
|
|
17
12
|
.filter((b) => (b.lang === 'mermaid' || b.lang === null) && ER_HEADER.test(b.value))
|
|
@@ -40,6 +35,8 @@ function erEntitiesOf(doc) {
|
|
|
40
35
|
export function tableErAgree(corpus, options) {
|
|
41
36
|
const inDocs = picomatch(options.docs ?? '**');
|
|
42
37
|
const violations = [];
|
|
38
|
+
// ER blocks compared, not documents walked.
|
|
39
|
+
let examined = 0;
|
|
43
40
|
for (const doc of corpus.documents()) {
|
|
44
41
|
if (!inDocs(doc.relPath))
|
|
45
42
|
continue;
|
|
@@ -52,8 +49,9 @@ export function tableErAgree(corpus, options) {
|
|
|
52
49
|
// A block that is not standard Mermaid ER syntax is itself drift — flag
|
|
53
50
|
// it (never crash, never silently skip) and compare what did parse.
|
|
54
51
|
for (const b of blocks) {
|
|
52
|
+
examined++;
|
|
55
53
|
if (b.parseError !== undefined) {
|
|
56
|
-
violations.push(v(doc, b.line, `erDiagram does not parse as standard Mermaid ER syntax: ${b.parseError}`, 'a diagram the standard grammar rejects cannot be validated — fix the syntax'));
|
|
54
|
+
violations.push(v({ doc, line: b.line }, `erDiagram does not parse as standard Mermaid ER syntax: ${b.parseError}`, 'a diagram the standard grammar rejects cannot be validated — fix the syntax'));
|
|
57
55
|
}
|
|
58
56
|
}
|
|
59
57
|
if (blocks.every((b) => b.parseError !== undefined))
|
|
@@ -61,13 +59,13 @@ export function tableErAgree(corpus, options) {
|
|
|
61
59
|
const entity = blocks.flatMap((b) => b.entities).find((e) => e.name === entityName);
|
|
62
60
|
const diagramLine = blocks[0]?.line ?? 1;
|
|
63
61
|
if (entity === undefined) {
|
|
64
|
-
violations.push(v(doc, diagramLine, `erDiagram does not declare entity '${entityName}'`, 'the diagram and the document must describe the same entity'));
|
|
62
|
+
violations.push(v({ doc, line: diagramLine }, `erDiagram does not declare entity '${entityName}'`, 'the diagram and the document must describe the same entity'));
|
|
65
63
|
continue;
|
|
66
64
|
}
|
|
67
65
|
const table = doc.tables.find((t) => t.sectionPath.some((h) => options.table.section.test(h)) &&
|
|
68
66
|
t.header.some((h) => options.table.name.test(h)));
|
|
69
67
|
if (table === undefined) {
|
|
70
|
-
violations.push(v(doc, diagramLine, `no property table matching section ${String(options.table.section)} to compare the erDiagram against`, 'attributes ⊆ properties is only checkable when the table exists'));
|
|
68
|
+
violations.push(v({ doc, line: diagramLine }, `no property table matching section ${String(options.table.section)} to compare the erDiagram against`, 'attributes ⊆ properties is only checkable when the table exists'));
|
|
71
69
|
continue;
|
|
72
70
|
}
|
|
73
71
|
const nameIdx = table.header.findIndex((h) => options.table.name.test(h));
|
|
@@ -87,15 +85,15 @@ export function tableErAgree(corpus, options) {
|
|
|
87
85
|
for (const attr of entity.attributes) {
|
|
88
86
|
const tableType = typeByName.get(attr.name);
|
|
89
87
|
if (tableType === undefined) {
|
|
90
|
-
violations.push(v(doc, diagramLine, `erDiagram attribute '${attr.name}' of '${entityName}' is not a row of the property table`, 'a diagram attribute the table does not carry is drift between two views of one entity'));
|
|
88
|
+
violations.push(v({ doc, line: diagramLine }, `erDiagram attribute '${attr.name}' of '${entityName}' is not a row of the property table`, 'a diagram attribute the table does not carry is drift between two views of one entity'));
|
|
91
89
|
continue;
|
|
92
90
|
}
|
|
93
91
|
if (typeIdx >= 0 && tableType.toLowerCase() !== attr.type.toLowerCase()) {
|
|
94
|
-
violations.push(v(doc, diagramLine, `type of '${attr.name}' disagrees: table says '${tableType}', erDiagram says '${attr.type}'`, 'the two representations must state the same type'));
|
|
92
|
+
violations.push(v({ doc, line: diagramLine }, `type of '${attr.name}' disagrees: table says '${tableType}', erDiagram says '${attr.type}'`, 'the two representations must state the same type'));
|
|
95
93
|
}
|
|
96
94
|
}
|
|
97
95
|
}
|
|
98
|
-
return finishPreset(violations, options);
|
|
96
|
+
return finishPreset(collectResult(violations, { examined }), options);
|
|
99
97
|
}
|
|
100
98
|
/** Count compared docs/entities/attributes for a caller's non-vacuity summary. */
|
|
101
99
|
export function tableErStats(corpus, options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"md-mermaid-er.js","sourceRoot":"","sources":["../src/md-mermaid-er.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"md-mermaid-er.js","sourceRoot":"","sources":["../src/md-mermaid-er.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAA;AAEjC,OAAO,EACL,YAAY,EAGZ,aAAa,GACd,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAqB,MAAM,0BAA0B,CAAA;AAE7F,6EAA6E;AAC7E,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AA2B9D,MAAM,IAAI,GAAG,yDAAyD,CAAA;AACtE,MAAM,SAAS,GAAG,iBAAiB,CAAA;AAEnC,MAAM,CAAC,GAAG,aAAa,CACrB,IAAI,EACJ,yBAAyB,EACzB,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,O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AO,CAAC,IAAI,IAAI,IAAI,CAAC,CAAA;IAC9C,IAAI,IAAI,GAAG,CAAC,CAAA;IACZ,IAAI,QAAQ,GAAG,CAAC,CAAA;IAChB,IAAI,UAAU,GAAG,CAAC,CAAA;IAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC;QACrC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;YAAE,SAAQ;QAClC,IAAI,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,SAAQ;QAC/C,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,CAAA;QAChC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,SAAQ;QACjC,IAAI,EAAE,CAAA;QACN,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;YACvB,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAA;YAC7B,UAAU,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;QACvE,CAAC;IACH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAA;AACvC,CAAC"}
|
package/dist/md-mermaid.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Direction, type PresetReportOptions, type CollectResult } from '@nielspeter/eess';
|
|
2
2
|
import type { Corpus } from '@nielspeter/eess-md';
|
|
3
3
|
import { type ArchProject } from '@nielspeter/eess-ts';
|
|
4
|
+
export { finishPreset, collectResult } from '@nielspeter/eess';
|
|
5
|
+
export type { CollectResult } from '@nielspeter/eess';
|
|
6
|
+
export { correspondence } from '@nielspeter/eess';
|
|
7
|
+
export type { ArchViolation, Direction, PresetReportOptions } from '@nielspeter/eess';
|
|
4
8
|
export interface EmbeddedDiagramsMatchCodeOptions extends PresetReportOptions {
|
|
5
9
|
/** Glob (matched against a class's directory) restricting which TS classes participate. */
|
|
6
10
|
readonly scope?: string;
|
|
@@ -12,10 +16,43 @@ export interface EmbeddedDiagramsMatchCodeOptions extends PresetReportOptions {
|
|
|
12
16
|
readonly completeness?: Direction;
|
|
13
17
|
}
|
|
14
18
|
/**
|
|
15
|
-
* Cross-validate Mermaid diagrams embedded as fenced ```mermaid blocks
|
|
16
|
-
* markdown corpus against TypeScript code
|
|
17
|
-
* exactly like a standalone `.mmd` file, with violations pointing at the
|
|
19
|
+
* Cross-validate Mermaid **class diagrams** embedded as fenced ```mermaid blocks
|
|
20
|
+
* in the markdown corpus against TypeScript code, with violations pointing at the
|
|
18
21
|
* markdown file and the fence line. Composed from the kernel `correspondence()`.
|
|
22
|
+
*
|
|
23
|
+
* **Scope.** Only class diagrams are compared. A fence declaring another kind
|
|
24
|
+
* (`sequenceDiagram`, `flowchart`, `gantt`, …) is skipped as a different
|
|
25
|
+
* artifact — see {@link embeddedDiagramStats}'s `skipped` for how many. A fence
|
|
26
|
+
* whose kind is unrecognised is still parsed, so an unknown diagram costs a loud
|
|
27
|
+
* finding rather than silent coverage loss.
|
|
28
|
+
*
|
|
29
|
+
* **This preset does not fail on an empty selection.** A corpus with no class
|
|
30
|
+
* diagrams returns no violations. Gate on {@link embeddedDiagramStats} if a
|
|
31
|
+
* non-empty run is what you mean to assert.
|
|
19
32
|
*/
|
|
20
|
-
export declare function embeddedDiagramsMatchCode(corpus: Corpus, project: ArchProject, options?: EmbeddedDiagramsMatchCodeOptions):
|
|
33
|
+
export declare function embeddedDiagramsMatchCode(corpus: Corpus, project: ArchProject, options?: EmbeddedDiagramsMatchCodeOptions): CollectResult;
|
|
34
|
+
/** What a run examined — a caller's non-vacuity evidence (ADR-010). */
|
|
35
|
+
export interface EmbeddedDiagramStats {
|
|
36
|
+
/** Documents holding at least one fence this binding selects. */
|
|
37
|
+
readonly documents: number;
|
|
38
|
+
/**
|
|
39
|
+
* Fences selected for comparison. A fence that turns out not to parse is
|
|
40
|
+
* selected and then reported, not compared — so this is the size of the
|
|
41
|
+
* attempted set, not of the succeeded one.
|
|
42
|
+
*/
|
|
43
|
+
readonly diagrams: number;
|
|
44
|
+
/**
|
|
45
|
+
* Mermaid fences skipped as another diagram kind. A selector that silently
|
|
46
|
+
* drops units is the failure this binding already shipped once, so the count
|
|
47
|
+
* is reported rather than left implicit (bug 0209).
|
|
48
|
+
*/
|
|
49
|
+
readonly skipped: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Count what {@link embeddedDiagramsMatchCode} would compare, so a caller can
|
|
53
|
+
* tell "no drift" from "nothing looked at". A green run over zero diagrams is
|
|
54
|
+
* not evidence, and this binding is otherwise unable to say which it produced
|
|
55
|
+
* (bug 0209). Mirrors md-mermaid-er's stats export.
|
|
56
|
+
*/
|
|
57
|
+
export declare function embeddedDiagramStats(corpus: Corpus): EmbeddedDiagramStats;
|
|
21
58
|
//# sourceMappingURL=md-mermaid.d.ts.map
|
package/dist/md-mermaid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"md-mermaid.d.ts","sourceRoot":"","sources":["../src/md-mermaid.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,
|
|
1
|
+
{"version":3,"file":"md-mermaid.d.ts","sourceRoot":"","sources":["../src/md-mermaid.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,mBAAmB,EAExB,KAAK,aAAa,EACnB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,qBAAqB,CAAA;AAE7D,OAAO,EAAwB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAI5E,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAG9D,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAuDrF,MAAM,WAAW,gCAAiC,SAAQ,mBAAmB;IAC3E,2FAA2F;IAC3F,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,CAAA;CAClC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,gCAAqC,GAC7C,aAAa,CA6Df;AA2BD,uEAAuE;AACvE,MAAM,WAAW,oBAAoB;IACnC,iEAAiE;IACjE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CAazE"}
|
package/dist/md-mermaid.js
CHANGED
|
@@ -1,32 +1,121 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { finishPreset, collectResult, } from '@nielspeter/eess';
|
|
2
|
+
import { correspondence } from '@nielspeter/eess';
|
|
2
3
|
import { diagram, classes as mmdClasses } from '@nielspeter/eess-mermaid';
|
|
3
4
|
import { classes as tsClasses } from '@nielspeter/eess-ts';
|
|
5
|
+
import { identifyTsClass } from './shared.js';
|
|
6
|
+
// Kernel re-exports (plan 0089 — standalone sufficiency): see mermaid-ts.ts.
|
|
7
|
+
export { finishPreset, collectResult } from '@nielspeter/eess';
|
|
8
|
+
export { correspondence } from '@nielspeter/eess';
|
|
9
|
+
// A fence's language tag says it is Mermaid; it does not say which DIAGRAM it
|
|
10
|
+
// is, and `diagram()` only ever parses a class diagram. Selecting on the tag
|
|
11
|
+
// alone fed sequence/flow/state/gantt fences to the class-diagram parser, which
|
|
12
|
+
// threw out of the preset and abandoned every diagram in the corpus (bug 0209).
|
|
13
|
+
//
|
|
14
|
+
// So we select on content — but by EXCLUDING the diagram kinds we know are
|
|
15
|
+
// something else, never by requiring the `classDiagram` keyword. An allowlist
|
|
16
|
+
// is fail-open: it drops anything it fails to recognise, silently, and review
|
|
17
|
+
// measured exactly that (a `%%{init}%%` theme directive ahead of the keyword
|
|
18
|
+
// parses fine and was skipped). A denylist is fail-closed: an unrecognised
|
|
19
|
+
// header reaches `diagram()`, which either parses it or produces an attributed
|
|
20
|
+
// finding. A future Mermaid diagram kind therefore costs a false positive that
|
|
21
|
+
// is loud, not coverage that vanishes.
|
|
22
|
+
// Kinds we know eess-mermaid cannot parse but which ARE legal Mermaid. Used only
|
|
23
|
+
// to phrase the finding honestly — they still reach the parser (fail-closed), and
|
|
24
|
+
// blaming the author's syntax for a grammar gap is the wrong attribution.
|
|
25
|
+
const KNOWN_UNMODELLED = /^(?:classDiagram-v2)\b/;
|
|
26
|
+
const FOREIGN_HEADER = /^(?:sequenceDiagram|flowchart|graph|stateDiagram(?:-v2)?|erDiagram|gantt|journey|pie|gitGraph|mindmap|timeline|quadrantChart|requirementDiagram|sankey(?:-beta)?|xychart(?:-beta)?|block(?:-beta)?|packet(?:-beta)?|kanban|architecture(?:-beta)?|radar(?:-beta)?|treemap(?:-beta)?|zenuml|info|C4(?:Context|Container|Component|Dynamic|Deployment))\b/;
|
|
27
|
+
// Mermaid's grammar treats `%%…` lines as hidden terminals and permits a
|
|
28
|
+
// `---` frontmatter block, so the diagram keyword is not necessarily the first
|
|
29
|
+
// thing in the fence. Find the first line that actually declares the kind.
|
|
30
|
+
function declaredKind(body) {
|
|
31
|
+
const lines = body.split(/\r?\n/);
|
|
32
|
+
let i = 0;
|
|
33
|
+
if (lines[0]?.trim() === '---') {
|
|
34
|
+
i = 1;
|
|
35
|
+
while (i < lines.length && lines[i]?.trim() !== '---')
|
|
36
|
+
i += 1;
|
|
37
|
+
i += 1;
|
|
38
|
+
}
|
|
39
|
+
let inDirective = false;
|
|
40
|
+
for (; i < lines.length; i += 1) {
|
|
41
|
+
const line = lines[i]?.trim() ?? '';
|
|
42
|
+
if (line === '')
|
|
43
|
+
continue;
|
|
44
|
+
// `%%{ … }%%` may span lines. Track it, or the continuation line gets read
|
|
45
|
+
// as the declared kind — measured: a multi-line init block ahead of a
|
|
46
|
+
// sequenceDiagram made it selected, and `skipped` reported 0 (review).
|
|
47
|
+
if (inDirective) {
|
|
48
|
+
if (line.endsWith('}%%'))
|
|
49
|
+
inDirective = false;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (line.startsWith('%%{') && !line.endsWith('}%%')) {
|
|
53
|
+
inDirective = true;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (line.startsWith('%%'))
|
|
57
|
+
continue;
|
|
58
|
+
return line;
|
|
59
|
+
}
|
|
60
|
+
return '';
|
|
61
|
+
}
|
|
4
62
|
/**
|
|
5
|
-
* Cross-validate Mermaid diagrams embedded as fenced ```mermaid blocks
|
|
6
|
-
* markdown corpus against TypeScript code
|
|
7
|
-
* exactly like a standalone `.mmd` file, with violations pointing at the
|
|
63
|
+
* Cross-validate Mermaid **class diagrams** embedded as fenced ```mermaid blocks
|
|
64
|
+
* in the markdown corpus against TypeScript code, with violations pointing at the
|
|
8
65
|
* markdown file and the fence line. Composed from the kernel `correspondence()`.
|
|
66
|
+
*
|
|
67
|
+
* **Scope.** Only class diagrams are compared. A fence declaring another kind
|
|
68
|
+
* (`sequenceDiagram`, `flowchart`, `gantt`, …) is skipped as a different
|
|
69
|
+
* artifact — see {@link embeddedDiagramStats}'s `skipped` for how many. A fence
|
|
70
|
+
* whose kind is unrecognised is still parsed, so an unknown diagram costs a loud
|
|
71
|
+
* finding rather than silent coverage loss.
|
|
72
|
+
*
|
|
73
|
+
* **This preset does not fail on an empty selection.** A corpus with no class
|
|
74
|
+
* diagrams returns no violations. Gate on {@link embeddedDiagramStats} if a
|
|
75
|
+
* non-empty run is what you mean to assert.
|
|
9
76
|
*/
|
|
10
77
|
export function embeddedDiagramsMatchCode(corpus, project, options = {}) {
|
|
11
78
|
const scope = options.scope ?? '**/src/**';
|
|
12
79
|
const direction = options.completeness ?? 'left-to-right';
|
|
13
|
-
const right = tsClasses(project)
|
|
14
|
-
.that()
|
|
15
|
-
.resideInFolder(scope)
|
|
16
|
-
.select({
|
|
80
|
+
const right = tsClasses(project).that().resideInFolder(scope).select({
|
|
17
81
|
label: 'TS class',
|
|
18
|
-
identify:
|
|
19
|
-
name: c.getName() ?? '<anonymous>',
|
|
20
|
-
file: c.getSourceFile().getFilePath(),
|
|
21
|
-
line: c.getStartLineNumber(),
|
|
22
|
-
}),
|
|
82
|
+
identify: identifyTsClass,
|
|
23
83
|
});
|
|
24
84
|
const violations = [];
|
|
85
|
+
// Diagram BLOCKS compared, never documents scanned — counting one layer too
|
|
86
|
+
// high reads healthy on a corpus whose every diagram was skipped.
|
|
87
|
+
let examined = 0;
|
|
25
88
|
for (const doc of corpus.documents()) {
|
|
26
|
-
for (const block of doc
|
|
27
|
-
|
|
89
|
+
for (const block of classDiagramBlocks(doc)) {
|
|
90
|
+
examined++;
|
|
91
|
+
let d;
|
|
92
|
+
try {
|
|
93
|
+
d = diagram(block.value);
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
// A fence that DECLARES classDiagram and still will not parse is a real
|
|
97
|
+
// finding about this document — report it against the markdown file and
|
|
98
|
+
// fence line rather than throwing out of the preset (bug 0209).
|
|
99
|
+
violations.push({
|
|
100
|
+
rule: 'embedded diagrams should parse as Mermaid',
|
|
101
|
+
ruleId: 'crossval/embedded-diagram',
|
|
102
|
+
element: doc.relPath,
|
|
103
|
+
file: doc.file,
|
|
104
|
+
line: block.line,
|
|
105
|
+
message: `embedded ${kindOf(block.value)} does not parse as a Mermaid class diagram: ${detailOf(e)}` +
|
|
106
|
+
(KNOWN_UNMODELLED.test(kindOf(block.value))
|
|
107
|
+
? ' — this is legal Mermaid that eess-mermaid does not model yet, not a syntax error in your document'
|
|
108
|
+
: ''),
|
|
109
|
+
because: 'A diagram that cannot be parsed cannot be compared against code, so it silently stops constraining it.',
|
|
110
|
+
// Deliberately offers ONE remedy. The earlier text ended "or remove the
|
|
111
|
+
// fence if it is not a class diagram" — review measured that an agent
|
|
112
|
+
// taking that branch turns red into green over a document whose drift
|
|
113
|
+
// is still there. A remedy that remediates by deleting the evidence is
|
|
114
|
+
// not a remedy (ADR-009 rule 2).
|
|
115
|
+
suggestion: 'Fix the diagram syntax so it parses as a Mermaid class diagram. If this fence is a diagram kind eess-mermaid does not model, report it rather than deleting the fence.',
|
|
116
|
+
});
|
|
28
117
|
continue;
|
|
29
|
-
|
|
118
|
+
}
|
|
30
119
|
const left = mmdClasses(d).select({
|
|
31
120
|
label: `diagram class (in ${doc.relPath})`,
|
|
32
121
|
// point violations at the markdown file + fence line, not the parsed diagram
|
|
@@ -39,6 +128,48 @@ export function embeddedDiagramsMatchCode(corpus, project, options = {}) {
|
|
|
39
128
|
.violations());
|
|
40
129
|
}
|
|
41
130
|
}
|
|
42
|
-
return finishPreset(violations, options);
|
|
131
|
+
return finishPreset(collectResult(violations, { examined }), options);
|
|
132
|
+
}
|
|
133
|
+
/** The declared kind of a fence, for phrasing a finding. */
|
|
134
|
+
function kindOf(body) {
|
|
135
|
+
const kind = declaredKind(body).split(/[\s{]/)[0] ?? '';
|
|
136
|
+
return kind === '' ? 'diagram' : kind;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The informative line of a parse failure. `MermaidUnitParseError`'s message is
|
|
140
|
+
* a constant prefix followed by the real lexer/parser errors, so taking line 0
|
|
141
|
+
* yields `MermaidUnit parse failed:` and no diagnosis at all — measured. The ER
|
|
142
|
+
* sibling takes line 1 for the same reason.
|
|
143
|
+
*/
|
|
144
|
+
function detailOf(e) {
|
|
145
|
+
if (!(e instanceof Error))
|
|
146
|
+
return String(e);
|
|
147
|
+
const lines = e.message.split('\n');
|
|
148
|
+
return lines[1] ?? lines[0] ?? e.message;
|
|
149
|
+
}
|
|
150
|
+
/** The class-diagram fences of one document — the blocks this binding models. */
|
|
151
|
+
function classDiagramBlocks(doc) {
|
|
152
|
+
return doc.codeBlocks.filter((b) => b.lang === 'mermaid' && !FOREIGN_HEADER.test(declaredKind(b.value)));
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Count what {@link embeddedDiagramsMatchCode} would compare, so a caller can
|
|
156
|
+
* tell "no drift" from "nothing looked at". A green run over zero diagrams is
|
|
157
|
+
* not evidence, and this binding is otherwise unable to say which it produced
|
|
158
|
+
* (bug 0209). Mirrors md-mermaid-er's stats export.
|
|
159
|
+
*/
|
|
160
|
+
export function embeddedDiagramStats(corpus) {
|
|
161
|
+
let documents = 0;
|
|
162
|
+
let diagrams = 0;
|
|
163
|
+
let skipped = 0;
|
|
164
|
+
for (const doc of corpus.documents()) {
|
|
165
|
+
const mermaid = doc.codeBlocks.filter((b) => b.lang === 'mermaid');
|
|
166
|
+
const blocks = classDiagramBlocks(doc);
|
|
167
|
+
skipped += mermaid.length - blocks.length;
|
|
168
|
+
if (blocks.length === 0)
|
|
169
|
+
continue;
|
|
170
|
+
documents += 1;
|
|
171
|
+
diagrams += blocks.length;
|
|
172
|
+
}
|
|
173
|
+
return { documents, diagrams, skipped };
|
|
43
174
|
}
|
|
44
175
|
//# sourceMappingURL=md-mermaid.js.map
|
package/dist/md-mermaid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"md-mermaid.js","sourceRoot":"","sources":["../src/md-mermaid.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"md-mermaid.js","sourceRoot":"","sources":["../src/md-mermaid.ts"],"names":[],"mappings":"AAAA,O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BD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc;IACjD,IAAI,SAAS,GAAG,CAAC,CAAA;IACjB,IAAI,QAAQ,GAAG,CAAC,CAAA;IAChB,IAAI,OAAO,GAAG,CAAC,CAAA;IACf,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC;QACrC,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAA;QAClE,MAAM,MAAM,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAA;QACtC,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;QACzC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,SAAQ;QACjC,SAAS,IAAI,CAAC,CAAA;QACd,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAA;IAC3B,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAA;AACzC,CAAC"}
|
package/dist/md-ts.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Corpus } from '@nielspeter/eess-md';
|
|
2
2
|
import { type ArchProject } from '@nielspeter/eess-ts';
|
|
3
|
+
export { correspondence } from '@nielspeter/eess';
|
|
4
|
+
export type { Selection } from '@nielspeter/eess';
|
|
3
5
|
export interface AdrCitationsResolveOptions {
|
|
4
6
|
/** Glob selecting ADR files. Default `docs/adr/**`. */
|
|
5
7
|
readonly dir?: string;
|
package/dist/md-ts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"md-ts.d.ts","sourceRoot":"","sources":["../src/md-ts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"md-ts.d.ts","sourceRoot":"","sources":["../src/md-ts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAS,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAI7D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEjD,MAAM,WAAW,0BAA0B;IACzC,uDAAuD;IACvD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAClC,uIAAuI;IACvI,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAClC;AA6CD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,0BAA+B,GACvC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAYrC;AAqCD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,0BAA+B,GACvC,IAAI,CA8CN"}
|
package/dist/md-ts.js
CHANGED
|
@@ -2,6 +2,8 @@ import picomatch from 'picomatch';
|
|
|
2
2
|
import { correspondence } from '@nielspeter/eess';
|
|
3
3
|
import { calls } from '@nielspeter/eess-ts';
|
|
4
4
|
import { citedItTitles, itTitleOf } from './it-title.js';
|
|
5
|
+
// Kernel re-exports (plan 0089 — standalone sufficiency): see mermaid-ts.ts.
|
|
6
|
+
export { correspondence } from '@nielspeter/eess';
|
|
5
7
|
function matchName(value, name) {
|
|
6
8
|
return typeof name === 'string' ? value === name : name.test(value);
|
|
7
9
|
}
|
package/dist/md-ts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"md-ts.js","sourceRoot":"","sources":["../src/md-ts.ts"],"names":[],"mappings":"AAAA,OAAO,S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,CAAC;SACD,KAAK,EAAE,CAAA;AACZ,CAAC"}
|
package/dist/mermaid-ts.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type Direction } from '@nielspeter/eess';
|
|
2
2
|
import { type ArchProject as MermaidDiagram } from '@nielspeter/eess-mermaid';
|
|
3
3
|
import { type ArchProject } from '@nielspeter/eess-ts';
|
|
4
|
+
export { correspondence } from '@nielspeter/eess';
|
|
5
|
+
export type { Direction } from '@nielspeter/eess';
|
|
4
6
|
export interface DiagramMatchesCodeOptions {
|
|
5
7
|
/** Glob (matched against a class's directory) restricting which TS classes
|
|
6
8
|
* participate. Defaults to a `src` folder anywhere in the tree. */
|
package/dist/mermaid-ts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mermaid-ts.d.ts","sourceRoot":"","sources":["../src/mermaid-ts.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"mermaid-ts.d.ts","sourceRoot":"","sources":["../src/mermaid-ts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEjD,OAAO,EAAyB,KAAK,WAAW,IAAI,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACpG,OAAO,EAAwB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAO5E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEjD,MAAM,WAAW,yBAAyB;IACxC;uEACmE;IACnE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,CAAA;CAClC;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,yBAA8B,GACtC,IAAI,CAqBN"}
|
package/dist/mermaid-ts.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { correspondence } from '@nielspeter/eess';
|
|
2
2
|
import { classes as mmdClasses } from '@nielspeter/eess-mermaid';
|
|
3
3
|
import { classes as tsClasses } from '@nielspeter/eess-ts';
|
|
4
|
+
import { identifyTsClass } from './shared.js';
|
|
5
|
+
// Kernel re-exports (plan 0089 — standalone sufficiency): crossvalidate is
|
|
6
|
+
// the family's binding tool, so unlike the other dialects it MUST re-export
|
|
7
|
+
// what its own body imports — a caller composing a custom cross-dialect
|
|
8
|
+
// binding needs these same primitives.
|
|
9
|
+
export { correspondence } from '@nielspeter/eess';
|
|
4
10
|
/**
|
|
5
11
|
* Cross-validate a Mermaid class diagram against TypeScript code: every class in
|
|
6
12
|
* the diagram has a matching TS class and vice versa. Built on the kernel
|
|
@@ -17,16 +23,9 @@ export function diagramMatchesCode(diagram, project, options = {}) {
|
|
|
17
23
|
label: 'diagram class',
|
|
18
24
|
identify: (c) => ({ name: c.name }),
|
|
19
25
|
});
|
|
20
|
-
const right = tsClasses(project)
|
|
21
|
-
.that()
|
|
22
|
-
.resideInFolder(scope)
|
|
23
|
-
.select({
|
|
26
|
+
const right = tsClasses(project).that().resideInFolder(scope).select({
|
|
24
27
|
label: 'TS class',
|
|
25
|
-
identify:
|
|
26
|
-
name: c.getName() ?? '<anonymous>',
|
|
27
|
-
file: c.getSourceFile().getFilePath(),
|
|
28
|
-
line: c.getStartLineNumber(),
|
|
29
|
-
}),
|
|
28
|
+
identify: identifyTsClass,
|
|
30
29
|
});
|
|
31
30
|
correspondence({ left, right })
|
|
32
31
|
.should()
|
package/dist/mermaid-ts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mermaid-ts.js","sourceRoot":"","sources":["../src/mermaid-ts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mermaid-ts.js","sourceRoot":"","sources":["../src/mermaid-ts.ts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+
import type { ClassDeclaration } from 'ts-morph';
|
|
2
|
+
import type { ArchViolation, ElementInfo } from '@nielspeter/eess';
|
|
3
|
+
import { type PathSuffixIndex } from '@nielspeter/eess/internal';
|
|
4
|
+
import type { FeatureSet } from '@nielspeter/eess-gherkin';
|
|
5
|
+
export type { ArchViolation, ElementInfo };
|
|
6
|
+
/**
|
|
7
|
+
* Conventions every binding in this package shares.
|
|
8
|
+
*
|
|
9
|
+
* Each of these was duplicated byte-for-byte across two bindings, which
|
|
10
|
+
* `no-copy-paste` reported at 100%. They are conventions rather than
|
|
11
|
+
* coincidences: how a TS class is named in a finding, and how a cited feature
|
|
12
|
+
* path is resolved, must be the same answer in every binding or two gates
|
|
13
|
+
* disagree about the same file.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* How a TS class appears in a correspondence finding.
|
|
17
|
+
*
|
|
18
|
+
* `<anonymous>` rather than omitting the name: a nameless class still occupies a
|
|
19
|
+
* position in the diagram comparison, and a finding that names nothing cannot be
|
|
20
|
+
* acted on.
|
|
21
|
+
*/
|
|
22
|
+
export declare function identifyTsClass(c: ClassDeclaration): ElementInfo;
|
|
23
|
+
/**
|
|
24
|
+
* A prepared index of the set's feature paths, for resolving citations.
|
|
25
|
+
*
|
|
26
|
+
* An exact `relPath` wins outright. Otherwise the citation is treated as a
|
|
27
|
+
* SUFFIX — `login.feature` matches `specs/auth/login.feature` — so a document
|
|
28
|
+
* can cite a feature without repeating the corpus root it already declared. An
|
|
29
|
+
* ambiguous citation comes back with every candidate, so the caller reports it
|
|
30
|
+
* as ambiguous instead of silently resolving to whichever file the walk reached
|
|
31
|
+
* first.
|
|
32
|
+
*
|
|
33
|
+
* **Bug 0257: the resolution itself is the kernel's now.** This used to be
|
|
34
|
+
* `resolveFeature(path, set)` with its own copy of the algorithm —
|
|
35
|
+
* `eess-md`'s `pointer-resolve.ts` had the same one, down to the exact-wins
|
|
36
|
+
* precedence and the "cite a longer suffix" remedy. What remains here is the
|
|
37
|
+
* binding: which paths go in. Built once per binding rather than rebuilt per
|
|
38
|
+
* citation, which the old two-argument shape forced.
|
|
39
|
+
*/
|
|
40
|
+
export declare function featurePaths(set: FeatureSet): PathSuffixIndex;
|
|
41
|
+
/**
|
|
42
|
+
* A binding's violation constructor: the rule and its id fixed once, the site
|
|
43
|
+
* turned into `element`/`file`/`line` by the binding's own `locate`.
|
|
44
|
+
*
|
|
45
|
+
* Four bindings had written this out by hand — `no-copy-paste` reported three
|
|
46
|
+
* of them at 100% (the fourth escaped only because it took `(doc, line)` as two
|
|
47
|
+
* arguments instead of one site).
|
|
48
|
+
*
|
|
49
|
+
* `locate` is a callback and not a field list because the sites genuinely
|
|
50
|
+
* differ: a test citation locates by `file:line`, a scenario by
|
|
51
|
+
* `relPath › title`, a document by `relPath`. What must NOT differ is that
|
|
52
|
+
* every finding carries all three — a cross-validation violation with no
|
|
53
|
+
* `file`, or with an `element` a reader cannot find in either artifact, names
|
|
54
|
+
* drift without saying where it is (ADR-009 rule 2).
|
|
55
|
+
*/
|
|
56
|
+
export declare function violationsFor<Site>(rule: string, ruleId: string, locate: (site: Site) => {
|
|
57
|
+
element: string;
|
|
58
|
+
file: string;
|
|
59
|
+
line: number;
|
|
60
|
+
}): (site: Site, message: string, because: string) => ArchViolation;
|
|
61
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAClE,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAA;AACjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAM1D,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,CAAA;AAE1C;;;;;;;;GAQG;AAEH;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,gBAAgB,GAAG,WAAW,CAMhE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,UAAU,GAAG,eAAe,CAE7D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAChC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACtE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,aAAa,CAEjE"}
|
package/dist/shared.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { pathSuffixIndex } from '@nielspeter/eess/internal';
|
|
2
|
+
/**
|
|
3
|
+
* Conventions every binding in this package shares.
|
|
4
|
+
*
|
|
5
|
+
* Each of these was duplicated byte-for-byte across two bindings, which
|
|
6
|
+
* `no-copy-paste` reported at 100%. They are conventions rather than
|
|
7
|
+
* coincidences: how a TS class is named in a finding, and how a cited feature
|
|
8
|
+
* path is resolved, must be the same answer in every binding or two gates
|
|
9
|
+
* disagree about the same file.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* How a TS class appears in a correspondence finding.
|
|
13
|
+
*
|
|
14
|
+
* `<anonymous>` rather than omitting the name: a nameless class still occupies a
|
|
15
|
+
* position in the diagram comparison, and a finding that names nothing cannot be
|
|
16
|
+
* acted on.
|
|
17
|
+
*/
|
|
18
|
+
export function identifyTsClass(c) {
|
|
19
|
+
return {
|
|
20
|
+
name: c.getName() ?? '<anonymous>',
|
|
21
|
+
file: c.getSourceFile().getFilePath(),
|
|
22
|
+
line: c.getStartLineNumber(),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A prepared index of the set's feature paths, for resolving citations.
|
|
27
|
+
*
|
|
28
|
+
* An exact `relPath` wins outright. Otherwise the citation is treated as a
|
|
29
|
+
* SUFFIX — `login.feature` matches `specs/auth/login.feature` — so a document
|
|
30
|
+
* can cite a feature without repeating the corpus root it already declared. An
|
|
31
|
+
* ambiguous citation comes back with every candidate, so the caller reports it
|
|
32
|
+
* as ambiguous instead of silently resolving to whichever file the walk reached
|
|
33
|
+
* first.
|
|
34
|
+
*
|
|
35
|
+
* **Bug 0257: the resolution itself is the kernel's now.** This used to be
|
|
36
|
+
* `resolveFeature(path, set)` with its own copy of the algorithm —
|
|
37
|
+
* `eess-md`'s `pointer-resolve.ts` had the same one, down to the exact-wins
|
|
38
|
+
* precedence and the "cite a longer suffix" remedy. What remains here is the
|
|
39
|
+
* binding: which paths go in. Built once per binding rather than rebuilt per
|
|
40
|
+
* citation, which the old two-argument shape forced.
|
|
41
|
+
*/
|
|
42
|
+
export function featurePaths(set) {
|
|
43
|
+
return pathSuffixIndex(set.features().map((f) => f.relPath));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A binding's violation constructor: the rule and its id fixed once, the site
|
|
47
|
+
* turned into `element`/`file`/`line` by the binding's own `locate`.
|
|
48
|
+
*
|
|
49
|
+
* Four bindings had written this out by hand — `no-copy-paste` reported three
|
|
50
|
+
* of them at 100% (the fourth escaped only because it took `(doc, line)` as two
|
|
51
|
+
* arguments instead of one site).
|
|
52
|
+
*
|
|
53
|
+
* `locate` is a callback and not a field list because the sites genuinely
|
|
54
|
+
* differ: a test citation locates by `file:line`, a scenario by
|
|
55
|
+
* `relPath › title`, a document by `relPath`. What must NOT differ is that
|
|
56
|
+
* every finding carries all three — a cross-validation violation with no
|
|
57
|
+
* `file`, or with an `element` a reader cannot find in either artifact, names
|
|
58
|
+
* drift without saying where it is (ADR-009 rule 2).
|
|
59
|
+
*/
|
|
60
|
+
export function violationsFor(rule, ruleId, locate) {
|
|
61
|
+
return (site, message, because) => ({ rule, ruleId, ...locate(site), message, because });
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAwB,MAAM,2BAA2B,CAAA;AASjF;;;;;;;;GAQG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,CAAmB;IACjD,OAAO;QACL,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,IAAI,aAAa;QAClC,IAAI,EAAE,CAAC,CAAC,aAAa,EAAE,CAAC,WAAW,EAAE;QACrC,IAAI,EAAE,CAAC,CAAC,kBAAkB,EAAE;KAC7B,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,YAAY,CAAC,GAAe;IAC1C,OAAO,eAAe,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAA;AAC9D,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAY,EACZ,MAAc,EACd,MAAuE;IAEvE,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAA;AAC1F,CAAC"}
|