@uselazuli/cli 0.0.0-stage → 1.0.1
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 +98 -0
- package/LICENSE +21 -0
- package/README.md +202 -2
- package/agents/lazuli-design-reviewer.md +30 -0
- package/agents/lazuli-first-look.md +22 -0
- package/agents/lazuli-task-tester.md +25 -0
- package/bin/lazuli.mjs +699 -0
- package/package.json +11 -4
- package/rules/accessibility/HYPOTHESES.md +8 -0
- package/rules/accessibility/_area.yaml +7 -0
- package/rules/accessibility/operable.yaml +100 -0
- package/rules/accessibility/perceivable.yaml +153 -0
- package/rules/accessibility/robust.yaml +24 -0
- package/rules/accessibility/understandable.yaml +72 -0
- package/rules/color/HYPOTHESES.md +27 -0
- package/rules/color/_area.yaml +10 -0
- package/rules/color/adapt.yaml +183 -0
- package/rules/color/create.yaml +259 -0
- package/rules/color/review.yaml +215 -0
- package/rules/color/signal.yaml +196 -0
- package/rules/content/HYPOTHESES.md +18 -0
- package/rules/content/_area.yaml +8 -0
- package/rules/content/review.yaml +347 -0
- package/rules/content/voice.yaml +144 -0
- package/rules/content/writing.yaml +202 -0
- package/rules/data/HYPOTHESES.md +11 -0
- package/rules/data/_area.yaml +7 -0
- package/rules/data/charts.yaml +189 -0
- package/rules/data/dashboards.yaml +141 -0
- package/rules/data/review.yaml +159 -0
- package/rules/graphic/HYPOTHESES.md +17 -0
- package/rules/graphic/_area.yaml +8 -0
- package/rules/graphic/identity.yaml +141 -0
- package/rules/graphic/pieces.yaml +164 -0
- package/rules/graphic/review.yaml +242 -0
- package/rules/graphic/symbol.yaml +141 -0
- package/rules/motion/HYPOTHESES.md +19 -0
- package/rules/motion/_area.yaml +7 -0
- package/rules/motion/micro.yaml +143 -0
- package/rules/motion/review.yaml +347 -0
- package/rules/motion/transitions.yaml +169 -0
- package/rules/typography/HYPOTHESES.md +12 -0
- package/rules/typography/_area.yaml +8 -0
- package/rules/typography/adapt.yaml +45 -0
- package/rules/typography/create.yaml +126 -0
- package/rules/typography/review.yaml +127 -0
- package/rules/ui/HYPOTHESES.md +23 -0
- package/rules/ui/_area.yaml +9 -0
- package/rules/ui/compose.yaml +219 -0
- package/rules/ui/grid.yaml +75 -0
- package/rules/ui/review.yaml +399 -0
- package/rules/ui/states.yaml +257 -0
- package/rules/ux/HYPOTHESES.md +13 -0
- package/rules/ux/_area.yaml +8 -0
- package/rules/ux/flows.yaml +164 -0
- package/rules/ux/forms.yaml +142 -0
- package/rules/ux/review.yaml +186 -0
- package/skills/lazuli/SKILL.md +180 -0
- package/skills/lazuli/procedures/create.md +29 -0
- package/skills/lazuli/procedures/explain-decisions.md +22 -0
- package/skills/lazuli/procedures/improve.md +30 -0
- package/skills/lazuli/procedures/remember-this.md +41 -0
- package/skills/lazuli/procedures/review-design.md +35 -0
- package/skills/lazuli/procedures/show-options.md +32 -0
- package/skills/lazuli-accessibility-check/SKILL.md +68 -0
- package/skills/lazuli-color-context-and-culture/SKILL.md +53 -0
- package/skills/lazuli-color-context-and-culture/references/sectors.md +26 -0
- package/skills/lazuli-color-palette-by-intent/SKILL.md +54 -0
- package/skills/lazuli-color-palette-by-intent/references/intent-chords.md +51 -0
- package/skills/lazuli-color-screen-review/SKILL.md +51 -0
- package/skills/lazuli-color-states-and-signals/SKILL.md +53 -0
- package/skills/lazuli-content-interface-writing/SKILL.md +53 -0
- package/skills/lazuli-content-voice/SKILL.md +39 -0
- package/skills/lazuli-data-charts-and-dashboards/SKILL.md +59 -0
- package/skills/lazuli-graphic-derived-pieces/SKILL.md +40 -0
- package/skills/lazuli-graphic-derived-pieces/references/piece-template.html +24 -0
- package/skills/lazuli-graphic-identity/SKILL.md +43 -0
- package/skills/lazuli-motion-micro-and-transitions/SKILL.md +49 -0
- package/skills/lazuli-typography-choose-and-pair/SKILL.md +50 -0
- package/skills/lazuli-typography-screen-review/SKILL.md +51 -0
- package/skills/lazuli-ui-composition/SKILL.md +42 -0
- package/skills/lazuli-ui-composition/references/option-template.html +34 -0
- package/skills/lazuli-ui-layout-review/SKILL.md +47 -0
- package/skills/lazuli-ui-states-and-system/SKILL.md +54 -0
- package/skills/lazuli-ux-flows-and-forms/SKILL.md +51 -0
- package/skills/lazuli-ux-task-test/SKILL.md +44 -0
- package/src/browser.mjs +161 -0
- package/src/commands/capture.mjs +313 -0
- package/src/commands/catalog.mjs +37 -0
- package/src/commands/check-design.mjs +428 -0
- package/src/commands/check-goals.mjs +57 -0
- package/src/commands/compare-designs.mjs +97 -0
- package/src/commands/draft-memo.mjs +161 -0
- package/src/commands/hooks.mjs +343 -0
- package/src/commands/install-hooks.mjs +120 -0
- package/src/commands/install.mjs +132 -0
- package/src/commands/list-rules.mjs +49 -0
- package/src/commands/map-page.mjs +594 -0
- package/src/commands/record-answers.mjs +79 -0
- package/src/commands/record-log.mjs +296 -0
- package/src/commands/record-task.mjs +250 -0
- package/src/commands/render-options.mjs +164 -0
- package/src/commands/start-project.mjs +32 -0
- package/src/measure/a11y.mjs +383 -0
- package/src/measure/asset.mjs +206 -0
- package/src/measure/at-rest.mjs +49 -0
- package/src/measure/cases.mjs +549 -0
- package/src/measure/chart-read.mjs +401 -0
- package/src/measure/chart.mjs +264 -0
- package/src/measure/coherence.mjs +145 -0
- package/src/measure/color.mjs +79 -0
- package/src/measure/content.mjs +82 -0
- package/src/measure/cvd.mjs +24 -0
- package/src/measure/extreme.mjs +241 -0
- package/src/measure/forms.mjs +150 -0
- package/src/measure/in-page/a11y.js +489 -0
- package/src/measure/in-page/color.js +346 -0
- package/src/measure/in-page/composition.js +1496 -0
- package/src/measure/in-page/contrast.js +15 -0
- package/src/measure/in-page/cvd.js +173 -0
- package/src/measure/in-page/extreme.js +355 -0
- package/src/measure/in-page/frames.js +781 -0
- package/src/measure/in-page/look.js +28 -0
- package/src/measure/in-page/motion-probe.js +169 -0
- package/src/measure/in-page/style.js +107 -0
- package/src/measure/in-page/svg-strokes.js +112 -0
- package/src/measure/in-page/svg-uses.js +50 -0
- package/src/measure/in-page/symbol.js +123 -0
- package/src/measure/in-page/type.js +266 -0
- package/src/measure/in-page/weight.js +207 -0
- package/src/measure/layout.mjs +91 -0
- package/src/measure/motion.mjs +508 -0
- package/src/measure/piece.mjs +195 -0
- package/src/measure/registry.mjs +252 -0
- package/src/measure/rhythm.mjs +81 -0
- package/src/measure/signature.mjs +65 -0
- package/src/measure/states.mjs +240 -0
- package/src/measure/style.mjs +13 -0
- package/src/measure/symbol.mjs +268 -0
- package/src/measure/terms.mjs +153 -0
- package/src/measure/tiles.mjs +20 -0
- package/src/measure/timeline.mjs +621 -0
- package/src/measure/type.mjs +167 -0
- package/src/measure/weight.mjs +18 -0
- package/src/private-strings.mjs +81 -0
- package/src/project/blind.mjs +70 -0
- package/src/project/edits.mjs +154 -0
- package/src/project/gate.mjs +159 -0
- package/src/project/lazuli-md.mjs +497 -0
- package/src/project/log.mjs +329 -0
- package/src/project/match.mjs +112 -0
- package/src/project/records.mjs +380 -0
- package/src/project/tasks.mjs +153 -0
- package/src/report/evaluate.mjs +27 -0
- package/src/report/evaluators/a11y.mjs +206 -0
- package/src/report/evaluators/chart.mjs +151 -0
- package/src/report/evaluators/coherence.mjs +103 -0
- package/src/report/evaluators/color.mjs +86 -0
- package/src/report/evaluators/content.mjs +112 -0
- package/src/report/evaluators/extreme.mjs +53 -0
- package/src/report/evaluators/forms.mjs +116 -0
- package/src/report/evaluators/layout.mjs +94 -0
- package/src/report/evaluators/motion.mjs +273 -0
- package/src/report/evaluators/piece.mjs +69 -0
- package/src/report/evaluators/rhythm.mjs +99 -0
- package/src/report/evaluators/states.mjs +39 -0
- package/src/report/evaluators/style.mjs +35 -0
- package/src/report/evaluators/symbol.mjs +110 -0
- package/src/report/evaluators/terms.mjs +49 -0
- package/src/report/evaluators/type.mjs +163 -0
- package/src/report/evaluators/weight.mjs +51 -0
- package/src/report/evidence.mjs +4 -0
- package/src/report/finding.mjs +11 -0
- package/src/report/format.mjs +215 -0
- package/src/rules/hypotheses.mjs +28 -0
- package/src/rules/load.mjs +256 -0
- package/src/rules/public-text.mjs +56 -0
- package/src/rules/schema.mjs +212 -0
- package/templates/LAZULI.md +86 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { makeFinding } from "../finding.mjs";
|
|
2
|
+
import { listed } from "../evidence.mjs";
|
|
3
|
+
import { NO_SCROLL_NOTE, isUnreadNote } from "../../measure/rhythm.mjs";
|
|
4
|
+
|
|
5
|
+
// No comparison with the map on a page that does not scroll (F12) or whose sections were not all read
|
|
6
|
+
// (below the cap): the map describes the whole page.
|
|
7
|
+
const notComparable = (r) => (r.notes ?? []).some((n) => n === NO_SCROLL_NOTE || isUnreadNote(n));
|
|
8
|
+
|
|
9
|
+
const hasNumbers = (t, keys) => t && typeof t === "object" && keys.every((k) => Number.isFinite(t[k]));
|
|
10
|
+
const pct = (v) => `${Math.round(v * 100)}%`;
|
|
11
|
+
const ratio = (v) => (v === Infinity ? "no lower bound (the smallest is 0)" : `${Math.round(v * 100) / 100}x`);
|
|
12
|
+
const median = (xs) => {
|
|
13
|
+
const s = [...xs].sort((a, b) => a - b);
|
|
14
|
+
const mid = Math.floor(s.length / 2);
|
|
15
|
+
return s.length % 2 ? s[mid] : (s[mid - 1] + s[mid]) / 2;
|
|
16
|
+
};
|
|
17
|
+
const sectionLine = (s) => `${s.selector}: ${s.heightVh} viewports, density ${s.density}, scale ${s.scale ?? "none"}`;
|
|
18
|
+
|
|
19
|
+
function pace(rule, m) {
|
|
20
|
+
const r = m.rhythm;
|
|
21
|
+
const t = rule.threshold;
|
|
22
|
+
if (!r || !hasNumbers(t, ["minSections", "minHeightRatio", "minDensityRatio"])) return null;
|
|
23
|
+
const sections = r.sections ?? [];
|
|
24
|
+
if (sections.length < t.minSections) return null;
|
|
25
|
+
const heights = sections.map((s) => s.heightVh);
|
|
26
|
+
// Raw densities when the report has them, so the rounding place never decides whether the sparsest is 0.
|
|
27
|
+
const densities = Array.isArray(r.densityRaw) && r.densityRaw.length === sections.length ? r.densityRaw : sections.map((s) => s.density);
|
|
28
|
+
const heightRatio = Math.min(...heights) > 0 ? Math.max(...heights) / Math.min(...heights) : Infinity;
|
|
29
|
+
// A sparsest density of 0 counts as above the cutoff.
|
|
30
|
+
const densityRatio = Math.min(...densities) > 0 ? Math.max(...densities) / Math.min(...densities) : Infinity;
|
|
31
|
+
const evidence = [
|
|
32
|
+
`tallest section: ${ratio(heightRatio)} the shortest (cutoff ${t.minHeightRatio}x)`,
|
|
33
|
+
`densest section: ${ratio(densityRatio)} the sparsest (cutoff ${t.minDensityRatio}x)`,
|
|
34
|
+
];
|
|
35
|
+
if (heightRatio < t.minHeightRatio && densityRatio < t.minDensityRatio) {
|
|
36
|
+
return makeFinding(rule, m.width, "hint", `The ${sections.length} sections keep one pace: their heights and their densities stay close, so the scroll repeats one beat.`, evidence);
|
|
37
|
+
}
|
|
38
|
+
return makeFinding(rule, m.width, "pass", `The ${sections.length} sections change pace in height or in density.`, evidence);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function map(rule, m) {
|
|
42
|
+
const r = m.rhythm;
|
|
43
|
+
if (!r || notComparable(r)) return null;
|
|
44
|
+
if (!r.declared) {
|
|
45
|
+
if (!r.hasGoal) return null;
|
|
46
|
+
return makeFinding(rule, m.width, "hint", "No rhythm map is declared for this page. Add a Rhythm line under its goal in LAZULI.md.");
|
|
47
|
+
}
|
|
48
|
+
const beats = r.declared.beats;
|
|
49
|
+
const sections = r.sections ?? [];
|
|
50
|
+
if (beats.length !== sections.length) {
|
|
51
|
+
return makeFinding(rule, m.width, "hint", `The map declares ${beats.length} beats and the page has ${sections.length} sections.`, listed(sections.map(sectionLine)));
|
|
52
|
+
}
|
|
53
|
+
const mid = median(sections.map((s) => s.density));
|
|
54
|
+
const off = [];
|
|
55
|
+
sections.forEach((s, i) => {
|
|
56
|
+
// A difference within one row of the coverage grid (densityStep) is below what was measured; reports
|
|
57
|
+
// made before 1.0.1 have no densityStep and compare with the median itself.
|
|
58
|
+
const step = Number.isFinite(s.densityStep) ? s.densityStep : 0;
|
|
59
|
+
if (beats[i] === "breathe" && s.density - mid > step) off.push(`${s.selector}: the map says breathe and its density ${s.density} is above the median ${mid}`);
|
|
60
|
+
if (beats[i] === "accelerate" && mid - s.density > step) off.push(`${s.selector}: the map says accelerate and its density ${s.density} is below the median ${mid}`);
|
|
61
|
+
});
|
|
62
|
+
if (off.length) {
|
|
63
|
+
return makeFinding(rule, m.width, "hint", `${off.length} of ${sections.length} sections do not follow the rhythm map of ${r.declared.piece}.`, listed(off));
|
|
64
|
+
}
|
|
65
|
+
return makeFinding(rule, m.width, "pass", `The sections follow the rhythm map of ${r.declared.piece}.`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Compared by scroll position, never by section index: the map's climax beat sits at (index + 0.5) / beats.
|
|
69
|
+
function climax(rule, m) {
|
|
70
|
+
const r = m.rhythm;
|
|
71
|
+
const t = rule.threshold;
|
|
72
|
+
if (!r || !r.declared || !r.climax || !hasNumbers(t, ["maxShift"]) || notComparable(r)) return null;
|
|
73
|
+
const beats = r.declared.beats;
|
|
74
|
+
const at = beats.indexOf("climax");
|
|
75
|
+
if (at < 0) return null;
|
|
76
|
+
const declared = (at + 0.5) / beats.length;
|
|
77
|
+
const { position } = r.climax;
|
|
78
|
+
const where = r.sections?.[r.climax.index]?.selector ?? `section ${r.climax.index + 1}`;
|
|
79
|
+
const evidence = [
|
|
80
|
+
`map: climax is beat ${at + 1} of ${beats.length}, at ${pct(declared)} of the page`,
|
|
81
|
+
`measured: the largest type is in ${where}, centered at ${pct(position)} of the page`,
|
|
82
|
+
];
|
|
83
|
+
if (Math.abs(declared - position) > t.maxShift) {
|
|
84
|
+
return makeFinding(
|
|
85
|
+
rule,
|
|
86
|
+
m.width,
|
|
87
|
+
"hint",
|
|
88
|
+
`The map puts the climax at ${pct(declared)} of the page, but the largest type sits at ${pct(position)} (${where}), more than ${pct(t.maxShift)} away.`,
|
|
89
|
+
evidence,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
return makeFinding(rule, m.width, "pass", `The largest type sits at ${pct(position)} of the page, where the map puts the climax (${pct(declared)}).`, evidence);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export const rhythmEvaluators = {
|
|
96
|
+
"rhythm.pace": pace,
|
|
97
|
+
"rhythm.map": map,
|
|
98
|
+
"rhythm.climax": climax,
|
|
99
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { makeFinding } from "../finding.mjs";
|
|
2
|
+
import { listed } from "../evidence.mjs";
|
|
3
|
+
|
|
4
|
+
const plural = (n, one, many) => (n === 1 ? one : many);
|
|
5
|
+
const PARTS = "on the element, its ::before, ::after or its children.";
|
|
6
|
+
|
|
7
|
+
// Only what was checked is claimed: a hover made by a script or styled on a parent is not seen.
|
|
8
|
+
const forcedState = (key, under) => (rule, m) => {
|
|
9
|
+
const r = m.states?.[key];
|
|
10
|
+
if (!r || !(r.checked > 0)) return null;
|
|
11
|
+
const n = r.unchanged.length;
|
|
12
|
+
if (n > 0) {
|
|
13
|
+
return makeFinding(rule, m.width, "hint", `${n} of ${r.checked} control looks show no change ${under} ${PARTS}`, listed(r.unchanged));
|
|
14
|
+
}
|
|
15
|
+
return makeFinding(rule, m.width, "pass", `All ${r.checked} control looks change ${under}.`);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const alikeState = (key, what, peer) => (rule, m) => {
|
|
19
|
+
const r = m.states?.[key];
|
|
20
|
+
if (!r || !(r.checked > 0)) return null;
|
|
21
|
+
const n = r.alike.length;
|
|
22
|
+
if (n > 0) {
|
|
23
|
+
return makeFinding(
|
|
24
|
+
rule,
|
|
25
|
+
m.width,
|
|
26
|
+
"hint",
|
|
27
|
+
`${n} ${plural(n, `${what.one} looks`, `${what.many} look`)} exactly like ${peer}.`,
|
|
28
|
+
listed(r.alike.map((a) => `${a.control} looks like ${a.like}`)),
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
return makeFinding(rule, m.width, "pass", `${r.checked} ${plural(r.checked, what.one, what.many)} checked; none looks exactly like ${peer}.`);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const statesEvaluators = {
|
|
35
|
+
"states.hover": forcedState("hover", "under :hover"),
|
|
36
|
+
"states.active": forcedState("active", "when pressed (:active)"),
|
|
37
|
+
"states.disabled": alikeState("disabled", { one: "disabled control", many: "disabled controls" }, "an enabled one"),
|
|
38
|
+
"states.invalid": alikeState("invalid", { one: "field marked aria-invalid", many: "fields marked aria-invalid" }, "a valid one"),
|
|
39
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { makeFinding } from "../finding.mjs";
|
|
2
|
+
|
|
3
|
+
function value(rule, m) {
|
|
4
|
+
const s = m.style;
|
|
5
|
+
if (!s) return null;
|
|
6
|
+
const entry = s.rules?.[rule.id];
|
|
7
|
+
if (!entry) return null;
|
|
8
|
+
const t = rule.threshold ?? {};
|
|
9
|
+
const count = entry.offending ?? entry.offenders.length;
|
|
10
|
+
if (count > 0) {
|
|
11
|
+
const first = entry.offenders[0];
|
|
12
|
+
return makeFinding(
|
|
13
|
+
rule,
|
|
14
|
+
m.width,
|
|
15
|
+
"fail",
|
|
16
|
+
`${count} ${count === 1 ? "element" : "elements"} matching ${t.selector} have ${t.property} ${first?.value ?? ""}`.trimEnd(),
|
|
17
|
+
[
|
|
18
|
+
...new Set(entry.offenders.map((o) => o.selector)),
|
|
19
|
+
...(rule.origin === "project" && rule.source ? [`Learned rule from the person: ${rule.source}`] : []),
|
|
20
|
+
],
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
const compared = entry.compared ?? entry.checked;
|
|
24
|
+
if (compared > 0) {
|
|
25
|
+
return makeFinding(rule, m.width, "pass", `${compared} ${compared === 1 ? "element" : "elements"} matching ${t.selector} keep ${t.property} within the rule.`);
|
|
26
|
+
}
|
|
27
|
+
// Visible elements that could not be compared already carry a note from the measurer.
|
|
28
|
+
if (entry.checked > 0) return null;
|
|
29
|
+
const note = `${rule.id}: no visible element matches ${t.selector}`;
|
|
30
|
+
if (!Array.isArray(s.notes)) s.notes = [];
|
|
31
|
+
if (!s.notes.includes(note)) s.notes.push(note);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const styleEvaluators = { "style.value": value };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { makeFinding } from "../finding.mjs";
|
|
2
|
+
import { listed } from "../evidence.mjs";
|
|
3
|
+
import { BACKGROUNDS } from "../../measure/symbol.mjs";
|
|
4
|
+
|
|
5
|
+
const plural = (n, one, many) => (n === 1 ? one : many);
|
|
6
|
+
// A share in 0 to 1 as a percent with at most one decimal (0.035 gives 3.5, never 3.5000000000000004).
|
|
7
|
+
const pct = (x) => String(+(x * 100).toFixed(1));
|
|
8
|
+
// What was not compared (an opaque box, a raster, no stroke) is noted by the measurer; the evaluators then
|
|
9
|
+
// return null, never a vacuous pass.
|
|
10
|
+
|
|
11
|
+
function silhouette(rule, m) {
|
|
12
|
+
const r = m.symbol;
|
|
13
|
+
const p = rule.threshold?.minOverlap;
|
|
14
|
+
if (!r || !Array.isArray(r.silhouette) || r.silhouette.length === 0 || !Number.isFinite(p)) return null;
|
|
15
|
+
const under = r.silhouette.filter((x) => x.overlap < p);
|
|
16
|
+
if (under.length) {
|
|
17
|
+
return makeFinding(
|
|
18
|
+
rule,
|
|
19
|
+
m.width,
|
|
20
|
+
"hint",
|
|
21
|
+
`The silhouette keeps less than ${pct(p)}% of its large shape at ${under.map((x) => x.size).join(", ")} px.`,
|
|
22
|
+
listed(under.map((x) => `${x.size} px: ${pct(x.overlap)}% of the shape at ${r.ref} px`)),
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
const min = Math.min(...r.silhouette.map((x) => x.size));
|
|
26
|
+
return makeFinding(rule, m.width, "pass", `The silhouette keeps at least ${pct(p)}% of its large shape down to ${min} px.`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Parts of at least minPartShare of their file. A size draws every part when each such part of the file that
|
|
30
|
+
// renders it is kept there; the smallest such size counts only while every larger size draws every part too.
|
|
31
|
+
function detail(rule, m) {
|
|
32
|
+
const r = m.symbol;
|
|
33
|
+
const p = rule.threshold?.minPartShare;
|
|
34
|
+
if (!r || !Array.isArray(r.parts) || !Number.isFinite(p)) return null;
|
|
35
|
+
const parts = r.parts.filter((x) => x.share >= p);
|
|
36
|
+
if (parts.length === 0) return null;
|
|
37
|
+
const sizes = [...r.sizes].sort((a, b) => b - a);
|
|
38
|
+
const min = sizes.at(-1);
|
|
39
|
+
const lost = parts.filter((x) => x.lostAt.length > 0);
|
|
40
|
+
if (lost.length === 0) {
|
|
41
|
+
return makeFinding(rule, m.width, "pass", `Every part of the symbol of at least ${pct(p)}% of it is still drawn at ${min} px.`);
|
|
42
|
+
}
|
|
43
|
+
const drawsAll = (s) => parts.filter((x) => x.keptAt.includes(s) || x.lostAt.includes(s)).every((x) => x.keptAt.includes(s));
|
|
44
|
+
let smallest = null;
|
|
45
|
+
for (const s of sizes) {
|
|
46
|
+
if (!drawsAll(s)) break;
|
|
47
|
+
smallest = s;
|
|
48
|
+
}
|
|
49
|
+
const n = lost.length;
|
|
50
|
+
const head = `${n} ${plural(n, "part of the symbol is", "parts of the symbol are")} not drawn at small sizes`;
|
|
51
|
+
const tail = smallest !== null && smallest < r.ref ? `the smallest size that draws every part is ${smallest} px.` : `no size below ${r.ref} px draws every part.`;
|
|
52
|
+
return makeFinding(
|
|
53
|
+
rule,
|
|
54
|
+
m.width,
|
|
55
|
+
"hint",
|
|
56
|
+
`${head}; ${tail}`,
|
|
57
|
+
listed(lost.map((x) => `${x.hex} (${pct(x.share)}% of the symbol) is gone at ${x.lostAt.join(", ")} px`)),
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function stroke(rule, m) {
|
|
62
|
+
const r = m.symbol;
|
|
63
|
+
const min = rule.threshold?.minStrokePx;
|
|
64
|
+
if (!r || !Array.isArray(r.strokes) || r.strokes.length === 0 || !Array.isArray(r.thinnest) || r.thinnest.length === 0 || !Number.isFinite(min)) return null;
|
|
65
|
+
const under = r.thinnest.filter((x) => x.px < min);
|
|
66
|
+
if (under.length) {
|
|
67
|
+
return makeFinding(
|
|
68
|
+
rule,
|
|
69
|
+
m.width,
|
|
70
|
+
"hint",
|
|
71
|
+
`Strokes go under ${min} px at ${under.map((x) => x.size).join(", ")} px.`,
|
|
72
|
+
listed(under.map((x) => `${x.size} px: ${x.selector} is ${x.px} px`)),
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
const smallest = Math.min(...r.thinnest.map((x) => x.size));
|
|
76
|
+
return makeFinding(rule, m.width, "pass", `Every stroke stays at ${min} px or more down to ${smallest} px.`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// The message names each background under the cutoff with its count of sizes; the evidence lists each
|
|
80
|
+
// background and size.
|
|
81
|
+
function contrast(rule, m) {
|
|
82
|
+
const r = m.symbol;
|
|
83
|
+
const min = rule.threshold?.minContrast;
|
|
84
|
+
if (!r || !Array.isArray(r.contrast) || !Number.isFinite(min)) return null;
|
|
85
|
+
const read = r.contrast.filter((x) => x.median !== null);
|
|
86
|
+
if (read.length === 0) return null;
|
|
87
|
+
const under = read.filter((x) => x.median < min);
|
|
88
|
+
if (under.length) {
|
|
89
|
+
const on = BACKGROUNDS.map((b) => {
|
|
90
|
+
const n = new Set(under.filter((x) => x.background === b.name).map((x) => x.size)).size;
|
|
91
|
+
return n > 0 ? `on ${b.name} (${b.hex}) at ${n} ${plural(n, "size", "sizes")}` : null;
|
|
92
|
+
}).filter(Boolean);
|
|
93
|
+
return makeFinding(
|
|
94
|
+
rule,
|
|
95
|
+
m.width,
|
|
96
|
+
"hint",
|
|
97
|
+
`Half of the symbol's edge is under ${min}:1 ${on.join(" and ")}.`,
|
|
98
|
+
listed(under.map((x) => `On ${x.background} (${x.hex}) at ${x.size} px: median edge contrast ${x.median}:1`)),
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
const on = BACKGROUNDS.map((b) => `${b.name} (${b.hex})`).join(" and ");
|
|
102
|
+
return makeFinding(rule, m.width, "pass", `Half of the symbol's edge or more reaches ${min}:1 on ${on} at every size.`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export const symbolEvaluators = {
|
|
106
|
+
"symbol.silhouette": silhouette,
|
|
107
|
+
"symbol.detail": detail,
|
|
108
|
+
"symbol.stroke": stroke,
|
|
109
|
+
"symbol.contrast": contrast,
|
|
110
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { makeFinding } from "../finding.mjs";
|
|
2
|
+
import { listed } from "../evidence.mjs";
|
|
3
|
+
import { joined, onScreens, screenNames } from "./coherence.mjs";
|
|
4
|
+
|
|
5
|
+
const plural = (n, one, many) => (n === 1 ? one : many);
|
|
6
|
+
// What was not compared is noted by the measurer; the evaluators then return null, never a vacuous pass.
|
|
7
|
+
|
|
8
|
+
function sameTarget(rule, m) {
|
|
9
|
+
const r = m.terms;
|
|
10
|
+
if (!r || !Array.isArray(r.destinations) || r.destinations.length === 0) return null;
|
|
11
|
+
const names = screenNames(r.screens ?? []);
|
|
12
|
+
const paths = screenNames(r.destinations.map((d) => d.href));
|
|
13
|
+
const divergent = r.destinations.map((d, i) => ({ d, path: paths[i] })).filter(({ d }) => d.names.length >= 2);
|
|
14
|
+
const n = divergent.length;
|
|
15
|
+
if (n > 0) {
|
|
16
|
+
return makeFinding(
|
|
17
|
+
rule,
|
|
18
|
+
m.width,
|
|
19
|
+
"hint",
|
|
20
|
+
`${n} ${plural(n, "destination is", "destinations are")} named in more than one way: ${joined(divergent.map((x) => x.path))}.`,
|
|
21
|
+
listed(divergent.map(({ d, path }) => `${path}: ${d.names.map((x) => `"${x.name}" on ${onScreens(names, x.screens)}`).join("; ")}`)),
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
const k = r.destinations.length;
|
|
25
|
+
return makeFinding(rule, m.width, "pass", `Each of the ${k} ${plural(k, "destination", "destinations")} linked from navigation more than once keeps one name.`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function spelling(rule, m) {
|
|
29
|
+
const r = m.terms;
|
|
30
|
+
if (!r || !Number.isFinite(r.words) || r.words === 0) return null;
|
|
31
|
+
const list = Array.isArray(r.spellings) ? r.spellings : [];
|
|
32
|
+
if (list.length > 0) {
|
|
33
|
+
const names = screenNames(r.screens ?? []);
|
|
34
|
+
const n = list.length;
|
|
35
|
+
return makeFinding(
|
|
36
|
+
rule,
|
|
37
|
+
m.width,
|
|
38
|
+
"hint",
|
|
39
|
+
`${n} ${plural(n, "term is", "terms are")} written in more than one way: ${list.map((s) => joined(s.forms.map((f) => `"${f.form}"`))).join("; ")}.`,
|
|
40
|
+
listed(list.map((s) => s.forms.map((f) => `"${f.form}" on ${onScreens(names, f.screens)} (${f.count})`).join("; "))),
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
return makeFinding(rule, m.width, "pass", `No term among ${r.words} distinct words is written in two ways.`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const termsEvaluators = {
|
|
47
|
+
"terms.same-target": sameTarget,
|
|
48
|
+
"terms.spelling": spelling,
|
|
49
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { makeFinding } from "../finding.mjs";
|
|
2
|
+
|
|
3
|
+
const clip = (s, n = 40) => (s.length > n ? `${s.slice(0, n - 3)}...` : s);
|
|
4
|
+
const hasNumbers = (t, keys) => t && typeof t === "object" && keys.every((k) => Number.isFinite(t[k]));
|
|
5
|
+
const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
6
|
+
const blockLabel = (b) => `${b.selector}: ${b.charsPerLine} characters per line over ${b.lines} lines`;
|
|
7
|
+
|
|
8
|
+
function families(rule, m) {
|
|
9
|
+
if (!m.type) return null;
|
|
10
|
+
const t = rule.threshold;
|
|
11
|
+
if (!hasNumbers(t, ["maxFamilies"])) return null;
|
|
12
|
+
const list = m.type.families ?? [];
|
|
13
|
+
if (list.length === 0) return null;
|
|
14
|
+
if (list.length <= t.maxFamilies) {
|
|
15
|
+
return makeFinding(rule, m.width, "pass", `${plural(list.length, "font family", "font families")} rendered, within the limit of ${t.maxFamilies}.`);
|
|
16
|
+
}
|
|
17
|
+
const evidence = list.slice(0, 8).map((f) => `${f.family}: ${f.glyphs} glyphs`);
|
|
18
|
+
return makeFinding(
|
|
19
|
+
rule,
|
|
20
|
+
m.width,
|
|
21
|
+
"hint",
|
|
22
|
+
`${plural(list.length, "font family", "font families")} rendered, above the limit of ${t.maxFamilies}.`,
|
|
23
|
+
evidence,
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function fallback(rule, m) {
|
|
28
|
+
if (!m.type) return null;
|
|
29
|
+
const list = m.type.fallbacks ?? [];
|
|
30
|
+
if (list.length === 0) return makeFinding(rule, m.width, "pass", "Every named first font family was rendered.");
|
|
31
|
+
const evidence = list.slice(0, 5).map((f) => `${f.selector} asks for ${f.declared} and rendered ${f.rendered.join(", ")}`);
|
|
32
|
+
return makeFinding(
|
|
33
|
+
rule,
|
|
34
|
+
m.width,
|
|
35
|
+
"hint",
|
|
36
|
+
`${plural(list.length, "text style")} rendered in a fallback instead of the declared first font family.`,
|
|
37
|
+
evidence,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function lineLength(rule, m) {
|
|
42
|
+
if (!m.type) return null;
|
|
43
|
+
const t = rule.threshold;
|
|
44
|
+
if (!hasNumbers(t, ["minChars", "maxChars", "minLines"])) return null;
|
|
45
|
+
// A block with fewer characters in all than minLines full lines at minChars is a caption, not running
|
|
46
|
+
// text: the cutoff is derived from the two rule values, not a third number.
|
|
47
|
+
const captionChars = t.minLines * t.minChars;
|
|
48
|
+
const total = (b) => (Number.isFinite(b.chars) ? b.chars : b.charsPerLine * b.lines);
|
|
49
|
+
const tall = (m.type.blocks ?? []).filter((b) => b.lines >= t.minLines);
|
|
50
|
+
const long = tall.filter((b) => total(b) >= captionChars);
|
|
51
|
+
const skipped = long.length < tall.length ? `; blocks under ${captionChars} characters in all were read as captions and not judged` : "";
|
|
52
|
+
if (long.length === 0) return null;
|
|
53
|
+
// Short lines are not the type's fault when a line as wide as the whole viewport could not hold the
|
|
54
|
+
// minimum at this block's size (its own measured character width).
|
|
55
|
+
const roomy = (b) => !(Number.isFinite(b.charAdvancePx) && b.charAdvancePx > 0 && Number.isFinite(m.width) && m.width / b.charAdvancePx < t.minChars);
|
|
56
|
+
const bad = long.filter((b) => (b.charsPerLine < t.minChars && roomy(b)) || b.charsPerLine > t.maxChars);
|
|
57
|
+
const judged = long.filter((b) => b.charsPerLine > t.maxChars || roomy(b));
|
|
58
|
+
if (judged.length === 0) return null;
|
|
59
|
+
if (bad.length === 0) {
|
|
60
|
+
return makeFinding(rule, m.width, "pass", `Line length is between ${t.minChars} and ${t.maxChars} characters in every block of ${t.minLines} lines or more${skipped}.`);
|
|
61
|
+
}
|
|
62
|
+
return makeFinding(
|
|
63
|
+
rule,
|
|
64
|
+
m.width,
|
|
65
|
+
"hint",
|
|
66
|
+
`${plural(bad.length, "text block")} with lines outside ${t.minChars} to ${t.maxChars} characters.`,
|
|
67
|
+
bad.slice(0, 5).map(blockLabel),
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function bodySize(rule, m) {
|
|
72
|
+
if (!m.type?.body) return null;
|
|
73
|
+
const t = rule.threshold;
|
|
74
|
+
if (!hasNumbers(t, ["minPx", "maxPx"])) return null;
|
|
75
|
+
const px = m.type.body.sizePx;
|
|
76
|
+
if (px >= t.minPx && px <= t.maxPx) {
|
|
77
|
+
return makeFinding(rule, m.width, "pass", `Body text is ${px} px, within ${t.minPx} to ${t.maxPx} px.`);
|
|
78
|
+
}
|
|
79
|
+
return makeFinding(rule, m.width, "hint", `Body text is ${px} px, outside ${t.minPx} to ${t.maxPx} px.`, [
|
|
80
|
+
`${m.type.body.selector}: ${px} px`,
|
|
81
|
+
]);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function lineHeight(rule, m) {
|
|
85
|
+
if (!m.type) return null;
|
|
86
|
+
const t = rule.threshold;
|
|
87
|
+
if (!hasNumbers(t, ["minRatio", "maxRatio"])) return null;
|
|
88
|
+
const multi = (m.type.blocks ?? []).filter((b) => b.lines >= 2);
|
|
89
|
+
if (multi.length === 0) return null;
|
|
90
|
+
const bad = multi.filter((b) => b.lineHeightRatio < t.minRatio || b.lineHeightRatio > t.maxRatio);
|
|
91
|
+
if (bad.length === 0) {
|
|
92
|
+
return makeFinding(rule, m.width, "pass", `Line height is between ${t.minRatio} and ${t.maxRatio} times the font size in every multi-line block.`);
|
|
93
|
+
}
|
|
94
|
+
return makeFinding(
|
|
95
|
+
rule,
|
|
96
|
+
m.width,
|
|
97
|
+
"hint",
|
|
98
|
+
`${plural(bad.length, "text block")} with a line height outside ${t.minRatio} to ${t.maxRatio} times the font size.`,
|
|
99
|
+
bad.slice(0, 5).map((b) => `${b.selector}: ${b.lineHeightRatio} at ${b.sizePx} px`),
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function scale(rule, m) {
|
|
104
|
+
if (!m.type) return null;
|
|
105
|
+
const t = rule.threshold;
|
|
106
|
+
if (!hasNumbers(t, ["minStepRatio"])) return null;
|
|
107
|
+
const { sizesPx = [], ratios = [] } = m.type.scale ?? {};
|
|
108
|
+
if (ratios.length === 0) return null;
|
|
109
|
+
const bad = ratios.map((r, i) => ({ r, from: sizesPx[i], to: sizesPx[i + 1] })).filter((x) => x.r < t.minStepRatio);
|
|
110
|
+
if (bad.length === 0) {
|
|
111
|
+
return makeFinding(rule, m.width, "pass", `Every step between neighboring sizes is at least ${t.minStepRatio} times.`);
|
|
112
|
+
}
|
|
113
|
+
return makeFinding(
|
|
114
|
+
rule,
|
|
115
|
+
m.width,
|
|
116
|
+
"hint",
|
|
117
|
+
`${plural(bad.length, "step")} between neighboring sizes below ${t.minStepRatio} times.`,
|
|
118
|
+
bad.slice(0, 5).map((x) => `${x.from} px to ${x.to} px is ${x.r} times`),
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function hierarchy(rule, m) {
|
|
123
|
+
if (!m.type) return null;
|
|
124
|
+
const headings = m.type.headings ?? [];
|
|
125
|
+
const inverted = [];
|
|
126
|
+
for (const high of headings) {
|
|
127
|
+
for (const low of headings) {
|
|
128
|
+
if (high.level < low.level && high.sizePx < low.sizePx) inverted.push([high, low]);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (inverted.length === 0) return makeFinding(rule, m.width, "pass", "No heading is smaller than a lower level heading.");
|
|
132
|
+
return makeFinding(
|
|
133
|
+
rule,
|
|
134
|
+
m.width,
|
|
135
|
+
"hint",
|
|
136
|
+
`${plural(inverted.length, "heading pair")} where a higher level renders smaller than a lower level.`,
|
|
137
|
+
inverted.slice(0, 5).map(([h, l]) => `h${h.level} (${h.sizePx} px) is smaller than h${l.level} (${l.sizePx} px)`),
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function headingRag(rule, m) {
|
|
142
|
+
if (!m.type) return null;
|
|
143
|
+
const bad = (m.type.headings ?? []).filter((h) => h.lines >= 2 && h.lastLineWords === 1);
|
|
144
|
+
if (bad.length === 0) return makeFinding(rule, m.width, "pass", "No heading ends on a line with a single word.");
|
|
145
|
+
return makeFinding(
|
|
146
|
+
rule,
|
|
147
|
+
m.width,
|
|
148
|
+
"hint",
|
|
149
|
+
`${plural(bad.length, "heading")} wrap${bad.length === 1 ? "s" : ""} to a last line with one word.`,
|
|
150
|
+
bad.slice(0, 5).map((h) => `${clip(h.selector)}: ${h.lines} lines, last line has 1 word`),
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export const typeEvaluators = {
|
|
155
|
+
"type.families": families,
|
|
156
|
+
"type.fallback": fallback,
|
|
157
|
+
"type.line-length": lineLength,
|
|
158
|
+
"type.body-size": bodySize,
|
|
159
|
+
"type.line-height": lineHeight,
|
|
160
|
+
"type.scale": scale,
|
|
161
|
+
"type.hierarchy": hierarchy,
|
|
162
|
+
"type.heading-rag": headingRag,
|
|
163
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { makeFinding } from "../finding.mjs";
|
|
2
|
+
|
|
3
|
+
// The opening of every weight.order message about a guessed main action (no data-primary).
|
|
4
|
+
const GUESS = "The first button-like element found";
|
|
5
|
+
|
|
6
|
+
// Where the main action sits against the first view, in page px, when the measure has it.
|
|
7
|
+
function place(p) {
|
|
8
|
+
if (![p.top, p.bottom, p.viewportPx].every(Number.isFinite)) return "";
|
|
9
|
+
return p.top < p.viewportPx
|
|
10
|
+
? ` Its bottom edge is at ${p.bottom} px of the ${p.viewportPx} px first view.`
|
|
11
|
+
: ` It starts at ${p.top} px, below the ${p.viewportPx} px first view.`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function weightOrder(rule, m) {
|
|
15
|
+
const w = m.weight;
|
|
16
|
+
if (!w) return null;
|
|
17
|
+
const p = w.primary;
|
|
18
|
+
if (!p) {
|
|
19
|
+
return makeFinding(rule, m.width, "hint", "No main action was detected in the first view. Mark it with data-primary.");
|
|
20
|
+
}
|
|
21
|
+
// Without data-primary the main action is a guess; say so instead of stating it as fact.
|
|
22
|
+
const who = p.explicit ? `The main action (${p.selector})` : `${GUESS} (${p.selector})`;
|
|
23
|
+
const exact = p.explicit ? "" : " Mark your main action with data-primary to make this exact.";
|
|
24
|
+
const where = place(p);
|
|
25
|
+
if (p.rank === null || p.rank === undefined) {
|
|
26
|
+
return makeFinding(rule, m.width, "hint", `${who} is not visible in the first view.${exact}${where}`);
|
|
27
|
+
}
|
|
28
|
+
if (p.rank > 1) {
|
|
29
|
+
const stronger = (w.order ?? []).slice(0, Math.min(3, p.rank - 1)).map((o) => o.label);
|
|
30
|
+
const list = stronger.length ? `; stronger: ${stronger.join(", ")}.` : ".";
|
|
31
|
+
return makeFinding(rule, m.width, "hint", `${who} ranks ${p.rank} in visual weight${list}${exact}${where}`);
|
|
32
|
+
}
|
|
33
|
+
return makeFinding(rule, m.width, "pass", `${who} is the most prominent element.${exact}${where}`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// When the main action is guessed (no data-primary) and the guess differs between widths (label or href), every
|
|
37
|
+
// weight.order finding on a guess gains one evidence line naming the guess at each width. Pure.
|
|
38
|
+
export function noteGuessChanges(findings, measures) {
|
|
39
|
+
const guesses = measures
|
|
40
|
+
.filter((m) => m.weight?.primary && !m.weight.primary.explicit)
|
|
41
|
+
.map((m) => ({ width: m.width, label: m.weight.primary.label, href: m.weight.primary.href ?? null }));
|
|
42
|
+
const differs = guesses.some((g) => g.label !== guesses[0].label || g.href !== guesses[0].href);
|
|
43
|
+
if (!differs) return findings;
|
|
44
|
+
const line = `The guessed main action differs between widths: ${guesses.map((g) => `"${g.label}" at ${g.width} px`).join(", ")}. Mark it with data-primary.`;
|
|
45
|
+
const guessed = new Set(guesses.map((g) => g.width));
|
|
46
|
+
return findings.map((f) =>
|
|
47
|
+
guessed.has(f.width) && f.message.startsWith(GUESS) ? { ...f, evidence: [...f.evidence, line] } : f,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const weightEvaluators = { "weight.order": weightOrder };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Display limit, not a rule cutoff: evidence lines shown per finding; a last line says how many were left out.
|
|
2
|
+
export const MAX_EVIDENCE = 5;
|
|
3
|
+
export const listed = (lines) =>
|
|
4
|
+
lines.length > MAX_EVIDENCE ? [...lines.slice(0, MAX_EVIDENCE), `and ${lines.length - MAX_EVIDENCE} more`] : lines;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// One finding per rule and width. fail only for norm and project rules; a hypothesis rule gives at most a hint.
|
|
2
|
+
export function makeFinding(rule, width, level, message, evidence = []) {
|
|
3
|
+
let final = level;
|
|
4
|
+
if (final === "fail" && ((rule.origin !== "norm" && rule.origin !== "project") || rule.status === "hypothesis")) final = "hint";
|
|
5
|
+
let tag = "";
|
|
6
|
+
if (rule.hypothesis && final === "hint") {
|
|
7
|
+
const ids = Array.isArray(rule.hypothesis) ? rule.hypothesis : [rule.hypothesis];
|
|
8
|
+
tag = ` (hypothesis ${[...ids, ...(rule.area ? [rule.area] : [])].join(", ")})`;
|
|
9
|
+
}
|
|
10
|
+
return { ruleId: rule.id, name: rule.name, area: rule.area, level: final, width, message: `${message}${tag}`, evidence };
|
|
11
|
+
}
|