@kerfjs/ui 5.0.0-beta.137 → 5.0.0-beta.138
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/ai/component-composition.schema.json +4 -0
- package/ai/public-api-signatures-v1.md +1 -1
- package/ai/webawesome-jsx-signatures-v1.md +1 -1
- package/analyzer/index.d.mts +15 -1
- package/analyzer/index.mjs +227 -23
- package/analyzer/report.schema.json +26 -1
- package/docs/ui-analyzer.md +21 -6
- package/doctor/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -456,6 +456,10 @@
|
|
|
456
456
|
"composed"
|
|
457
457
|
]
|
|
458
458
|
},
|
|
459
|
+
"role": {
|
|
460
|
+
"description": "Declare that this class starts an independent inset surface when CSS alone does not establish one.",
|
|
461
|
+
"enum": ["surface"]
|
|
462
|
+
},
|
|
459
463
|
"notes": {
|
|
460
464
|
"$ref": "#/$defs/stringList"
|
|
461
465
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Public API signatures for the UI authoring corpus
|
|
2
2
|
|
|
3
|
-
Generated from emitted declarations for `@kerfjs/ui@5.0.0-beta.
|
|
3
|
+
Generated from emitted declarations for `@kerfjs/ui@5.0.0-beta.138` and `kerfjs@5.0.0-beta.138`. This bounded reference covers only APIs used by the seven-task corpus. It is interface evidence, not an implementation or runtime guarantee.
|
|
4
4
|
|
|
5
5
|
## `@kerfjs/ui/css-values`
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Web Awesome JSX signatures for the UI authoring corpus
|
|
2
2
|
|
|
3
|
-
Generated from the emitted `@kerfjs/ui@5.0.0-beta.
|
|
3
|
+
Generated from the emitted `@kerfjs/ui@5.0.0-beta.138` declaration boundary. Import `@kerfjs/ui/webawesome` for type effects when authoring direct `wa-*` JSX. The module emits no runtime behavior and does not register custom elements.
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
import { KerfCustomElement } from 'kerfjs/jsx-runtime';
|
package/analyzer/index.d.mts
CHANGED
|
@@ -11,11 +11,19 @@ export interface UiAnalysisDiagnostic {
|
|
|
11
11
|
|
|
12
12
|
export interface UiAnalysisProfileDiagnostic {
|
|
13
13
|
code: `KUI-P${string}`;
|
|
14
|
+
severity?: 'error' | 'warning';
|
|
14
15
|
source?: string;
|
|
15
16
|
path: string;
|
|
16
17
|
message: string;
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
export interface UiAnalysisSuppressedDiagnostic {
|
|
21
|
+
ruleId: `KUI-L${string}`;
|
|
22
|
+
location: { file: string; line: number; column: number };
|
|
23
|
+
exceptionId: string;
|
|
24
|
+
consumer: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
19
27
|
export interface UiAnalysisReport {
|
|
20
28
|
schemaVersion: 1;
|
|
21
29
|
tool: { name: string; version: 1 };
|
|
@@ -26,7 +34,13 @@ export interface UiAnalysisReport {
|
|
|
26
34
|
diagnostics: UiAnalysisProfileDiagnostic[];
|
|
27
35
|
};
|
|
28
36
|
diagnostics: UiAnalysisDiagnostic[];
|
|
29
|
-
|
|
37
|
+
suppressed: UiAnalysisSuppressedDiagnostic[];
|
|
38
|
+
summary: {
|
|
39
|
+
errors: number;
|
|
40
|
+
warnings: number;
|
|
41
|
+
review: number;
|
|
42
|
+
suppressed: number;
|
|
43
|
+
};
|
|
30
44
|
}
|
|
31
45
|
|
|
32
46
|
export const UI_ANALYSIS_SCHEMA_VERSION: 1;
|
package/analyzer/index.mjs
CHANGED
|
@@ -245,9 +245,9 @@ function diagnostic(ruleId, at, message, evidence, chain, adoption = false) {
|
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
function
|
|
248
|
+
function suppressingException(item, profile, root) {
|
|
249
249
|
const target = relative(root, item.location.file).replaceAll('\\', '/');
|
|
250
|
-
return (profile?.exceptions ?? []).
|
|
250
|
+
return (profile?.exceptions ?? []).find(
|
|
251
251
|
(exception) =>
|
|
252
252
|
exception.rules?.includes(item.ruleId) && exception.target === target,
|
|
253
253
|
);
|
|
@@ -303,9 +303,14 @@ function reachableStyleFacts(file, imports, styleFacts) {
|
|
|
303
303
|
const result = new Map();
|
|
304
304
|
for (const style of reachableStyleFiles(file, imports, styleFacts)) {
|
|
305
305
|
for (const [className, facts] of styleFacts.get(style)) {
|
|
306
|
-
const current = result.get(className) ?? {
|
|
306
|
+
const current = result.get(className) ?? {
|
|
307
|
+
scroll: false,
|
|
308
|
+
inset: false,
|
|
309
|
+
surface: false,
|
|
310
|
+
};
|
|
307
311
|
current.scroll ||= facts.scroll;
|
|
308
312
|
current.inset ||= facts.inset;
|
|
313
|
+
current.surface ||= facts.surface;
|
|
309
314
|
current.styled ??= facts.styled;
|
|
310
315
|
result.set(className, current);
|
|
311
316
|
}
|
|
@@ -981,6 +986,7 @@ async function inspectCss(
|
|
|
981
986
|
const record = cssFacts.get(className) ?? {
|
|
982
987
|
scroll: false,
|
|
983
988
|
inset: false,
|
|
989
|
+
surface: false,
|
|
984
990
|
};
|
|
985
991
|
record.styled ??= {
|
|
986
992
|
stylesheet: file,
|
|
@@ -1110,6 +1116,7 @@ async function inspectCss(
|
|
|
1110
1116
|
const record = cssFacts.get(className) ?? {
|
|
1111
1117
|
scroll: false,
|
|
1112
1118
|
inset: false,
|
|
1119
|
+
surface: false,
|
|
1113
1120
|
};
|
|
1114
1121
|
if (
|
|
1115
1122
|
/^overflow(?:-|$)/.test(decl.prop) &&
|
|
@@ -1118,13 +1125,73 @@ async function inspectCss(
|
|
|
1118
1125
|
record.scroll = true;
|
|
1119
1126
|
if (/^padding(?:-|$)/.test(decl.prop) && decl.value !== '0')
|
|
1120
1127
|
record.inset = true;
|
|
1128
|
+
if (
|
|
1129
|
+
/^(?:background(?:-color|-image)?|border(?:-(?:top|right|bottom|left))?|outline)$/.test(
|
|
1130
|
+
decl.prop,
|
|
1131
|
+
) &&
|
|
1132
|
+
!/^(?:0(?:px|rem|em)?(?:\s|$)|none\b|transparent\b|initial\b|inherit\b|unset\b|revert\b)/i.test(
|
|
1133
|
+
decl.value.trim(),
|
|
1134
|
+
)
|
|
1135
|
+
)
|
|
1136
|
+
record.surface = true;
|
|
1121
1137
|
cssFacts.set(className, record);
|
|
1122
1138
|
}
|
|
1123
1139
|
});
|
|
1124
1140
|
});
|
|
1125
1141
|
}
|
|
1126
1142
|
|
|
1127
|
-
function
|
|
1143
|
+
function finiteClassStrings(expression, finiteTypeValues, inTemplate = false) {
|
|
1144
|
+
if (!expression) return undefined;
|
|
1145
|
+
if (ts.isParenthesizedExpression(expression))
|
|
1146
|
+
return finiteClassStrings(
|
|
1147
|
+
expression.expression,
|
|
1148
|
+
finiteTypeValues,
|
|
1149
|
+
inTemplate,
|
|
1150
|
+
);
|
|
1151
|
+
if (ts.isStringLiteralLike(expression)) return [expression.text];
|
|
1152
|
+
if (ts.isConditionalExpression(expression)) {
|
|
1153
|
+
const yes = finiteClassStrings(
|
|
1154
|
+
expression.whenTrue,
|
|
1155
|
+
finiteTypeValues,
|
|
1156
|
+
inTemplate,
|
|
1157
|
+
);
|
|
1158
|
+
const no = finiteClassStrings(
|
|
1159
|
+
expression.whenFalse,
|
|
1160
|
+
finiteTypeValues,
|
|
1161
|
+
inTemplate,
|
|
1162
|
+
);
|
|
1163
|
+
return yes && no && yes.length + no.length <= 32
|
|
1164
|
+
? [...new Set([...yes, ...no])]
|
|
1165
|
+
: undefined;
|
|
1166
|
+
}
|
|
1167
|
+
const combine = (left, right) =>
|
|
1168
|
+
left && right && left.length * right.length <= 32
|
|
1169
|
+
? [...new Set(left.flatMap((a) => right.map((b) => a + b)))]
|
|
1170
|
+
: undefined;
|
|
1171
|
+
if (
|
|
1172
|
+
ts.isBinaryExpression(expression) &&
|
|
1173
|
+
expression.operatorToken.kind === ts.SyntaxKind.PlusToken
|
|
1174
|
+
)
|
|
1175
|
+
return combine(
|
|
1176
|
+
finiteClassStrings(expression.left, finiteTypeValues, inTemplate),
|
|
1177
|
+
finiteClassStrings(expression.right, finiteTypeValues, inTemplate),
|
|
1178
|
+
);
|
|
1179
|
+
if (ts.isTemplateExpression(expression)) {
|
|
1180
|
+
let values = [expression.head.text];
|
|
1181
|
+
for (const span of expression.templateSpans) {
|
|
1182
|
+
values = combine(
|
|
1183
|
+
values,
|
|
1184
|
+
finiteClassStrings(span.expression, finiteTypeValues, true),
|
|
1185
|
+
);
|
|
1186
|
+
values = combine(values, [span.literal.text]);
|
|
1187
|
+
if (!values) return undefined;
|
|
1188
|
+
}
|
|
1189
|
+
return values;
|
|
1190
|
+
}
|
|
1191
|
+
return inTemplate ? finiteTypeValues?.(expression) : undefined;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
function literalClasses(attribute, finiteTypeValues) {
|
|
1128
1195
|
if (!attribute?.initializer) return { values: [], dynamic: false };
|
|
1129
1196
|
const value = attribute.initializer;
|
|
1130
1197
|
if (ts.isStringLiteral(value))
|
|
@@ -1138,6 +1205,20 @@ function literalClasses(attribute) {
|
|
|
1138
1205
|
values: value.expression.text.split(/\s+/).filter(Boolean),
|
|
1139
1206
|
dynamic: false,
|
|
1140
1207
|
};
|
|
1208
|
+
if (ts.isJsxExpression(value) && value.expression) {
|
|
1209
|
+
const strings = finiteClassStrings(value.expression, finiteTypeValues);
|
|
1210
|
+
if (strings) {
|
|
1211
|
+
const values = [
|
|
1212
|
+
...new Set(
|
|
1213
|
+
strings.flatMap((item) => item.split(/\s+/).filter(Boolean)),
|
|
1214
|
+
),
|
|
1215
|
+
];
|
|
1216
|
+
return {
|
|
1217
|
+
values,
|
|
1218
|
+
dynamic: values.some((className) => /^(?:kui-|wa-)/.test(className)),
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1141
1222
|
return { values: [], dynamic: true };
|
|
1142
1223
|
}
|
|
1143
1224
|
|
|
@@ -1622,6 +1703,42 @@ function inspectTsx(
|
|
|
1622
1703
|
true,
|
|
1623
1704
|
ts.ScriptKind.TSX,
|
|
1624
1705
|
);
|
|
1706
|
+
let typedSource;
|
|
1707
|
+
let typeChecker;
|
|
1708
|
+
const finiteTypeValues = (expression) => {
|
|
1709
|
+
if (!typeChecker) {
|
|
1710
|
+
const program = ts.createProgram({
|
|
1711
|
+
rootNames: [file],
|
|
1712
|
+
options: { ...compilerOptions, noEmit: true, skipLibCheck: true },
|
|
1713
|
+
});
|
|
1714
|
+
typedSource = program.getSourceFile(file);
|
|
1715
|
+
typeChecker = program.getTypeChecker();
|
|
1716
|
+
}
|
|
1717
|
+
if (!typedSource) return undefined;
|
|
1718
|
+
const start = expression.getStart(source);
|
|
1719
|
+
const end = expression.getEnd();
|
|
1720
|
+
let typedNode;
|
|
1721
|
+
const find = (node) => {
|
|
1722
|
+
if (node.getStart(typedSource) === start && node.getEnd() === end) {
|
|
1723
|
+
typedNode = node;
|
|
1724
|
+
return;
|
|
1725
|
+
}
|
|
1726
|
+
ts.forEachChild(node, (child) => {
|
|
1727
|
+
if (!typedNode && child.pos <= start && child.end >= end) find(child);
|
|
1728
|
+
});
|
|
1729
|
+
};
|
|
1730
|
+
find(typedSource);
|
|
1731
|
+
if (!typedNode) return undefined;
|
|
1732
|
+
const type = typeChecker.getTypeAtLocation(typedNode);
|
|
1733
|
+
const members = type.isUnion() ? type.types : [type];
|
|
1734
|
+
if (members.length > 32) return undefined;
|
|
1735
|
+
const values = members.map((member) =>
|
|
1736
|
+
member.flags & ts.TypeFlags.StringLiteral ? member.value : undefined,
|
|
1737
|
+
);
|
|
1738
|
+
return values.every((value) => typeof value === 'string')
|
|
1739
|
+
? values
|
|
1740
|
+
: undefined;
|
|
1741
|
+
};
|
|
1625
1742
|
const imports = new Map();
|
|
1626
1743
|
const helperImports = new Map();
|
|
1627
1744
|
const namespaces = new Map();
|
|
@@ -1782,7 +1899,7 @@ function inspectTsx(
|
|
|
1782
1899
|
ts.isJsxAttribute(item) &&
|
|
1783
1900
|
['class', 'className'].includes(item.name.getText(source)),
|
|
1784
1901
|
);
|
|
1785
|
-
const classes = literalClasses(classAttribute);
|
|
1902
|
+
const classes = literalClasses(classAttribute, finiteTypeValues);
|
|
1786
1903
|
const at = location(file, opening, source);
|
|
1787
1904
|
if ((!entry && /^[a-z]/.test(tag)) || (componentMode && entry))
|
|
1788
1905
|
borrowedValues(
|
|
@@ -1866,6 +1983,15 @@ function inspectTsx(
|
|
|
1866
1983
|
const inset = classes.values.some(
|
|
1867
1984
|
(className) => cssFacts.get(className)?.inset,
|
|
1868
1985
|
);
|
|
1986
|
+
const surface =
|
|
1987
|
+
['input', 'select', 'textarea'].includes(tag) ||
|
|
1988
|
+
classes.values.some(
|
|
1989
|
+
(className) =>
|
|
1990
|
+
cssFacts.get(className)?.surface ||
|
|
1991
|
+
facts.classEntries
|
|
1992
|
+
.get(className)
|
|
1993
|
+
?.some((owner) => owner.layout?.geometry?.role === 'surface'),
|
|
1994
|
+
);
|
|
1869
1995
|
const parent = stack.at(-1);
|
|
1870
1996
|
if (scroll && parent?.scroll)
|
|
1871
1997
|
diagnostics.push(
|
|
@@ -1877,7 +2003,7 @@ function inspectTsx(
|
|
|
1877
2003
|
[parent.label, entry?.key ?? tag],
|
|
1878
2004
|
),
|
|
1879
2005
|
);
|
|
1880
|
-
if (inset && parent?.inset)
|
|
2006
|
+
if (inset && parent?.inset && !surface)
|
|
1881
2007
|
diagnostics.push(
|
|
1882
2008
|
diagnostic(
|
|
1883
2009
|
'KUI-L004',
|
|
@@ -2332,12 +2458,24 @@ function recordDiagnosticDecisions(
|
|
|
2332
2458
|
suppressed: false,
|
|
2333
2459
|
activeConsumers: new Set(),
|
|
2334
2460
|
suppressedConsumers: new Set(),
|
|
2461
|
+
suppressedMatches: new Map(),
|
|
2335
2462
|
};
|
|
2336
2463
|
const consumer =
|
|
2337
2464
|
relative(root, context.startDirectory).replaceAll('\\', '/') || '.';
|
|
2338
|
-
|
|
2465
|
+
const exception = suppressingException(
|
|
2466
|
+
item,
|
|
2467
|
+
context.profileResult.profile,
|
|
2468
|
+
workspaceRoot,
|
|
2469
|
+
);
|
|
2470
|
+
if (exception) {
|
|
2339
2471
|
decision.suppressed = true;
|
|
2340
2472
|
decision.suppressedConsumers.add(consumer);
|
|
2473
|
+
const source =
|
|
2474
|
+
context.profileResult.provenance[`$exceptions.${exception.id}`];
|
|
2475
|
+
decision.suppressedMatches.set(
|
|
2476
|
+
JSON.stringify([source, exception.id, consumer]),
|
|
2477
|
+
{ item, exceptionId: exception.id, consumer, source },
|
|
2478
|
+
);
|
|
2341
2479
|
} else {
|
|
2342
2480
|
decision.active = true;
|
|
2343
2481
|
decision.activeConsumers.add(consumer);
|
|
@@ -2488,13 +2626,23 @@ function resolveDiagnosticDecisions(diagnosticDecisions) {
|
|
|
2488
2626
|
const suppressed = [...diagnosticDecisions.values()].filter(
|
|
2489
2627
|
(decision) => !decision.active && decision.suppressed,
|
|
2490
2628
|
).length;
|
|
2629
|
+
const suppressedEntries = [...diagnosticDecisions.values()]
|
|
2630
|
+
.flatMap((decision) => [...decision.suppressedMatches.values()])
|
|
2631
|
+
.sort(
|
|
2632
|
+
(a, b) =>
|
|
2633
|
+
a.item.location.file.localeCompare(b.item.location.file) ||
|
|
2634
|
+
a.item.location.line - b.item.location.line ||
|
|
2635
|
+
a.item.ruleId.localeCompare(b.item.ruleId) ||
|
|
2636
|
+
a.exceptionId.localeCompare(b.exceptionId) ||
|
|
2637
|
+
a.consumer.localeCompare(b.consumer),
|
|
2638
|
+
);
|
|
2491
2639
|
active.sort(
|
|
2492
2640
|
(a, b) =>
|
|
2493
2641
|
a.location.file.localeCompare(b.location.file) ||
|
|
2494
2642
|
a.location.line - b.location.line ||
|
|
2495
2643
|
a.ruleId.localeCompare(b.ruleId),
|
|
2496
2644
|
);
|
|
2497
|
-
return { active, suppressed };
|
|
2645
|
+
return { active, suppressed, suppressedEntries };
|
|
2498
2646
|
}
|
|
2499
2647
|
|
|
2500
2648
|
// Phase 7 (reporting): the portable report — project-relative paths, the
|
|
@@ -2502,10 +2650,12 @@ function resolveDiagnosticDecisions(diagnosticDecisions) {
|
|
|
2502
2650
|
// diagnostics, and the summary counts.
|
|
2503
2651
|
async function buildAnalysisReport({
|
|
2504
2652
|
root,
|
|
2653
|
+
workspaceRoot,
|
|
2505
2654
|
files,
|
|
2506
2655
|
profileContexts,
|
|
2507
2656
|
active,
|
|
2508
2657
|
suppressed,
|
|
2658
|
+
suppressedEntries,
|
|
2509
2659
|
}) {
|
|
2510
2660
|
const portablePath = (file) => {
|
|
2511
2661
|
if (!file || !isAbsolute(file)) return file;
|
|
@@ -2523,22 +2673,66 @@ async function buildAnalysisReport({
|
|
|
2523
2673
|
),
|
|
2524
2674
|
];
|
|
2525
2675
|
const profilePackageRoot = dirname(profileFiles[0] ?? root);
|
|
2676
|
+
const usedExceptions = new Set(
|
|
2677
|
+
suppressedEntries.map(({ source, exceptionId }) =>
|
|
2678
|
+
JSON.stringify([source, exceptionId]),
|
|
2679
|
+
),
|
|
2680
|
+
);
|
|
2681
|
+
const analyzedFiles = new Set(files);
|
|
2682
|
+
const exceptionWarnings = [];
|
|
2683
|
+
const visitedExceptions = new Set();
|
|
2684
|
+
for (const { profileResult } of resolvedContexts)
|
|
2685
|
+
for (const [index, exception] of (
|
|
2686
|
+
profileResult.profile?.exceptions ?? []
|
|
2687
|
+
).entries()) {
|
|
2688
|
+
if (!exception?.id || typeof exception.target !== 'string') continue;
|
|
2689
|
+
const source = profileResult.provenance[`$exceptions.${exception.id}`];
|
|
2690
|
+
const key = JSON.stringify([source, exception.id]);
|
|
2691
|
+
if (visitedExceptions.has(key)) continue;
|
|
2692
|
+
visitedExceptions.add(key);
|
|
2693
|
+
const target = resolve(workspaceRoot, exception.target);
|
|
2694
|
+
const relativeTarget = relative(workspaceRoot, target);
|
|
2695
|
+
if (relativeTarget === '..' || relativeTarget.startsWith('../')) continue;
|
|
2696
|
+
const exists = await stat(target).then(
|
|
2697
|
+
(details) => details.isFile(),
|
|
2698
|
+
() => false,
|
|
2699
|
+
);
|
|
2700
|
+
if (!exists)
|
|
2701
|
+
exceptionWarnings.push({
|
|
2702
|
+
code: 'KUI-P031',
|
|
2703
|
+
severity: 'warning',
|
|
2704
|
+
source,
|
|
2705
|
+
path: `$.exceptions[${index}].target`,
|
|
2706
|
+
message: `Exception ${exception.id} names missing target ${exception.target}.`,
|
|
2707
|
+
});
|
|
2708
|
+
else if (analyzedFiles.has(target) && !usedExceptions.has(key))
|
|
2709
|
+
exceptionWarnings.push({
|
|
2710
|
+
code: 'KUI-P032',
|
|
2711
|
+
severity: 'warning',
|
|
2712
|
+
source,
|
|
2713
|
+
path: `$.exceptions[${index}]`,
|
|
2714
|
+
message: `Exception ${exception.id} suppressed no diagnostic in ${exception.target}.`,
|
|
2715
|
+
});
|
|
2716
|
+
}
|
|
2526
2717
|
const portableMessage = (message) =>
|
|
2527
2718
|
String(message)
|
|
2528
2719
|
.replaceAll(root, '<repo-root>')
|
|
2529
2720
|
.replaceAll(profilePackageRoot, '<package-root>');
|
|
2530
2721
|
const profileDiagnostics = [
|
|
2531
2722
|
...new Map(
|
|
2532
|
-
|
|
2533
|
-
.flatMap(
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2723
|
+
[
|
|
2724
|
+
...resolvedContexts.flatMap(
|
|
2725
|
+
({ profileResult }) => profileResult.diagnostics ?? [],
|
|
2726
|
+
),
|
|
2727
|
+
...exceptionWarnings,
|
|
2728
|
+
].map((item) => [
|
|
2729
|
+
JSON.stringify([item.code, item.source, item.path, item.message]),
|
|
2730
|
+
{
|
|
2731
|
+
...item,
|
|
2732
|
+
source: portablePath(item.source),
|
|
2733
|
+
message: portableMessage(item.message),
|
|
2734
|
+
},
|
|
2735
|
+
]),
|
|
2542
2736
|
).values(),
|
|
2543
2737
|
];
|
|
2544
2738
|
return {
|
|
@@ -2565,10 +2759,18 @@ async function buildAnalysisReport({
|
|
|
2565
2759
|
}
|
|
2566
2760
|
: {}),
|
|
2567
2761
|
})),
|
|
2762
|
+
suppressed: suppressedEntries.map(({ item, exceptionId, consumer }) => ({
|
|
2763
|
+
ruleId: item.ruleId,
|
|
2764
|
+
location: { ...item.location, file: portablePath(item.location.file) },
|
|
2765
|
+
exceptionId,
|
|
2766
|
+
consumer,
|
|
2767
|
+
})),
|
|
2568
2768
|
summary: {
|
|
2569
2769
|
errors:
|
|
2570
2770
|
active.filter((item) => item.severity === 'error').length +
|
|
2571
|
-
profileDiagnostics.length,
|
|
2771
|
+
profileDiagnostics.filter((item) => item.severity !== 'warning').length,
|
|
2772
|
+
warnings: profileDiagnostics.filter((item) => item.severity === 'warning')
|
|
2773
|
+
.length,
|
|
2572
2774
|
review: active.filter((item) => item.severity === 'review').length,
|
|
2573
2775
|
suppressed,
|
|
2574
2776
|
},
|
|
@@ -2655,21 +2857,23 @@ export async function analyzeUiProject({
|
|
|
2655
2857
|
ownership,
|
|
2656
2858
|
ownershipContext,
|
|
2657
2859
|
});
|
|
2658
|
-
const { active, suppressed } =
|
|
2860
|
+
const { active, suppressed, suppressedEntries } =
|
|
2659
2861
|
resolveDiagnosticDecisions(diagnosticDecisions);
|
|
2660
2862
|
return buildAnalysisReport({
|
|
2661
2863
|
root,
|
|
2864
|
+
workspaceRoot,
|
|
2662
2865
|
files,
|
|
2663
2866
|
profileContexts,
|
|
2664
2867
|
active,
|
|
2665
2868
|
suppressed,
|
|
2869
|
+
suppressedEntries,
|
|
2666
2870
|
});
|
|
2667
2871
|
}
|
|
2668
2872
|
|
|
2669
2873
|
export function formatUiAnalysisText(report) {
|
|
2670
2874
|
const lines = report.profile.diagnostics.map(
|
|
2671
2875
|
(item) =>
|
|
2672
|
-
`${item.source ?? '<profile>'}:1:1 error ${item.code} ${item.message}`,
|
|
2876
|
+
`${item.source ?? '<profile>'}:1:1 ${item.severity ?? 'error'} ${item.code} ${item.message}`,
|
|
2673
2877
|
);
|
|
2674
2878
|
lines.push(
|
|
2675
2879
|
...report.diagnostics.map(
|
|
@@ -2678,7 +2882,7 @@ export function formatUiAnalysisText(report) {
|
|
|
2678
2882
|
),
|
|
2679
2883
|
);
|
|
2680
2884
|
lines.push(
|
|
2681
|
-
`Kerf UI analysis: ${report.summary.errors} error(s), ${report.summary.review} review finding(s), ${report.summary.suppressed} suppressed.`,
|
|
2885
|
+
`Kerf UI analysis: ${report.summary.errors} error(s), ${report.summary.warnings} warning(s), ${report.summary.review} review finding(s), ${report.summary.suppressed} suppressed.`,
|
|
2682
2886
|
);
|
|
2683
2887
|
return lines.join('\n');
|
|
2684
2888
|
}
|
|
@@ -2702,7 +2906,7 @@ export function formatUiAnalysisSarif(report) {
|
|
|
2702
2906
|
results: [
|
|
2703
2907
|
...report.profile.diagnostics.map((item) => ({
|
|
2704
2908
|
ruleId: item.code,
|
|
2705
|
-
level: 'error',
|
|
2909
|
+
level: item.severity === 'warning' ? 'warning' : 'error',
|
|
2706
2910
|
message: { text: item.message },
|
|
2707
2911
|
locations: [
|
|
2708
2912
|
{
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"files",
|
|
11
11
|
"profile",
|
|
12
12
|
"diagnostics",
|
|
13
|
+
"suppressed",
|
|
13
14
|
"summary"
|
|
14
15
|
],
|
|
15
16
|
"properties": {
|
|
@@ -51,11 +52,35 @@
|
|
|
51
52
|
"additionalProperties": false
|
|
52
53
|
}
|
|
53
54
|
},
|
|
55
|
+
"suppressed": {
|
|
56
|
+
"type": "array",
|
|
57
|
+
"items": {
|
|
58
|
+
"type": "object",
|
|
59
|
+
"required": ["ruleId", "location", "exceptionId", "consumer"],
|
|
60
|
+
"properties": {
|
|
61
|
+
"ruleId": { "pattern": "^KUI-L[0-9]{3}$" },
|
|
62
|
+
"location": {
|
|
63
|
+
"type": "object",
|
|
64
|
+
"required": ["file", "line", "column"],
|
|
65
|
+
"properties": {
|
|
66
|
+
"file": { "type": "string" },
|
|
67
|
+
"line": { "type": "integer", "minimum": 1 },
|
|
68
|
+
"column": { "type": "integer", "minimum": 1 }
|
|
69
|
+
},
|
|
70
|
+
"additionalProperties": false
|
|
71
|
+
},
|
|
72
|
+
"exceptionId": { "type": "string" },
|
|
73
|
+
"consumer": { "type": "string" }
|
|
74
|
+
},
|
|
75
|
+
"additionalProperties": false
|
|
76
|
+
}
|
|
77
|
+
},
|
|
54
78
|
"summary": {
|
|
55
79
|
"type": "object",
|
|
56
|
-
"required": ["errors", "review", "suppressed"],
|
|
80
|
+
"required": ["errors", "warnings", "review", "suppressed"],
|
|
57
81
|
"properties": {
|
|
58
82
|
"errors": { "type": "integer", "minimum": 0 },
|
|
83
|
+
"warnings": { "type": "integer", "minimum": 0 },
|
|
59
84
|
"review": { "type": "integer", "minimum": 0 },
|
|
60
85
|
"suppressed": { "type": "integer", "minimum": 0 }
|
|
61
86
|
},
|
package/docs/ui-analyzer.md
CHANGED
|
@@ -128,6 +128,12 @@ if (report.summary.errors) process.exitCode = 1;
|
|
|
128
128
|
For `KUI-L004` and `KUI-L007`, scroll and inset declarations belong to the
|
|
129
129
|
subject of each CSS selector. An ancestor class used only to qualify a
|
|
130
130
|
descendant selector is not treated as a scroll owner or inset source.
|
|
131
|
+
`KUI-L004` treats an inner element with its own nontransparent background,
|
|
132
|
+
nonzero border, or outline as a separate inset surface. Native input, select,
|
|
133
|
+
and textarea elements also own their inset. If CSS cannot express that boundary,
|
|
134
|
+
an application composition entry can declare `layout.geometry.role: "surface"`
|
|
135
|
+
for the inner class; zero borders and transparent backgrounds do not establish
|
|
136
|
+
a surface.
|
|
131
137
|
|
|
132
138
|
Errors are provable contract violations and make the command exit 1. Review
|
|
133
139
|
findings are deliberately heuristic and do not fail by default; pass
|
|
@@ -434,12 +440,21 @@ The JSON report schema is exported as
|
|
|
434
440
|
`@kerfjs/ui/analyzer/report.schema.json`.
|
|
435
441
|
|
|
436
442
|
Profile discovery, parsing, catalog-loading, and validation diagnostics retain
|
|
437
|
-
their stable `KUI-P###` ids in every output format and count as errors.
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
+
their stable `KUI-P###` ids in every output format and count as errors. A
|
|
444
|
+
profile exception naming a missing target (`KUI-P031`) or suppressing no
|
|
445
|
+
finding in an analyzed target (`KUI-P032`) is a warning. The doctor gates these
|
|
446
|
+
with `failOn: "warning"`; a partial scan does not judge exceptions for files it
|
|
447
|
+
did not analyze. JSON reports also list each suppressed finding in
|
|
448
|
+
`suppressed[]` with its exception id, source location, and consumer. The
|
|
449
|
+
`summary.suppressed` count retains its meaning: findings suppressed for every
|
|
450
|
+
consumer.
|
|
451
|
+
|
|
452
|
+
The analyzer classifies conditional and template class expressions when every
|
|
453
|
+
possible value is a finite set of application-owned class names. A template
|
|
454
|
+
substitution can use a string-literal union type, such as `'user' | 'assistant'`
|
|
455
|
+
for `message--${role}`. Unconstrained strings and expressions that can produce
|
|
456
|
+
Kerf or Web Awesome classes still receive a review finding. CSS values
|
|
457
|
+
expressed through public variables or `calc()` are
|
|
443
458
|
also left to their owning token contract rather than reverse-engineered.
|
|
444
459
|
|
|
445
460
|
## Narrow exceptions
|
package/doctor/index.mjs
CHANGED
|
@@ -656,7 +656,7 @@ function normalizeAnalyzer(report) {
|
|
|
656
656
|
...report.profile.diagnostics.map((item) =>
|
|
657
657
|
normalizedDiagnostic({
|
|
658
658
|
id: item.code,
|
|
659
|
-
severity: 'error',
|
|
659
|
+
severity: item.severity ?? 'error',
|
|
660
660
|
stage: 'analyzer',
|
|
661
661
|
message: item.message,
|
|
662
662
|
location: { file: item.source, line: 1, column: 1, path: item.path },
|