@md-code/component-uniqueness 0.1.4 → 0.3.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/CHANGELOG.md +17 -0
- package/LICENSE +202 -0
- package/README.md +21 -3
- package/dist/config.d.ts +50 -0
- package/dist/config.js +402 -0
- package/dist/constants.d.ts +55 -0
- package/dist/constants.js +86 -0
- package/dist/decision-maker.d.ts +39 -0
- package/dist/decision-maker.js +119 -0
- package/dist/filter/child-element.d.ts +3 -0
- package/dist/filter/child-element.js +17 -0
- package/dist/filter/missing-component.d.ts +10 -0
- package/dist/filter/missing-component.js +96 -0
- package/dist/filter/no-structure.d.ts +3 -0
- package/dist/filter/no-structure.js +16 -0
- package/dist/filter/usages.d.ts +3 -0
- package/dist/filter/usages.js +14 -0
- package/dist/index.d.ts +105 -0
- package/dist/index.js +244 -0
- package/dist/lib-registry.d.ts +4 -0
- package/dist/lib-registry.js +376 -0
- package/dist/logger.d.ts +7 -0
- package/dist/logger.js +70 -0
- package/dist/main.d.ts +25 -0
- package/dist/main.js +666 -0
- package/dist/matcher/a11y.d.ts +19 -0
- package/dist/matcher/a11y.js +311 -0
- package/dist/matcher/behavior.d.ts +10 -0
- package/dist/matcher/behavior.js +32 -0
- package/dist/matcher/css-matching.d.ts +18 -0
- package/dist/matcher/css-matching.js +159 -0
- package/dist/matcher/framework/index.d.ts +2 -0
- package/dist/matcher/framework/index.js +37 -0
- package/dist/matcher/framework/react.d.ts +12 -0
- package/dist/matcher/framework/react.js +70 -0
- package/dist/matcher/index.d.ts +64 -0
- package/dist/matcher/index.js +38 -0
- package/dist/matcher/name.d.ts +15 -0
- package/dist/matcher/name.js +154 -0
- package/dist/matcher/structure.d.ts +22 -0
- package/dist/matcher/structure.js +329 -0
- package/dist/matcher/styles.d.ts +20 -0
- package/dist/matcher/styles.js +49 -0
- package/dist/normalize/candidate.d.ts +3 -0
- package/dist/normalize/candidate.js +21 -0
- package/dist/normalize/dom.d.ts +22 -0
- package/dist/normalize/dom.js +180 -0
- package/dist/normalize/external-html.d.ts +5 -0
- package/dist/normalize/external-html.js +40 -0
- package/dist/normalize/framework.d.ts +20 -0
- package/dist/normalize/framework.js +130 -0
- package/dist/normalize/resolver.d.ts +7 -0
- package/dist/normalize/resolver.js +28 -0
- package/dist/normalize/style-resolver.d.ts +7 -0
- package/dist/normalize/style-resolver.js +28 -0
- package/dist/normalize/style.d.ts +15 -0
- package/dist/normalize/style.js +174 -0
- package/dist/normalize/words.d.ts +3 -0
- package/dist/normalize/words.js +40 -0
- package/dist/package.json +88 -0
- package/dist/playgrounds/angular.d.ts +7 -0
- package/dist/playgrounds/angular.js +9 -0
- package/dist/playgrounds/framework-entrypoint.d.ts +10 -0
- package/dist/playgrounds/framework-entrypoint.js +102 -0
- package/dist/playgrounds/framework.d.ts +10 -0
- package/dist/playgrounds/framework.js +102 -0
- package/dist/playgrounds/react.d.ts +14 -0
- package/dist/playgrounds/react.js +1288 -0
- package/dist/playgrounds/scss.d.ts +6 -0
- package/dist/playgrounds/scss.js +9 -0
- package/dist/playgrounds/style-entrypoint.d.ts +13 -0
- package/dist/playgrounds/style-entrypoint.js +82 -0
- package/dist/playgrounds/style.d.ts +13 -0
- package/dist/playgrounds/style.js +82 -0
- package/dist/playgrounds/styled-components.d.ts +7 -0
- package/dist/playgrounds/styled-components.js +190 -0
- package/dist/playgrounds/tailwind.d.ts +15 -0
- package/dist/playgrounds/tailwind.js +256 -0
- package/dist/playgrounds/vue.d.ts +7 -0
- package/dist/playgrounds/vue.js +9 -0
- package/dist/report/asks.d.ts +27 -0
- package/dist/report/asks.js +28 -0
- package/dist/report/cli-report.d.ts +7 -0
- package/dist/report/cli-report.js +187 -0
- package/dist/report/codes/index.d.ts +37 -0
- package/dist/report/codes/index.js +31 -0
- package/dist/report/errorTypes/index.d.ts +92 -0
- package/dist/report/errorTypes/index.js +186 -0
- package/dist/report/evidence.d.ts +2 -0
- package/dist/report/evidence.js +8 -0
- package/dist/report/explain.d.ts +27 -0
- package/dist/report/explain.js +76 -0
- package/dist/report/index.d.ts +2 -0
- package/dist/report/index.js +24 -0
- package/dist/report/matchers/a11y/model.d.ts +20 -0
- package/dist/report/matchers/a11y/model.js +14 -0
- package/dist/report/matchers/a11y/text.d.ts +2 -0
- package/dist/report/matchers/a11y/text.js +22 -0
- package/dist/report/matchers/behavior/model.d.ts +20 -0
- package/dist/report/matchers/behavior/model.js +12 -0
- package/dist/report/matchers/behavior/text.d.ts +2 -0
- package/dist/report/matchers/behavior/text.js +22 -0
- package/dist/report/matchers/framework/model.d.ts +10 -0
- package/dist/report/matchers/framework/model.js +39 -0
- package/dist/report/matchers/framework/text.d.ts +2 -0
- package/dist/report/matchers/framework/text.js +26 -0
- package/dist/report/matchers/index.d.ts +5 -0
- package/dist/report/matchers/index.js +97 -0
- package/dist/report/matchers/name/model.d.ts +20 -0
- package/dist/report/matchers/name/model.js +30 -0
- package/dist/report/matchers/name/text.d.ts +2 -0
- package/dist/report/matchers/name/text.js +17 -0
- package/dist/report/matchers/set-model.d.ts +31 -0
- package/dist/report/matchers/set-model.js +42 -0
- package/dist/report/matchers/structure/model.d.ts +10 -0
- package/dist/report/matchers/structure/model.js +58 -0
- package/dist/report/matchers/structure/text.d.ts +2 -0
- package/dist/report/matchers/structure/text.js +40 -0
- package/dist/report/matchers/styles/model.d.ts +11 -0
- package/dist/report/matchers/styles/model.js +36 -0
- package/dist/report/matchers/styles/text.d.ts +2 -0
- package/dist/report/matchers/styles/text.js +40 -0
- package/dist/report/user-report/build/bundle.d.ts +3 -0
- package/dist/report/user-report/build/bundle.js +185 -0
- package/dist/report/user-report/build/bundle.prebuilt.js +955 -0
- package/dist/report/user-report/data/collect.d.ts +68 -0
- package/dist/report/user-report/data/collect.js +150 -0
- package/dist/report/user-report/data/folders.d.ts +3 -0
- package/dist/report/user-report/data/folders.js +73 -0
- package/dist/report/user-report/data/groups.d.ts +13 -0
- package/dist/report/user-report/data/groups.js +76 -0
- package/dist/report/user-report/data/links.d.ts +39 -0
- package/dist/report/user-report/data/links.js +222 -0
- package/dist/report/user-report/data/snapshot.d.ts +9 -0
- package/dist/report/user-report/data/snapshot.js +180 -0
- package/dist/report/user-report/data/source.d.ts +13 -0
- package/dist/report/user-report/data/source.js +58 -0
- package/dist/report/user-report/data/word.d.ts +3 -0
- package/dist/report/user-report/data/word.js +32 -0
- package/dist/report/user-report/html/shell.d.ts +2 -0
- package/dist/report/user-report/html/shell.js +27 -0
- package/dist/report/user-report/index.d.ts +7 -0
- package/dist/report/user-report/index.js +47 -0
- package/dist/report/vocabulary/evidence.d.ts +48 -0
- package/dist/report/vocabulary/evidence.js +66 -0
- package/dist/report/vocabulary/format.d.ts +4 -0
- package/dist/report/vocabulary/format.js +20 -0
- package/dist/report/vocabulary/labels.d.ts +134 -0
- package/dist/report/vocabulary/labels.js +87 -0
- package/dist/report/vocabulary/phrases.d.ts +20 -0
- package/dist/report/vocabulary/phrases.js +34 -0
- package/dist/self-catalog.d.ts +4 -0
- package/dist/self-catalog.js +179 -0
- package/dist/utils.d.ts +6 -0
- package/dist/utils.js +125 -0
- package/package.json +86 -71
- package/config.js +0 -372
- package/decision-maker.js +0 -109
- package/filter/drop-child-element.js +0 -14
- package/filter/drop-no-structure.js +0 -13
- package/filter/drop-usages.js +0 -13
- package/filter/missing-component.js +0 -100
- package/index.js +0 -184
- package/logger.js +0 -44
- package/main.js +0 -584
- package/matcher/a11y.js +0 -65
- package/matcher/behavior.js +0 -31
- package/matcher/framework/index.js +0 -15
- package/matcher/framework/react.js +0 -25
- package/matcher/index.js +0 -36
- package/matcher/name.js +0 -132
- package/matcher/structure.js +0 -242
- package/normalize/candidate.js +0 -22
- package/normalize/dom.js +0 -187
- package/normalize/framework.js +0 -110
- package/normalize/style-resolver.js +0 -24
- package/normalize/style.js +0 -175
- package/normalize/words.js +0 -40
- package/playgrounds/angular.js +0 -11
- package/playgrounds/framework-entrypoint.js +0 -90
- package/playgrounds/react.js +0 -998
- package/playgrounds/scss.js +0 -7
- package/playgrounds/style-entrypoint.js +0 -78
- package/playgrounds/styled-components.js +0 -138
- package/playgrounds/tailwind.js +0 -186
- package/playgrounds/vue.js +0 -11
- package/plugin.js +0 -3
- package/report.js +0 -162
- package/utils.js +0 -92
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.available = exports.resolveCss = exports.parseComponents = void 0;
|
|
4
|
+
const parseComponents = () => [];
|
|
5
|
+
exports.parseComponents = parseComponents;
|
|
6
|
+
const resolveCss = () => ({ css: "", unresolved: [] });
|
|
7
|
+
exports.resolveCss = resolveCss;
|
|
8
|
+
const available = () => false;
|
|
9
|
+
exports.available = available;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare const useCanonical: (left: any, right: any) => {
|
|
2
|
+
action: "use-canonical";
|
|
3
|
+
text: string;
|
|
4
|
+
target: {
|
|
5
|
+
path: any;
|
|
6
|
+
line: any;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
declare const extractComponent: (count: any) => {
|
|
10
|
+
action: "extract-component";
|
|
11
|
+
text: string;
|
|
12
|
+
target: any;
|
|
13
|
+
};
|
|
14
|
+
declare const replaceRawHtml: (tag: any, right: any) => {
|
|
15
|
+
action: "replace-raw-html";
|
|
16
|
+
text: string;
|
|
17
|
+
target: {
|
|
18
|
+
path: any;
|
|
19
|
+
line: any;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
declare const none: () => {
|
|
23
|
+
action: "none";
|
|
24
|
+
text: string;
|
|
25
|
+
target: any;
|
|
26
|
+
};
|
|
27
|
+
export { useCanonical, extractComponent, replaceRawHtml, none };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.none = exports.replaceRawHtml = exports.extractComponent = exports.useCanonical = void 0;
|
|
4
|
+
// A finding states WHAT is wrong; a repair states WHAT TO DO. Every repair is
|
|
5
|
+
// `{ action, text, target }`: a stable id so the UI can label it without parsing
|
|
6
|
+
// the sentence, the sentence from the vocabulary, and the place it points at.
|
|
7
|
+
const phrases_1 = require("./vocabulary/phrases");
|
|
8
|
+
const constants_1 = require("../constants");
|
|
9
|
+
const useCanonical = (left, right) => ({
|
|
10
|
+
action: constants_1.ACTION.UseCanonical,
|
|
11
|
+
text: (0, phrases_1.fill)(phrases_1.PHRASES.fixUseCanonical, { left: left.name, right: right.name, path: right.path }),
|
|
12
|
+
target: right.path ? { path: right.path, line: right.line ?? 1 } : null,
|
|
13
|
+
});
|
|
14
|
+
exports.useCanonical = useCanonical;
|
|
15
|
+
const extractComponent = (count) => ({
|
|
16
|
+
action: constants_1.ACTION.ExtractComponent,
|
|
17
|
+
text: (0, phrases_1.fill)(phrases_1.PHRASES.fixExtractComponent, { count }),
|
|
18
|
+
target: null,
|
|
19
|
+
});
|
|
20
|
+
exports.extractComponent = extractComponent;
|
|
21
|
+
const replaceRawHtml = (tag, right) => ({
|
|
22
|
+
action: constants_1.ACTION.ReplaceRawHtml,
|
|
23
|
+
text: (0, phrases_1.fill)(phrases_1.PHRASES.fixReplaceRawHtml, { tag, right: right.name, path: right.path }),
|
|
24
|
+
target: right.path ? { path: right.path, line: right.line ?? 1 } : null,
|
|
25
|
+
});
|
|
26
|
+
exports.replaceRawHtml = replaceRawHtml;
|
|
27
|
+
const none = () => ({ action: constants_1.ACTION.None, text: phrases_1.PHRASES.fixKeep, target: null });
|
|
28
|
+
exports.none = none;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TIER_LABEL } from "./vocabulary/labels";
|
|
2
|
+
declare const findingBlock: (f: any, candidates?: Map<any, any>) => string[];
|
|
3
|
+
declare const findingText: (f: any, candidates?: Map<any, any>) => string;
|
|
4
|
+
declare const renderTier: (tier: any, findings: any, candidates: any) => any[];
|
|
5
|
+
declare const renderComponentReport: (comp: any, verbose?: boolean) => string;
|
|
6
|
+
declare const renderComponentOverviewReport: (comp: any) => string;
|
|
7
|
+
export { findingText, findingBlock, renderComponentReport, renderComponentOverviewReport, renderTier, TIER_LABEL };
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TIER_LABEL = exports.renderTier = exports.renderComponentOverviewReport = exports.renderComponentReport = exports.findingBlock = exports.findingText = void 0;
|
|
4
|
+
// The terminal / `--report` document and the per-finding console block. It is a
|
|
5
|
+
// MARKDOWN rendering of the same findings the HTML page draws — same ids, same
|
|
6
|
+
// numbers, same repair sentences. `findingText` is the single string the page's
|
|
7
|
+
// Detail panel prints for one pair.
|
|
8
|
+
const errorTypes_1 = require("./errorTypes");
|
|
9
|
+
const labels_1 = require("./vocabulary/labels");
|
|
10
|
+
Object.defineProperty(exports, "TIER_LABEL", { enumerable: true, get: function () { return labels_1.TIER_LABEL; } });
|
|
11
|
+
const matchers_1 = require("./matchers");
|
|
12
|
+
const constants_1 = require("../constants");
|
|
13
|
+
const loc = (p) => (p?.line ? `\`${p.path}:${p.line}\`` : `\`${p?.path ?? "—"}\``);
|
|
14
|
+
const table = (headers, rows) => {
|
|
15
|
+
const lines = [];
|
|
16
|
+
lines.push(`| ${headers.join(" | ")} |`);
|
|
17
|
+
lines.push(`| ${headers.map(() => "---").join(" | ")} |`);
|
|
18
|
+
for (const row of rows)
|
|
19
|
+
lines.push(`| ${row.join(" | ")} |`);
|
|
20
|
+
lines.push("");
|
|
21
|
+
return lines;
|
|
22
|
+
};
|
|
23
|
+
// The five explanations the page draws: what each signal compared. `candidates`
|
|
24
|
+
// is a Map keyed `path#name` → component, so the matcher models are rebuilt from
|
|
25
|
+
// the same components the decision used.
|
|
26
|
+
const matcherBlocks = (candidates, finding) => {
|
|
27
|
+
const left = candidates.get(`${finding.left?.path}#${finding.left?.name}`);
|
|
28
|
+
const right = candidates.get(`${finding.right?.path}#${finding.right?.name}`);
|
|
29
|
+
if (!left || !right || !finding.evidence?.engine)
|
|
30
|
+
return [];
|
|
31
|
+
const blocks = (0, matchers_1.describe)(left, right, finding.evidence.engine);
|
|
32
|
+
const lines = [];
|
|
33
|
+
for (const block of blocks) {
|
|
34
|
+
const [first, ...rest] = block.lines;
|
|
35
|
+
lines.push(` ${(0, labels_1.signalOf)(block.key).label} ${first}`);
|
|
36
|
+
for (const line of rest)
|
|
37
|
+
lines.push(` ${line}`);
|
|
38
|
+
}
|
|
39
|
+
return lines;
|
|
40
|
+
};
|
|
41
|
+
// ONE finding, ONE block: the verdict sentence, every reason, each matcher's own
|
|
42
|
+
// lines, the repair.
|
|
43
|
+
const findingBlock = (f, candidates = new Map()) => {
|
|
44
|
+
const lines = [`- **${f.left?.name ?? "—"}** — ${f.message}`];
|
|
45
|
+
const scores = (f.decision?.signals ?? []).filter((signal) => signal.applied).map((signal) => `${signal.label} ${Math.round(signal.score * 100)}%`);
|
|
46
|
+
if (scores.length > 0)
|
|
47
|
+
lines.push(` scores ${scores.join(" · ")}`);
|
|
48
|
+
for (const why of f.decision?.why ?? [])
|
|
49
|
+
if (why.tone === constants_1.TONE.Veto)
|
|
50
|
+
lines.push(` ! ${why.text}`);
|
|
51
|
+
lines.push(...matcherBlocks(candidates, f));
|
|
52
|
+
lines.push(` **Fix** — ${f.fix?.text ?? ""}`);
|
|
53
|
+
return lines;
|
|
54
|
+
};
|
|
55
|
+
exports.findingBlock = findingBlock;
|
|
56
|
+
// The whole console entry for one finding, as a single string.
|
|
57
|
+
const findingText = (f, candidates = new Map()) => {
|
|
58
|
+
const top = f.decision ? f.decision.signals.reduce((best, s) => (s.contribution > best.contribution ? s : best), f.decision.signals[0]) : null;
|
|
59
|
+
const head = [
|
|
60
|
+
`\`${f.id}\``,
|
|
61
|
+
`${f.left?.name ?? "—"} ${loc(f.left)} → ${f.right?.name ?? "—"} ${loc(f.right)}`,
|
|
62
|
+
`confidence ${f.confidence != null ? f.confidence.toFixed(2) : "—"}${top ? ` · top signal ${top.label}` : ""}`,
|
|
63
|
+
"",
|
|
64
|
+
];
|
|
65
|
+
return [...head, ...findingBlock(f, candidates)].join("\n");
|
|
66
|
+
};
|
|
67
|
+
exports.findingText = findingText;
|
|
68
|
+
const renderHeader = (comp, findings) => {
|
|
69
|
+
const count = (kind) => findings.filter((f) => f.kind === kind).length;
|
|
70
|
+
const missingMembers = findings.filter((f) => f.kind === constants_1.KIND.Missing).reduce((n, f) => n + (f.members?.length ?? 0), 0);
|
|
71
|
+
const lines = [];
|
|
72
|
+
lines.push("# Component duplicates (component-level funnel)");
|
|
73
|
+
lines.push("");
|
|
74
|
+
lines.push(`Scanned ${comp.files} app file(s), ${comp.appCount} app component(s) against ${comp.canonCount} canonical component(s).`);
|
|
75
|
+
lines.push("");
|
|
76
|
+
const parts = [
|
|
77
|
+
`Found ${count(constants_1.KIND.Duplicate)} duplicate component(s) and ${count(constants_1.KIND.Similar)} similar component(s)`,
|
|
78
|
+
missingMembers > 0 ? `, plus ${missingMembers} component(s) grouped under ${count(constants_1.KIND.Missing)} potentially missing component(s)` : "",
|
|
79
|
+
count(constants_1.KIND.RawHtml) > 0 ? `, plus ${count(constants_1.KIND.RawHtml)} raw-html element(s)` : "",
|
|
80
|
+
count(constants_1.KIND.Part) > 0 ? `, plus ${count(constants_1.KIND.Part)} copied part(s)` : "",
|
|
81
|
+
];
|
|
82
|
+
lines.push(`${parts.filter(Boolean).join("")}.`);
|
|
83
|
+
lines.push("");
|
|
84
|
+
return lines;
|
|
85
|
+
};
|
|
86
|
+
// One row per verdict: the id (pasteable into the page's deep link), the two
|
|
87
|
+
// names with their locations, the confidence, the signal that decided it and the
|
|
88
|
+
// repair — the same columns utils prints.
|
|
89
|
+
const verdictRows = (rows) => rows.map((f) => [
|
|
90
|
+
`\`${f.id}\``,
|
|
91
|
+
`${f.left?.name ?? "—"}`,
|
|
92
|
+
loc(f.left),
|
|
93
|
+
`${f.right?.name ?? "—"}`,
|
|
94
|
+
loc(f.right),
|
|
95
|
+
`${f.confidence != null ? f.confidence.toFixed(2) : "—"}`,
|
|
96
|
+
f.decision ? `${f.decision.signals.reduce((top, s) => (s.contribution > top.contribution ? s : top), f.decision.signals[0]).label}` : "—",
|
|
97
|
+
f.fix?.text ?? "",
|
|
98
|
+
]);
|
|
99
|
+
// A verdict tier: the table, then one block per finding with every matcher's own
|
|
100
|
+
// lines (Structure / Styles / Behavior / Accessibility / Framework / Name) — the
|
|
101
|
+
// same per-tab detail the page draws, so a confidence is checkable in a terminal.
|
|
102
|
+
const renderTier = (tier, findings, candidates) => {
|
|
103
|
+
const rows = findings.filter((f) => f.kind === tier).sort((a, b) => (b.confidence ?? 0) - (a.confidence ?? 0));
|
|
104
|
+
if (rows.length === 0)
|
|
105
|
+
return [];
|
|
106
|
+
const lines = [];
|
|
107
|
+
lines.push(`## ${labels_1.TIER_LABEL[tier]} (${rows.length})`);
|
|
108
|
+
lines.push("");
|
|
109
|
+
lines.push(...table(["Id", "Local component", "Location", "Canonical", "Canonical location", "Confidence", "Top signal", "Fix"], verdictRows(rows)));
|
|
110
|
+
lines.push("### Why each one matched");
|
|
111
|
+
lines.push("");
|
|
112
|
+
for (const f of rows) {
|
|
113
|
+
lines.push(...findingBlock(f, candidates));
|
|
114
|
+
lines.push("");
|
|
115
|
+
}
|
|
116
|
+
return lines;
|
|
117
|
+
};
|
|
118
|
+
exports.renderTier = renderTier;
|
|
119
|
+
const renderMissing = (findings) => {
|
|
120
|
+
const groups = findings.filter((f) => f.kind === constants_1.KIND.Missing);
|
|
121
|
+
if (groups.length === 0)
|
|
122
|
+
return [];
|
|
123
|
+
const lines = [`## Potentially missing component (${groups.length})`, ""];
|
|
124
|
+
lines.push("Several distinct components all matched the same canonical. The codebase is missing a shared component that would unify them — not that any single one is a duplicate.");
|
|
125
|
+
lines.push("");
|
|
126
|
+
for (const f of groups) {
|
|
127
|
+
lines.push(`### ${f.left?.name ?? f.right?.name ?? "—"}`);
|
|
128
|
+
lines.push("");
|
|
129
|
+
lines.push(f.message);
|
|
130
|
+
lines.push("");
|
|
131
|
+
lines.push(...table(["Component", "Location", "Confidence"], (f.members ?? []).map((m) => [m.name, loc(m), m.confidence != null ? m.confidence.toFixed(2) : "—"])));
|
|
132
|
+
lines.push(`**Fix** — ${f.fix?.text ?? ""}`);
|
|
133
|
+
lines.push("");
|
|
134
|
+
}
|
|
135
|
+
return lines;
|
|
136
|
+
};
|
|
137
|
+
const renderRawHtml = (findings) => {
|
|
138
|
+
const rows = findings.filter((f) => f.kind === constants_1.KIND.RawHtml);
|
|
139
|
+
if (rows.length === 0)
|
|
140
|
+
return [];
|
|
141
|
+
return [
|
|
142
|
+
`## Raw HTML outside canonical packages (${rows.length})`,
|
|
143
|
+
"",
|
|
144
|
+
...table(["Element", "Location", "Replace with", "From", "Why"], rows.map((f) => [`${f.left?.name ?? "—"}`, loc(f.left), `\`${f.right?.name ?? "—"}\``, `\`${f.right?.path ?? "—"}\``, f.evidence?.reason ?? f.message])),
|
|
145
|
+
];
|
|
146
|
+
};
|
|
147
|
+
const renderParts = (findings) => {
|
|
148
|
+
const rows = findings.filter((f) => f.kind === constants_1.KIND.Part);
|
|
149
|
+
if (rows.length === 0)
|
|
150
|
+
return [];
|
|
151
|
+
return [
|
|
152
|
+
`## Partial duplicates (parts) (${rows.length})`,
|
|
153
|
+
"",
|
|
154
|
+
...table(["Part", "Location", "Replace with", "From", "Why"], rows.map((f) => [`${f.left?.name ?? "—"}`, loc(f.left), `\`${f.right?.name ?? "—"}\``, `\`${f.right?.path ?? "—"}\``, f.evidence?.reason ?? f.message])),
|
|
155
|
+
];
|
|
156
|
+
};
|
|
157
|
+
const renderFiltered = (findings) => {
|
|
158
|
+
const dropped = findings.filter((f) => f.kind === constants_1.KIND.Dropped);
|
|
159
|
+
if (dropped.length === 0)
|
|
160
|
+
return [];
|
|
161
|
+
return [
|
|
162
|
+
`## Filtered out (${dropped.length})`,
|
|
163
|
+
"",
|
|
164
|
+
...table(["Local component", "Location", "Canonical", "Filter", "Why dropped"], dropped.map((f) => [`${f.left?.name ?? "—"}`, loc(f.left), `\`${f.right?.name ?? "—"}\``, `\`${f.dropped?.filter ?? "—"}\``, f.dropped?.reason ?? ""])),
|
|
165
|
+
];
|
|
166
|
+
};
|
|
167
|
+
// The full terminal report: every tab the page draws, with locations and each
|
|
168
|
+
// matcher's own lines — like utils, not a prose summary. `verbose` keeps the
|
|
169
|
+
// filtered-out section (the answer to "why is this duplicate missing?").
|
|
170
|
+
const renderComponentReport = (comp, verbose = false) => {
|
|
171
|
+
const findings = (0, errorTypes_1.describeComp)(comp);
|
|
172
|
+
const candidates = new Map((comp.candidates ?? []).map((c) => [`${c.path}#${c.name}`, c]));
|
|
173
|
+
const lines = [];
|
|
174
|
+
lines.push(...renderHeader(comp, findings));
|
|
175
|
+
for (const tier of [constants_1.TIER.Duplicate, constants_1.TIER.Similar])
|
|
176
|
+
lines.push(...renderTier(tier, findings, candidates));
|
|
177
|
+
lines.push(...renderMissing(findings));
|
|
178
|
+
lines.push(...renderRawHtml(findings));
|
|
179
|
+
lines.push(...renderParts(findings));
|
|
180
|
+
if (verbose)
|
|
181
|
+
lines.push(...renderFiltered(findings));
|
|
182
|
+
return lines.join("\n");
|
|
183
|
+
};
|
|
184
|
+
exports.renderComponentReport = renderComponentReport;
|
|
185
|
+
// Kept for the page's Detail panel: the same per-finding block the report prints.
|
|
186
|
+
const renderComponentOverviewReport = (comp) => renderComponentReport(comp, false);
|
|
187
|
+
exports.renderComponentOverviewReport = renderComponentOverviewReport;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
declare const CODES: {
|
|
2
|
+
duplicate: {
|
|
3
|
+
kind: "duplicate";
|
|
4
|
+
sentence: (p: any) => string;
|
|
5
|
+
};
|
|
6
|
+
similar: {
|
|
7
|
+
kind: "similar";
|
|
8
|
+
sentence: (p: any) => string;
|
|
9
|
+
};
|
|
10
|
+
missing: {
|
|
11
|
+
kind: "missing";
|
|
12
|
+
sentence: (p: any) => string;
|
|
13
|
+
};
|
|
14
|
+
rawHtml: {
|
|
15
|
+
kind: "rawhtml";
|
|
16
|
+
sentence: (p: any) => string;
|
|
17
|
+
};
|
|
18
|
+
part: {
|
|
19
|
+
kind: "part";
|
|
20
|
+
sentence: (p: any) => string;
|
|
21
|
+
};
|
|
22
|
+
filteredOut: {
|
|
23
|
+
kind: "dropped";
|
|
24
|
+
sentence: (p: any) => string;
|
|
25
|
+
};
|
|
26
|
+
confidence: {
|
|
27
|
+
kind: any;
|
|
28
|
+
sentence: (p: any) => string;
|
|
29
|
+
};
|
|
30
|
+
headline: {
|
|
31
|
+
kind: any;
|
|
32
|
+
sentence: (p: any) => string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
declare const render: (code: any, params: any) => any;
|
|
36
|
+
declare const kindOfCode: (code: any) => any;
|
|
37
|
+
export { CODES, render, kindOfCode };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.kindOfCode = exports.render = exports.CODES = void 0;
|
|
4
|
+
// THE CODES. One table, one id per thing the tool can say about a component.
|
|
5
|
+
// A producer states a CODE plus its PARAMETERS, and every surface renders it
|
|
6
|
+
// through `render()` here: the terminal report, the HTML page and the ESLint
|
|
7
|
+
// message all agree. A new kind of finding is one entry here.
|
|
8
|
+
const phrases_1 = require("../vocabulary/phrases");
|
|
9
|
+
const constants_1 = require("../../constants");
|
|
10
|
+
const CODES = {
|
|
11
|
+
[constants_1.CODE.Duplicate]: { kind: constants_1.KIND.Duplicate, sentence: (p) => (0, phrases_1.fill)(phrases_1.PHRASES.duplicate, p) },
|
|
12
|
+
[constants_1.CODE.Similar]: { kind: constants_1.KIND.Similar, sentence: (p) => (0, phrases_1.fill)(phrases_1.PHRASES.similar, p) },
|
|
13
|
+
[constants_1.CODE.Missing]: { kind: constants_1.KIND.Missing, sentence: (p) => (0, phrases_1.fill)(phrases_1.PHRASES.missing, p) },
|
|
14
|
+
[constants_1.CODE.RawHtml]: { kind: constants_1.KIND.RawHtml, sentence: (p) => (0, phrases_1.fill)(phrases_1.PHRASES.rawHtml, p) },
|
|
15
|
+
[constants_1.CODE.Part]: { kind: constants_1.KIND.Part, sentence: (p) => (0, phrases_1.fill)(phrases_1.PHRASES.part, p) },
|
|
16
|
+
[constants_1.CODE.FilteredOut]: { kind: constants_1.KIND.Dropped, sentence: (p) => (0, phrases_1.fill)(phrases_1.PHRASES.filtered, p) },
|
|
17
|
+
[constants_1.CODE.Confidence]: { kind: null, sentence: (p) => (0, phrases_1.fill)(phrases_1.PHRASES.confidence, p) },
|
|
18
|
+
[constants_1.CODE.Headline]: { kind: null, sentence: (p) => (0, phrases_1.fill)(phrases_1.PHRASES.headline, p) },
|
|
19
|
+
};
|
|
20
|
+
exports.CODES = CODES;
|
|
21
|
+
// An unknown code is a producer bug, but it must not crash a report: the id is
|
|
22
|
+
// printed where the sentence should be, which is exactly what makes it findable.
|
|
23
|
+
const render = (code, params) => {
|
|
24
|
+
const entry = CODES[code];
|
|
25
|
+
if (!entry)
|
|
26
|
+
return String(code);
|
|
27
|
+
return entry.sentence(params ?? {});
|
|
28
|
+
};
|
|
29
|
+
exports.render = render;
|
|
30
|
+
const kindOfCode = (code) => CODES[code]?.kind ?? null;
|
|
31
|
+
exports.kindOfCode = kindOfCode;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
declare const pairFinding: (match: any) => {
|
|
2
|
+
id: any;
|
|
3
|
+
code: any;
|
|
4
|
+
params: any;
|
|
5
|
+
kind: any;
|
|
6
|
+
label: any;
|
|
7
|
+
color: any;
|
|
8
|
+
left: any;
|
|
9
|
+
right: any;
|
|
10
|
+
confidence: any;
|
|
11
|
+
tier: any;
|
|
12
|
+
message: string;
|
|
13
|
+
fix: any;
|
|
14
|
+
decision: any;
|
|
15
|
+
evidence: {};
|
|
16
|
+
dropped: any;
|
|
17
|
+
members: any;
|
|
18
|
+
};
|
|
19
|
+
declare const droppedFinding: (dropped: any) => {
|
|
20
|
+
id: any;
|
|
21
|
+
code: any;
|
|
22
|
+
params: any;
|
|
23
|
+
kind: any;
|
|
24
|
+
label: any;
|
|
25
|
+
color: any;
|
|
26
|
+
left: any;
|
|
27
|
+
right: any;
|
|
28
|
+
confidence: any;
|
|
29
|
+
tier: any;
|
|
30
|
+
message: string;
|
|
31
|
+
fix: any;
|
|
32
|
+
decision: any;
|
|
33
|
+
evidence: {};
|
|
34
|
+
dropped: any;
|
|
35
|
+
members: any;
|
|
36
|
+
};
|
|
37
|
+
declare const missingFinding: (cluster: any) => {
|
|
38
|
+
id: any;
|
|
39
|
+
code: any;
|
|
40
|
+
params: any;
|
|
41
|
+
kind: any;
|
|
42
|
+
label: any;
|
|
43
|
+
color: any;
|
|
44
|
+
left: any;
|
|
45
|
+
right: any;
|
|
46
|
+
confidence: any;
|
|
47
|
+
tier: any;
|
|
48
|
+
message: string;
|
|
49
|
+
fix: any;
|
|
50
|
+
decision: any;
|
|
51
|
+
evidence: {};
|
|
52
|
+
dropped: any;
|
|
53
|
+
members: any;
|
|
54
|
+
};
|
|
55
|
+
declare const rawHtmlFinding: (row: any) => {
|
|
56
|
+
id: any;
|
|
57
|
+
code: any;
|
|
58
|
+
params: any;
|
|
59
|
+
kind: any;
|
|
60
|
+
label: any;
|
|
61
|
+
color: any;
|
|
62
|
+
left: any;
|
|
63
|
+
right: any;
|
|
64
|
+
confidence: any;
|
|
65
|
+
tier: any;
|
|
66
|
+
message: string;
|
|
67
|
+
fix: any;
|
|
68
|
+
decision: any;
|
|
69
|
+
evidence: {};
|
|
70
|
+
dropped: any;
|
|
71
|
+
members: any;
|
|
72
|
+
};
|
|
73
|
+
declare const partFinding: (row: any) => {
|
|
74
|
+
id: any;
|
|
75
|
+
code: any;
|
|
76
|
+
params: any;
|
|
77
|
+
kind: any;
|
|
78
|
+
label: any;
|
|
79
|
+
color: any;
|
|
80
|
+
left: any;
|
|
81
|
+
right: any;
|
|
82
|
+
confidence: any;
|
|
83
|
+
tier: any;
|
|
84
|
+
message: string;
|
|
85
|
+
fix: any;
|
|
86
|
+
decision: any;
|
|
87
|
+
evidence: {};
|
|
88
|
+
dropped: any;
|
|
89
|
+
members: any;
|
|
90
|
+
};
|
|
91
|
+
declare const describeComp: (comp: any) => any[];
|
|
92
|
+
export { describeComp, pairFinding, droppedFinding, missingFinding, rawHtmlFinding, partFinding };
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.partFinding = exports.rawHtmlFinding = exports.missingFinding = exports.droppedFinding = exports.pairFinding = exports.describeComp = void 0;
|
|
27
|
+
// The vocabulary of the report, in one place:
|
|
28
|
+
//
|
|
29
|
+
// describeComp(comp) -> findings[]
|
|
30
|
+
//
|
|
31
|
+
// Every finding is the same SHAPE, whatever produced it, and every sentence comes
|
|
32
|
+
// from a CODE (`../codes`):
|
|
33
|
+
//
|
|
34
|
+
// { id, code, params, kind, label, color, what it says and how it looks
|
|
35
|
+
// left, right, the two places (or one)
|
|
36
|
+
// confidence, tier, the numbers
|
|
37
|
+
// message, render(code, params)
|
|
38
|
+
// fix, the repair, structured
|
|
39
|
+
// decision, per-signal scores + why lines
|
|
40
|
+
// evidence, dropped, members } the raw facts behind it
|
|
41
|
+
//
|
|
42
|
+
// Components compare an app (local) component against a canonical one. The left
|
|
43
|
+
// side is the app component, the right side the canonical it should reuse.
|
|
44
|
+
const labels_1 = require("../vocabulary/labels");
|
|
45
|
+
const codes_1 = require("../codes");
|
|
46
|
+
const explain_1 = require("../explain");
|
|
47
|
+
const constants_1 = require("../../constants");
|
|
48
|
+
const asks = __importStar(require("../asks"));
|
|
49
|
+
// A component place: the report only needs where it is and what it is called.
|
|
50
|
+
const place = (comp) => ({
|
|
51
|
+
name: comp?.name ?? null,
|
|
52
|
+
path: comp?.path ?? null,
|
|
53
|
+
line: comp?.line ?? null,
|
|
54
|
+
endLine: comp?.endLine ?? comp?.line ?? null,
|
|
55
|
+
});
|
|
56
|
+
const conf = (value) => (Number.isFinite(value) ? value.toFixed(2) : "n/a");
|
|
57
|
+
const pct = (value) => (Number.isFinite(value) ? `${Math.round(value * 100)}%` : "n/a");
|
|
58
|
+
const finding = ({ id, code, params, left, right = null, fix, decision = null, evidence = {}, dropped = null, members = null, suffix = "" }) => {
|
|
59
|
+
const kind = (0, codes_1.kindOfCode)(code) ?? constants_1.KIND.Similar;
|
|
60
|
+
const meta = (0, labels_1.kindOf)(kind);
|
|
61
|
+
return {
|
|
62
|
+
id,
|
|
63
|
+
code,
|
|
64
|
+
params,
|
|
65
|
+
kind,
|
|
66
|
+
label: meta.label,
|
|
67
|
+
color: meta.color,
|
|
68
|
+
left,
|
|
69
|
+
right,
|
|
70
|
+
confidence: decision ? decision.confidence : null,
|
|
71
|
+
tier: decision ? decision.tier : null,
|
|
72
|
+
message: `${(0, codes_1.render)(code, params)}${suffix}`,
|
|
73
|
+
fix,
|
|
74
|
+
decision,
|
|
75
|
+
evidence,
|
|
76
|
+
dropped,
|
|
77
|
+
members,
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
const pairFinding = (match) => {
|
|
81
|
+
const decision = (0, explain_1.explain)(match.decision);
|
|
82
|
+
const code = match.decision.tier === "duplicate" ? constants_1.CODE.Duplicate : constants_1.CODE.Similar;
|
|
83
|
+
const left = place(match.app);
|
|
84
|
+
const right = place(match.canon);
|
|
85
|
+
const fix = code === constants_1.CODE.Duplicate ? asks.useCanonical(left, right) : asks.none();
|
|
86
|
+
return finding({
|
|
87
|
+
id: `${code}:${left.path}#${left.name}=>${right.path}#${right.name}`,
|
|
88
|
+
code,
|
|
89
|
+
params: {
|
|
90
|
+
left: `\`${left.name}\``,
|
|
91
|
+
right: `\`${right.name}\``,
|
|
92
|
+
confidence: `${conf(decision.confidence)} (${pct(decision.confidence)})`,
|
|
93
|
+
},
|
|
94
|
+
left: { ...left, side: constants_1.SIDE.App },
|
|
95
|
+
right: { ...right, side: constants_1.SIDE.Canon },
|
|
96
|
+
fix,
|
|
97
|
+
decision,
|
|
98
|
+
evidence: { reason: match.reason, engine: match.decision },
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
exports.pairFinding = pairFinding;
|
|
102
|
+
const droppedFinding = (dropped) => {
|
|
103
|
+
const match = dropped.match ?? dropped;
|
|
104
|
+
const decision = (0, explain_1.explain)(match.decision);
|
|
105
|
+
const left = place(match.app);
|
|
106
|
+
const right = place(match.canon);
|
|
107
|
+
const why = dropped.reason ?? "";
|
|
108
|
+
return finding({
|
|
109
|
+
id: `dropped:${left.path}#${left.name}=>${right.path}#${right.name}`,
|
|
110
|
+
code: constants_1.CODE.FilteredOut,
|
|
111
|
+
params: { left: `\`${left.name}\``, right: `\`${right.name}\``, reason: why },
|
|
112
|
+
left: { ...left, side: constants_1.SIDE.App },
|
|
113
|
+
right: { ...right, side: constants_1.SIDE.Canon },
|
|
114
|
+
fix: asks.none(),
|
|
115
|
+
decision,
|
|
116
|
+
evidence: { filter: dropped.filter, reason: why },
|
|
117
|
+
suffix: ` Filtered out by \`${dropped.filter ?? "filter"}\`: ${why}`,
|
|
118
|
+
dropped: { filter: dropped.filter, reason: why },
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
exports.droppedFinding = droppedFinding;
|
|
122
|
+
const missingFinding = (cluster) => {
|
|
123
|
+
const canon = place(cluster.canon);
|
|
124
|
+
const weakest = cluster.matches.reduce((min, m) => Math.min(min, m.decision.confidence), 1);
|
|
125
|
+
const members = cluster.matches.map((m) => ({ ...place(m.app), confidence: m.decision.confidence }));
|
|
126
|
+
return finding({
|
|
127
|
+
id: `missing:${canon.path}#${cluster.name}`,
|
|
128
|
+
code: constants_1.CODE.Missing,
|
|
129
|
+
params: { count: cluster.matches.length, right: `\`${canon.name}\``, confidence: conf(weakest) },
|
|
130
|
+
left: { name: cluster.name, path: null, line: null, endLine: null, side: constants_1.SIDE.App },
|
|
131
|
+
right: { ...canon, side: constants_1.SIDE.Canon },
|
|
132
|
+
fix: asks.extractComponent(cluster.matches.length),
|
|
133
|
+
decision: null,
|
|
134
|
+
evidence: { canon: canon.name, apps: cluster.matches.map((m) => m.app.name) },
|
|
135
|
+
members,
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
exports.missingFinding = missingFinding;
|
|
139
|
+
const rawHtmlFinding = (row) => {
|
|
140
|
+
const right = { name: row.suggestion.component, path: row.suggestion.path, line: null, endLine: null };
|
|
141
|
+
const left = { name: `<${row.tag}>`, path: row.path, line: row.line, endLine: row.line };
|
|
142
|
+
return finding({
|
|
143
|
+
id: `rawhtml:${row.path}:${row.line}:${row.tag}`,
|
|
144
|
+
code: constants_1.CODE.RawHtml,
|
|
145
|
+
params: { tag: row.tag, right: `\`${right.name}\`` },
|
|
146
|
+
left: { ...left, side: constants_1.SIDE.App },
|
|
147
|
+
right: { ...right, side: constants_1.SIDE.Canon },
|
|
148
|
+
fix: asks.replaceRawHtml(row.tag, right),
|
|
149
|
+
decision: null,
|
|
150
|
+
evidence: { reason: row.reason, confidence: row.confidence },
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
exports.rawHtmlFinding = rawHtmlFinding;
|
|
154
|
+
const partFinding = (row) => {
|
|
155
|
+
const primary = row.suggestions[0];
|
|
156
|
+
const right = { name: primary.component, path: primary.path, line: primary.line ?? null, endLine: primary.endLine ?? null };
|
|
157
|
+
const left = { name: `${row.owner} › <${row.tag}>`, path: row.path, line: row.line, endLine: row.endLine };
|
|
158
|
+
const decision = row.engine ? (0, explain_1.explain)(row.engine) : null;
|
|
159
|
+
return finding({
|
|
160
|
+
id: `part:${row.path}:${row.line}:${row.tag}`,
|
|
161
|
+
code: constants_1.CODE.Part,
|
|
162
|
+
params: { left: `\`${left.name}\``, right: `\`${right.name}\``, confidence: conf(primary.confidence) },
|
|
163
|
+
left: { ...left, side: constants_1.SIDE.App },
|
|
164
|
+
right: { ...right, side: constants_1.SIDE.Canon },
|
|
165
|
+
fix: asks.useCanonical(left, right),
|
|
166
|
+
decision,
|
|
167
|
+
evidence: { reason: primary.reason, suggestions: row.suggestions, engine: row.engine ?? null },
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
exports.partFinding = partFinding;
|
|
171
|
+
// The one producer: every finding the overview / markdown / CLI consumes.
|
|
172
|
+
const describeComp = (comp) => {
|
|
173
|
+
const findings = [];
|
|
174
|
+
for (const match of comp.matches ?? [])
|
|
175
|
+
findings.push(pairFinding(match));
|
|
176
|
+
for (const cluster of comp.missingClusters ?? [])
|
|
177
|
+
findings.push(missingFinding(cluster));
|
|
178
|
+
for (const row of comp.rawHtml ?? [])
|
|
179
|
+
findings.push(rawHtmlFinding(row));
|
|
180
|
+
for (const row of comp.parts ?? [])
|
|
181
|
+
findings.push(partFinding(row));
|
|
182
|
+
for (const dropped of comp.dropped ?? [])
|
|
183
|
+
findings.push(droppedFinding(dropped));
|
|
184
|
+
return findings;
|
|
185
|
+
};
|
|
186
|
+
exports.describeComp = describeComp;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.percentOf = void 0;
|
|
4
|
+
// Small evidence helpers the report's React app reads. The engine keeps its
|
|
5
|
+
// scoring in the matchers and decision-maker; this module only turns a 0..1
|
|
6
|
+
// score into the reader's percentage, the same way every surface prints it.
|
|
7
|
+
const percentOf = (value) => Math.round((Number.isFinite(value) ? value : 0) * 100);
|
|
8
|
+
exports.percentOf = percentOf;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare const explain: (decision: any) => {
|
|
2
|
+
confidence: any;
|
|
3
|
+
tier: any;
|
|
4
|
+
verdict: string;
|
|
5
|
+
thresholds: any;
|
|
6
|
+
weights: any;
|
|
7
|
+
vetoes: any[];
|
|
8
|
+
signals: {
|
|
9
|
+
key: "structure" | "styles" | "behavior" | "a11y" | "framework" | "name";
|
|
10
|
+
label: string;
|
|
11
|
+
short: string;
|
|
12
|
+
color: string;
|
|
13
|
+
what: string;
|
|
14
|
+
score: any;
|
|
15
|
+
weight: any;
|
|
16
|
+
contribution: number;
|
|
17
|
+
applied: boolean;
|
|
18
|
+
evidence: {
|
|
19
|
+
key: string;
|
|
20
|
+
label: any;
|
|
21
|
+
value: string;
|
|
22
|
+
}[];
|
|
23
|
+
}[];
|
|
24
|
+
why: any[];
|
|
25
|
+
headline: string;
|
|
26
|
+
};
|
|
27
|
+
export { explain };
|