medesign 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +152 -86
- package/SKILL.md +169 -0
- package/bin/medesign.js +130 -27
- package/data/cip/deliverables.csv +51 -0
- package/data/cip/industries.csv +21 -0
- package/data/cip/mockup-contexts.csv +21 -0
- package/data/cip/styles.csv +21 -0
- package/data/icon/styles.csv +16 -0
- package/data/logo/colors.csv +56 -0
- package/data/logo/industries.csv +56 -0
- package/data/logo/styles.csv +56 -0
- package/docs/architecture/v1.7-proposal.md +279 -0
- package/docs/audit/COMPETITIVE-BENCHMARK.md +101 -0
- package/docs/audit/INITIAL-SOURCE-AUDIT.md +89 -0
- package/docs/benchmark/BENCHMARK-SUITE.md +97 -0
- package/docs/roadmap/FRONTEND-DESIGN-SKILL-ROADMAP.md +277 -0
- package/examples/snapshots/cadastral-qaqc-slide-desktop-1440x900.png +0 -0
- package/examples/snapshots/cadastral-qaqc-slide-mobile-390x844.png +0 -0
- package/examples/snapshots/cadastral-qaqc-slide-tablet-820x1180.png +0 -0
- package/package.json +85 -81
- package/presets/metha/design-tokens.css +12 -12
- package/references/design-routing.md +96 -207
- package/references/quality-gate.md +1 -1
- package/references/slides-copywriting-formulas.md +5 -8
- package/references/slides-layout-patterns.md +8 -23
- package/references/slides-strategies.md +0 -10
- package/tests/browser-audit.js +24 -6
- package/tests/linter.js +131 -13
- package/tests/snapshot.js +5 -2
- package/tests/visual-testbed.html +682 -681
package/tests/linter.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* ME-DESIGN vNext — Verification Engine & Linter
|
|
5
|
-
* Static
|
|
5
|
+
* Static pattern-based rule verification for HTML / CSS / JSX
|
|
6
6
|
* Usage: node tests/linter.js <filepath> [--preset <name>] [--format text|json|sarif] [--config <path>]
|
|
7
7
|
*/
|
|
8
8
|
|
|
@@ -15,7 +15,7 @@ const args = process.argv.slice(2);
|
|
|
15
15
|
if (args.includes('--help') || args.includes('-h')) {
|
|
16
16
|
console.log(`
|
|
17
17
|
\x1b[1mME-DESIGN Linter (v${pkg.version})\x1b[0m
|
|
18
|
-
\x1b[90mStatic
|
|
18
|
+
\x1b[90mStatic pattern and heuristic auditing for HTML/CSS/JSX\x1b[0m
|
|
19
19
|
|
|
20
20
|
\x1b[1mUsage:\x1b[0m
|
|
21
21
|
medesign lint <file> [options]
|
|
@@ -88,28 +88,58 @@ for (const cfg of candidateConfigs) {
|
|
|
88
88
|
|
|
89
89
|
const content = fs.readFileSync(targetFile, 'utf8');
|
|
90
90
|
|
|
91
|
-
//
|
|
91
|
+
// Hard invariants are policy gates: user config and inline suppression cannot disable them.
|
|
92
|
+
const HARD_INVARIANT_RULES = new Set(['MD001', 'MD002', 'MD003', 'MD004', 'MD005']);
|
|
93
|
+
|
|
94
|
+
// Support inline suppression for advisory rules only.
|
|
92
95
|
let preprocessedCode = content
|
|
93
|
-
.replace(/\/\*\s*medesign-disable-next-line\s+[A-Za-z0-9_]
|
|
94
|
-
|
|
96
|
+
.replace(/\/\*\s*medesign-disable-next-line\s+([A-Za-z0-9_]+)\s*\*\/[\r\n]+[^\r\n]+/g, (match, ruleId) =>
|
|
97
|
+
HARD_INVARIANT_RULES.has(ruleId.toUpperCase()) ? match : '/* medesign-suppressed */')
|
|
98
|
+
.replace(/\/\*\s*medesign-disable\s+([A-Za-z0-9_]+)\s*\*\/([\s\S]*?)\/\*\s*medesign-enable\s+\1\s*\*\//g, (match, ruleId, body) =>
|
|
99
|
+
HARD_INVARIANT_RULES.has(ruleId.toUpperCase())
|
|
100
|
+
? body
|
|
101
|
+
: '/* medesign-suppressed */');
|
|
95
102
|
|
|
96
103
|
// Strip remaining comments so commentary does not trigger false positives or bypasses
|
|
97
104
|
const cleanCode = preprocessedCode
|
|
98
105
|
.replace(/\/\*[\s\S]*?\*\//g, '')
|
|
99
106
|
.replace(/<!--[\s\S]*?-->/g, '');
|
|
100
107
|
|
|
108
|
+
function findLocation(source, pattern) {
|
|
109
|
+
let idx = -1;
|
|
110
|
+
if (pattern instanceof RegExp) {
|
|
111
|
+
const m = pattern.exec(source);
|
|
112
|
+
if (m) idx = m.index;
|
|
113
|
+
} else if (typeof pattern === 'string') {
|
|
114
|
+
idx = source.indexOf(pattern);
|
|
115
|
+
}
|
|
116
|
+
if (idx < 0) return { line: 1, column: 1 };
|
|
117
|
+
const upTo = source.substring(0, idx);
|
|
118
|
+
const lines = upTo.split('\n');
|
|
119
|
+
const line = lines.length;
|
|
120
|
+
const column = lines[lines.length - 1].length + 1;
|
|
121
|
+
return { line, column };
|
|
122
|
+
}
|
|
123
|
+
|
|
101
124
|
const diagnostics = [];
|
|
102
125
|
|
|
103
126
|
// 1. RULE MD001: Focus Visibility (:focus-visible) - Hard Invariant
|
|
104
127
|
const hasFocusVisible = /:focus-visible/i.test(cleanCode) || /focus:outline/i.test(cleanCode) || /focus-visible:/i.test(cleanCode) || /outline:\s*2px/i.test(cleanCode);
|
|
105
128
|
if (!hasFocusVisible) {
|
|
129
|
+
const loc = findLocation(content, /:focus\b|<button\b/i);
|
|
106
130
|
diagnostics.push({
|
|
107
131
|
ruleId: 'MD001',
|
|
108
132
|
ruleName: 'FocusVisibility',
|
|
133
|
+
ruleClass: 'hard-invariant',
|
|
109
134
|
category: 'I',
|
|
110
|
-
severity: config.rules.MD001 || 'error',
|
|
135
|
+
severity: HARD_INVARIANT_RULES.has('MD001') ? 'error' : (config.rules.MD001 || 'error'),
|
|
111
136
|
hardInvariant: true,
|
|
137
|
+
confidence: 'high',
|
|
138
|
+
line: loc.line,
|
|
139
|
+
column: loc.column,
|
|
112
140
|
message: 'Missing visible focus indicator (:focus-visible) for interactive controls.',
|
|
141
|
+
explanation: 'Interactive controls without visible focus trap keyboard navigation users (WCAG 2.4.7).',
|
|
142
|
+
suggestedFix: 'Define :focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }',
|
|
113
143
|
remediation: 'Define :focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }'
|
|
114
144
|
});
|
|
115
145
|
}
|
|
@@ -118,13 +148,20 @@ if (!hasFocusVisible) {
|
|
|
118
148
|
const hasAnimations = /animation:|transition:/i.test(cleanCode) && !/transition:\s*none/i.test(cleanCode);
|
|
119
149
|
const hasReducedMotion = /prefers-reduced-motion/i.test(cleanCode);
|
|
120
150
|
if (hasAnimations && !hasReducedMotion) {
|
|
151
|
+
const loc = findLocation(content, /animation:|transition:/i);
|
|
121
152
|
diagnostics.push({
|
|
122
153
|
ruleId: 'MD002',
|
|
123
154
|
ruleName: 'ReducedMotionCompliance',
|
|
155
|
+
ruleClass: 'hard-invariant',
|
|
124
156
|
category: 'R',
|
|
125
|
-
severity: config.rules.MD002 || 'error',
|
|
157
|
+
severity: HARD_INVARIANT_RULES.has('MD002') ? 'error' : (config.rules.MD002 || 'error'),
|
|
126
158
|
hardInvariant: true,
|
|
159
|
+
confidence: 'high',
|
|
160
|
+
line: loc.line,
|
|
161
|
+
column: loc.column,
|
|
127
162
|
message: 'Animations/transitions detected without @media (prefers-reduced-motion) compliance gate.',
|
|
163
|
+
explanation: 'Animations and transitions without reduced-motion queries can trigger vestibular disorientation (WCAG 2.3.3).',
|
|
164
|
+
suggestedFix: 'Add @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }',
|
|
128
165
|
remediation: 'Add @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }'
|
|
129
166
|
});
|
|
130
167
|
}
|
|
@@ -132,13 +169,20 @@ if (hasAnimations && !hasReducedMotion) {
|
|
|
132
169
|
// 3. RULE MD003: Uncontrolled Button Scale / Hit Target Crush - Hard Invariant
|
|
133
170
|
const hasUncontrolledScale = /active:scale-9[0-5]/i.test(cleanCode) || /:active\s*\{\s*transform:\s*scale\(0\.9[0-5]\)/i.test(cleanCode);
|
|
134
171
|
if (hasUncontrolledScale) {
|
|
172
|
+
const loc = findLocation(content, /active:scale-9[0-5]|transform:\s*scale\(0\.9[0-5]\)/i);
|
|
135
173
|
diagnostics.push({
|
|
136
174
|
ruleId: 'MD003',
|
|
137
175
|
ruleName: 'IsolatedHitTarget',
|
|
176
|
+
ruleClass: 'hard-invariant',
|
|
138
177
|
category: 'G',
|
|
139
|
-
severity: config.rules.MD003 || 'error',
|
|
178
|
+
severity: HARD_INVARIANT_RULES.has('MD003') ? 'error' : (config.rules.MD003 || 'error'),
|
|
140
179
|
hardInvariant: true,
|
|
180
|
+
confidence: 'high',
|
|
181
|
+
line: loc.line,
|
|
182
|
+
column: loc.column,
|
|
141
183
|
message: 'Detected raw scale(0.90-0.95) directly on interactive button container, collapsing touch hit-target.',
|
|
184
|
+
explanation: 'Direct container scaling collapses the outer interactive touch area below 44px (WCAG 2.5.5 / 2.5.8).',
|
|
185
|
+
suggestedFix: 'Isolate outer 44px hit-target container and scale only the inner .visual-surface using clamp(0.96, 1 - 2.5/max(W,H), 0.995).',
|
|
142
186
|
remediation: 'Isolate outer 44px hit-target container and scale only the inner .visual-surface using clamp(0.96, 1 - 2.5/max(W,H), 0.995).'
|
|
143
187
|
});
|
|
144
188
|
}
|
|
@@ -147,13 +191,20 @@ if (hasUncontrolledScale) {
|
|
|
147
191
|
const hasButtons = /<button/i.test(cleanCode) || /class="[^"]*btn[^"]*"/i.test(cleanCode);
|
|
148
192
|
const hasInteractiveStates = /:hover/i.test(cleanCode) || /:active/i.test(cleanCode);
|
|
149
193
|
if (hasButtons && !hasInteractiveStates) {
|
|
194
|
+
const loc = findLocation(content, /<button|class="[^"]*btn[^"]*"/i);
|
|
150
195
|
diagnostics.push({
|
|
151
196
|
ruleId: 'MD004',
|
|
152
197
|
ruleName: 'InteractiveStateContract',
|
|
198
|
+
ruleClass: 'hard-invariant',
|
|
153
199
|
category: 'I',
|
|
154
|
-
severity: config.rules.MD004 || 'error',
|
|
200
|
+
severity: HARD_INVARIANT_RULES.has('MD004') ? 'error' : (config.rules.MD004 || 'error'),
|
|
155
201
|
hardInvariant: true,
|
|
202
|
+
confidence: 'high',
|
|
203
|
+
line: loc.line,
|
|
204
|
+
column: loc.column,
|
|
156
205
|
message: 'Buttons declared without defined interactive states (:hover / :active).',
|
|
206
|
+
explanation: 'Interactive controls without hover or pressed state feedback appear non-functional (WCAG 4.1.2).',
|
|
207
|
+
suggestedFix: 'Provide meaningful visual feedback for hover and active/pressed states.',
|
|
157
208
|
remediation: 'Provide meaningful visual feedback for hover and active/pressed states.'
|
|
158
209
|
});
|
|
159
210
|
}
|
|
@@ -162,23 +213,32 @@ if (hasButtons && !hasInteractiveStates) {
|
|
|
162
213
|
// In Windows High Contrast Mode, box-shadow is completely stripped by the browser. Focus MUST use physical outline.
|
|
163
214
|
const focusBlocks = cleanCode.match(/(?:button|a|\.[\w-]+)?:focus(?:-visible)?\s*\{[^}]+\}/gi) || [];
|
|
164
215
|
let hasBoxShadowOnlyFocus = false;
|
|
216
|
+
let offendingFocusBlock = null;
|
|
165
217
|
for (const block of focusBlocks) {
|
|
166
218
|
const hasOutline = /outline\s*:\s*(?!none|0px?)([^;}]+)/i.test(block);
|
|
167
219
|
const hasBoxShadow = /box-shadow\s*:/i.test(block);
|
|
168
220
|
const stripsOutline = /outline\s*:\s*(?:none|0px?)\s*(?:;|\})/i.test(block);
|
|
169
221
|
if (stripsOutline || (hasBoxShadow && !hasOutline)) {
|
|
170
222
|
hasBoxShadowOnlyFocus = true;
|
|
223
|
+
offendingFocusBlock = block;
|
|
171
224
|
break;
|
|
172
225
|
}
|
|
173
226
|
}
|
|
174
227
|
if (hasBoxShadowOnlyFocus) {
|
|
228
|
+
const loc = findLocation(content, offendingFocusBlock || /:focus/i);
|
|
175
229
|
diagnostics.push({
|
|
176
230
|
ruleId: 'MD005',
|
|
177
231
|
ruleName: 'HighContrastFocusRing',
|
|
232
|
+
ruleClass: 'hard-invariant',
|
|
178
233
|
category: 'I',
|
|
179
|
-
severity: config.rules.MD005 || 'error',
|
|
234
|
+
severity: HARD_INVARIANT_RULES.has('MD005') ? 'error' : (config.rules.MD005 || 'error'),
|
|
180
235
|
hardInvariant: true,
|
|
236
|
+
confidence: 'high',
|
|
237
|
+
line: loc.line,
|
|
238
|
+
column: loc.column,
|
|
181
239
|
message: 'Focus indicator relies on box-shadow or suppresses outline without replacement. In Windows High Contrast (forced-colors: active), box-shadow is stripped, causing total focus ring loss.',
|
|
240
|
+
explanation: 'Windows High Contrast Mode strips CSS box-shadow, resulting in invisible focus rings if outline is disabled.',
|
|
241
|
+
suggestedFix: 'Always specify a physical outline in focus styles: :focus-visible { outline: 2px solid Highlight; outline-offset: 2px; }',
|
|
182
242
|
remediation: 'Always specify a physical outline in focus styles: :focus-visible { outline: 2px solid Highlight; outline-offset: 2px; }'
|
|
183
243
|
});
|
|
184
244
|
}
|
|
@@ -186,13 +246,20 @@ if (hasBoxShadowOnlyFocus) {
|
|
|
186
246
|
// 6. RULE MD101: Dense Grid on Data Dashboards - Soft Heuristic (Warning)
|
|
187
247
|
const hasDenseGrid = /grid-auto-flow:\s*dense/i.test(cleanCode);
|
|
188
248
|
if (hasDenseGrid) {
|
|
249
|
+
const loc = findLocation(content, /grid-auto-flow:\s*dense/i);
|
|
189
250
|
diagnostics.push({
|
|
190
251
|
ruleId: 'MD101',
|
|
191
252
|
ruleName: 'DenseGridTabSequence',
|
|
253
|
+
ruleClass: 'accessibility-requirement',
|
|
192
254
|
category: 'G',
|
|
193
255
|
severity: config.rules.MD101 || 'warning',
|
|
194
256
|
hardInvariant: false,
|
|
257
|
+
confidence: 'medium',
|
|
258
|
+
line: loc.line,
|
|
259
|
+
column: loc.column,
|
|
195
260
|
message: 'grid-auto-flow: dense may scramble DOM order away from keyboard tab order.',
|
|
261
|
+
explanation: 'Dense auto-flow packs elements into visual holes out of DOM sequence, violating logical reading order (WCAG 1.3.2 / 2.4.3).',
|
|
262
|
+
suggestedFix: 'Use grid-auto-flow: row with Named Grid Areas (grid-template-areas) for predictable data layouts.',
|
|
196
263
|
remediation: 'Use grid-auto-flow: row with Named Grid Areas (grid-template-areas) for predictable data layouts.'
|
|
197
264
|
});
|
|
198
265
|
}
|
|
@@ -201,13 +268,20 @@ if (hasDenseGrid) {
|
|
|
201
268
|
const hasGradient = /linear-gradient\(/i.test(cleanCode);
|
|
202
269
|
const hasOklchOklab = /linear-gradient\([^)]*\bin\s+(oklch|oklab)/i.test(cleanCode);
|
|
203
270
|
if (hasGradient && !hasOklchOklab) {
|
|
271
|
+
const loc = findLocation(content, /linear-gradient\(/i);
|
|
204
272
|
diagnostics.push({
|
|
205
273
|
ruleId: 'MD102',
|
|
206
274
|
ruleName: 'PerceptualColorInterpolation',
|
|
275
|
+
ruleClass: 'visual-quality-heuristic',
|
|
207
276
|
category: 'V',
|
|
208
277
|
severity: config.rules.MD102 || 'warning',
|
|
209
278
|
hardInvariant: false,
|
|
279
|
+
confidence: 'medium',
|
|
280
|
+
line: loc.line,
|
|
281
|
+
column: loc.column,
|
|
210
282
|
message: 'Gradients detected without modern perceptual interpolation space (in oklch / in oklab).',
|
|
283
|
+
explanation: 'Standard sRGB gradients pass through desaturated muddy gray intermediate hues due to non-uniform lightness.',
|
|
284
|
+
suggestedFix: 'Use linear-gradient(in oklch shorter hue ...) or linear-gradient(in oklab ...) to prevent middle-gray mud.',
|
|
211
285
|
remediation: 'Use linear-gradient(in oklch shorter hue ...) or linear-gradient(in oklab ...) to prevent middle-gray mud.'
|
|
212
286
|
});
|
|
213
287
|
}
|
|
@@ -216,13 +290,20 @@ if (hasGradient && !hasOklchOklab) {
|
|
|
216
290
|
const hasOuterRadius = /border-radius:\s*\d+px/i.test(cleanCode);
|
|
217
291
|
const hasInnerConcentric = /max\(\s*0px/i.test(cleanCode) || /calc\(infinity/i.test(cleanCode) || /--corner-r/i.test(cleanCode);
|
|
218
292
|
if (hasOuterRadius && !hasInnerConcentric) {
|
|
293
|
+
const loc = findLocation(content, /border-radius:\s*\d+px/i);
|
|
219
294
|
diagnostics.push({
|
|
220
295
|
ruleId: 'MD103',
|
|
221
296
|
ruleName: 'ConcentricRadiusMath',
|
|
297
|
+
ruleClass: 'visual-quality-heuristic',
|
|
222
298
|
category: 'G',
|
|
223
299
|
severity: config.rules.MD103 || 'info',
|
|
224
300
|
hardInvariant: false,
|
|
301
|
+
confidence: 'medium',
|
|
302
|
+
line: loc.line,
|
|
303
|
+
column: loc.column,
|
|
225
304
|
message: 'Consider applying Safe Concentric Radius formula max(0px, r_outer - border_w - pad) for nested cards.',
|
|
305
|
+
explanation: 'Nested containers with equal border-radius suffer corner optical collision and clipped corners.',
|
|
306
|
+
suggestedFix: 'Ensure inner containers compute radius proportionally to avoid clipped corners.',
|
|
226
307
|
remediation: 'Ensure inner containers compute radius proportionally to avoid clipped corners.'
|
|
227
308
|
});
|
|
228
309
|
}
|
|
@@ -231,13 +312,20 @@ if (hasOuterRadius && !hasInnerConcentric) {
|
|
|
231
312
|
const hasRaw100vh = /(?:height|min-height|max-height)\s*:\s*100vh/i.test(cleanCode);
|
|
232
313
|
const hasDvhSvh = /100[ds]vh/i.test(cleanCode);
|
|
233
314
|
if (hasRaw100vh && !hasDvhSvh) {
|
|
315
|
+
const loc = findLocation(content, /(?:height|min-height|max-height)\s*:\s*100vh/i);
|
|
234
316
|
diagnostics.push({
|
|
235
317
|
ruleId: 'MD104',
|
|
236
318
|
ruleName: 'MobileViewportStability',
|
|
319
|
+
ruleClass: 'accessibility-requirement',
|
|
237
320
|
category: 'R',
|
|
238
321
|
severity: config.rules.MD104 || 'warning',
|
|
239
322
|
hardInvariant: false,
|
|
323
|
+
confidence: 'high',
|
|
324
|
+
line: loc.line,
|
|
325
|
+
column: loc.column,
|
|
240
326
|
message: '100vh viewport unit used without dynamic viewport fallback (100dvh/100svh). On mobile browsers, toolbar expansion causes vertical jumping.',
|
|
327
|
+
explanation: '100vh does not account for dynamic mobile browser chrome (address bar expansion), causing vertical scroll jumps.',
|
|
328
|
+
suggestedFix: 'Provide dynamic viewport unit: min-height: 100vh; min-height: 100dvh;',
|
|
241
329
|
remediation: 'Provide dynamic viewport unit: min-height: 100vh; min-height: 100dvh;'
|
|
242
330
|
});
|
|
243
331
|
}
|
|
@@ -245,13 +333,20 @@ if (hasRaw100vh && !hasDvhSvh) {
|
|
|
245
333
|
// 10. RULE MD105: Visual/DOM Order Scrambling - Soft Heuristic (Warning)
|
|
246
334
|
const hasOrderReverse = /flex-direction\s*:\s*(row|column)-reverse/i.test(cleanCode) || /\border\s*:\s*(-?[1-9]\d*)/i.test(cleanCode);
|
|
247
335
|
if (hasOrderReverse) {
|
|
336
|
+
const loc = findLocation(content, /flex-direction\s*:\s*(row|column)-reverse|\border\s*:\s*(-?[1-9]\d*)/i);
|
|
248
337
|
diagnostics.push({
|
|
249
338
|
ruleId: 'MD105',
|
|
250
339
|
ruleName: 'VisualDomSequenceScramble',
|
|
340
|
+
ruleClass: 'accessibility-requirement',
|
|
251
341
|
category: 'G',
|
|
252
342
|
severity: config.rules.MD105 || 'warning',
|
|
253
343
|
hardInvariant: false,
|
|
344
|
+
confidence: 'high',
|
|
345
|
+
line: loc.line,
|
|
346
|
+
column: loc.column,
|
|
254
347
|
message: 'Reverse flex-direction or CSS order detected. Reordering visual sequence without updating DOM order violates WCAG 1.3.2 and disorients keyboard users.',
|
|
348
|
+
explanation: 'CSS reverse layout or order creates a mismatch between reading/focus sequence and visual order (WCAG 1.3.2).',
|
|
349
|
+
suggestedFix: 'Reorder elements in HTML/DOM source directly rather than relying on reverse layout or CSS order.',
|
|
255
350
|
remediation: 'Reorder elements in HTML/DOM source directly rather than relying on reverse layout or CSS order.'
|
|
256
351
|
});
|
|
257
352
|
}
|
|
@@ -260,6 +355,7 @@ if (hasOrderReverse) {
|
|
|
260
355
|
// When an interactive slider or pill container has a rounded background, inner tracks must maintain >= 8px optical clearance.
|
|
261
356
|
const sliderPillBlocks = cleanCode.match(/(?:[a-zA-Z0-9_\-\.\#\:\*\,\[\]\="'>\s]+)?(?:slider|progress|scrubber|pill-track)\s*\{[^}]+\}/gi) || [];
|
|
262
357
|
let hasBoundaryCollision = false;
|
|
358
|
+
let offendingSliderBlock = null;
|
|
263
359
|
for (const block of sliderPillBlocks) {
|
|
264
360
|
const hasPillRadius = /border-radius\s*:\s*(?:var\(--radius-full\)|9999px|50%|[1-9]\d{1,}px)/i.test(block);
|
|
265
361
|
const hasVisibleBg = /background(?:-color)?\s*:\s*(?!none|transparent\b|rgba\(\s*0\s*,\s*0\s*,\s*0\s*,\s*0\s*\))/i.test(block);
|
|
@@ -267,17 +363,25 @@ for (const block of sliderPillBlocks) {
|
|
|
267
363
|
const hasOpticalPadding = /padding(?:-inline|-left|-right)?\s*:\s*(?:[^;}]*?(?:[8-9]px|[1-9]\d+px|var\(--padding))/i.test(block);
|
|
268
364
|
if (hasPillRadius && hasVisibleBg && hasMinHeightTarget && !hasOpticalPadding) {
|
|
269
365
|
hasBoundaryCollision = true;
|
|
366
|
+
offendingSliderBlock = block;
|
|
270
367
|
break;
|
|
271
368
|
}
|
|
272
369
|
}
|
|
273
370
|
if (hasBoundaryCollision) {
|
|
371
|
+
const loc = findLocation(content, offendingSliderBlock || /(?:slider|progress|scrubber|pill-track)\s*\{/i);
|
|
274
372
|
diagnostics.push({
|
|
275
373
|
ruleId: 'MD106',
|
|
276
374
|
ruleName: 'ContainerBoundaryClearance',
|
|
375
|
+
ruleClass: 'ux-heuristic',
|
|
277
376
|
category: 'G',
|
|
278
377
|
severity: config.rules.MD106 || 'warning',
|
|
279
378
|
hardInvariant: false,
|
|
379
|
+
confidence: 'medium',
|
|
380
|
+
line: loc.line,
|
|
381
|
+
column: loc.column,
|
|
280
382
|
message: 'Detected full-width slider/progress track inside a rounded container with background but zero optical padding, causing visual boundary collision.',
|
|
383
|
+
explanation: 'Track elements colliding with pill border radius create optical tension and imprecise drag handles.',
|
|
384
|
+
suggestedFix: 'Isolate outer 44px hit-target with transparent background, or provide horizontal optical padding (padding: 0 12px) to prevent the track from slamming into the curved border.',
|
|
281
385
|
remediation: 'Isolate outer 44px hit-target with transparent background, or provide horizontal optical padding (padding: 0 12px) to prevent the track from slamming into the curved border.'
|
|
282
386
|
});
|
|
283
387
|
}
|
|
@@ -286,13 +390,20 @@ if (hasBoundaryCollision) {
|
|
|
286
390
|
const visibleTextMatch = content.replace(/<script[\s\S]*?<\/script>/gi, '').replace(/<style[\s\S]*?<\/style>/gi, '');
|
|
287
391
|
const hasEmDash = /[—–]/.test(visibleTextMatch);
|
|
288
392
|
if (hasEmDash) {
|
|
393
|
+
const loc = findLocation(content, /[—–]/);
|
|
289
394
|
diagnostics.push({
|
|
290
395
|
ruleId: 'MD201',
|
|
291
396
|
ruleName: 'EditorialPunctuationHyphen',
|
|
397
|
+
ruleClass: 'optional-recommendation',
|
|
292
398
|
category: 'V',
|
|
293
399
|
severity: config.rules.MD201 || 'info',
|
|
294
400
|
hardInvariant: false,
|
|
401
|
+
confidence: 'high',
|
|
402
|
+
line: loc.line,
|
|
403
|
+
column: loc.column,
|
|
295
404
|
message: 'Detected em-dash (—) or en-dash (–) in rendered copy.',
|
|
405
|
+
explanation: 'Em-dash punctuation is an editorial tell from LLM prose generators; clean UI copy prefers hyphens or colons.',
|
|
406
|
+
suggestedFix: 'Consider replacing with hyphen (-) or colon for concise UI copywriting.',
|
|
296
407
|
remediation: 'Consider replacing with hyphen (-) or colon for concise UI copywriting.'
|
|
297
408
|
});
|
|
298
409
|
}
|
|
@@ -374,6 +485,10 @@ if (format === 'sarif') {
|
|
|
374
485
|
artifactLocation: {
|
|
375
486
|
uri: uri,
|
|
376
487
|
uriBaseId: '%SRCROOT%'
|
|
488
|
+
},
|
|
489
|
+
region: {
|
|
490
|
+
startLine: d.line || 1,
|
|
491
|
+
startColumn: d.column || 1
|
|
377
492
|
}
|
|
378
493
|
}
|
|
379
494
|
}
|
|
@@ -392,6 +507,8 @@ if (format === 'json') {
|
|
|
392
507
|
console.log(JSON.stringify({
|
|
393
508
|
file: targetFile,
|
|
394
509
|
preset: presetName,
|
|
510
|
+
analysisType: 'static-pattern-heuristic',
|
|
511
|
+
scoreType: 'static-heuristic',
|
|
395
512
|
qScore,
|
|
396
513
|
passed: isPassed,
|
|
397
514
|
scores: { H, I, G, R, V },
|
|
@@ -415,7 +532,7 @@ console.log(`${ANSI_CYAN}Design Quality & Governance Audit${ANSI_RESET}`);
|
|
|
415
532
|
console.log(`${ANSI_GRAY}────────────────────────────────────────${ANSI_RESET}`);
|
|
416
533
|
console.log(`Target ${path.basename(targetFile)}`);
|
|
417
534
|
console.log(`Preset ${presetName.toUpperCase()}`);
|
|
418
|
-
console.log(`Analysis Static
|
|
535
|
+
console.log(`Analysis Static Pattern & Heuristic Rules (Confidence Gated)`);
|
|
419
536
|
console.log(`Ruleset medesign-standard@${pkg.version}\n`);
|
|
420
537
|
|
|
421
538
|
console.log(`${ANSI_BOLD}QUALITY SCORE (Q = ${w.H}H + ${w.I}I + ${w.G}G + ${w.R}R + ${w.V}V)${ANSI_RESET}`);
|
|
@@ -426,7 +543,8 @@ console.log(` Responsive (R) ${R.toFixed(1)} / 100`);
|
|
|
426
543
|
console.log(` Visual Craft (V) ${V.toFixed(1)} / 100\n`);
|
|
427
544
|
|
|
428
545
|
const qScoreColor = isPassed ? ANSI_GREEN : ANSI_RED;
|
|
429
|
-
console.log(` ${ANSI_BOLD}Q-SCORE ${qScoreColor}${qScore.toFixed(1)} / 100${ANSI_RESET} [${isPassed ? 'PASS' : 'FAIL'}]
|
|
546
|
+
console.log(` ${ANSI_BOLD}Q-SCORE ${qScoreColor}${qScore.toFixed(1)} / 100${ANSI_RESET} [${isPassed ? 'PASS' : 'FAIL'}]`);
|
|
547
|
+
console.log(` ${ANSI_GRAY}(Note: Q-Score is a static pattern heuristic, not a direct measurement of rendered layout)${ANSI_RESET}\n`);
|
|
430
548
|
|
|
431
549
|
console.log(`${ANSI_BOLD}HARD INVARIANTS CHECKLIST${ANSI_RESET}`);
|
|
432
550
|
console.log(` ${hasFocusVisible ? ANSI_GREEN + 'PASS' : ANSI_RED + 'FAIL'}${ANSI_RESET} MD001: Keyboard Focus Ring Visibility (:focus-visible)`);
|
|
@@ -439,7 +557,7 @@ if (diagnostics.length > 0) {
|
|
|
439
557
|
console.log(`${ANSI_BOLD}FINDINGS (${diagnostics.length})${ANSI_RESET}`);
|
|
440
558
|
diagnostics.forEach(d => {
|
|
441
559
|
const sevColor = d.severity === 'error' ? ANSI_RED : (d.severity === 'warning' ? ANSI_YELLOW : ANSI_CYAN);
|
|
442
|
-
console.log(` ${sevColor}${d.severity.padEnd(7)}${ANSI_RESET} ${d.ruleId} ${d.message}`);
|
|
560
|
+
console.log(` ${sevColor}${d.severity.padEnd(7)}${ANSI_RESET} [${d.line}:${d.column}] ${d.ruleId} (${d.ruleClass}) ${d.message}`);
|
|
443
561
|
if (d.remediation) {
|
|
444
562
|
console.log(` ${ANSI_GRAY}-> Remediation: ${d.remediation}${ANSI_RESET}`);
|
|
445
563
|
}
|
package/tests/snapshot.js
CHANGED
|
@@ -128,7 +128,7 @@ class CDPClient {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
async connect() {
|
|
131
|
-
for (let i = 0; i <
|
|
131
|
+
for (let i = 0; i < 60; i++) {
|
|
132
132
|
try {
|
|
133
133
|
const r = await fetch(`http://127.0.0.1:${this.port}/json/version`);
|
|
134
134
|
if (r.ok) break;
|
|
@@ -184,7 +184,10 @@ async function captureSnapshots() {
|
|
|
184
184
|
'--no-sandbox',
|
|
185
185
|
'--disable-extensions',
|
|
186
186
|
'--mute-audio',
|
|
187
|
-
'--hide-scrollbars'
|
|
187
|
+
'--hide-scrollbars',
|
|
188
|
+
'--disable-dev-shm-usage',
|
|
189
|
+
'--disable-setuid-sandbox',
|
|
190
|
+
'--no-zygote'
|
|
188
191
|
]);
|
|
189
192
|
|
|
190
193
|
const allPresets = isOgOnly
|