dealsystem 0.0.1 → 0.2.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 +64 -2
- package/dist/api/errors.d.ts +25 -0
- package/dist/api/errors.js +38 -0
- package/dist/api/http.d.ts +56 -0
- package/dist/api/http.js +406 -0
- package/dist/api/legal.d.ts +9 -0
- package/dist/api/legal.js +20 -0
- package/dist/api/oauth.d.ts +35 -0
- package/dist/api/oauth.js +113 -0
- package/dist/api/types.d.ts +142 -0
- package/dist/api/types.js +9 -0
- package/dist/auth/credentials.d.ts +28 -0
- package/dist/auth/credentials.js +96 -0
- package/dist/auth/session.d.ts +10 -0
- package/dist/auth/session.js +46 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +4 -0
- package/dist/check/allowlist.d.ts +9 -0
- package/dist/check/allowlist.js +74 -0
- package/dist/check/catalog.d.ts +6 -0
- package/dist/check/catalog.js +410 -0
- package/dist/check/context.d.ts +79 -0
- package/dist/check/context.js +230 -0
- package/dist/check/fileset.d.ts +19 -0
- package/dist/check/fileset.js +91 -0
- package/dist/check/format.d.ts +25 -0
- package/dist/check/format.js +79 -0
- package/dist/check/index.d.ts +8 -0
- package/dist/check/index.js +9 -0
- package/dist/check/rule.d.ts +15 -0
- package/dist/check/rule.js +6 -0
- package/dist/check/rules/a11y.d.ts +3 -0
- package/dist/check/rules/a11y.js +433 -0
- package/dist/check/rules/privacy.d.ts +9 -0
- package/dist/check/rules/privacy.js +437 -0
- package/dist/check/rules/quality.d.ts +11 -0
- package/dist/check/rules/quality.js +451 -0
- package/dist/check/rules/schedule.d.ts +2 -0
- package/dist/check/rules/schedule.js +30 -0
- package/dist/check/rules/security.d.ts +18 -0
- package/dist/check/rules/security.js +744 -0
- package/dist/check/rules/structure.d.ts +2 -0
- package/dist/check/rules/structure.js +399 -0
- package/dist/check/run.d.ts +15 -0
- package/dist/check/run.js +147 -0
- package/dist/check/sdk.d.ts +56 -0
- package/dist/check/sdk.js +58 -0
- package/dist/check/types.d.ts +116 -0
- package/dist/check/types.js +2 -0
- package/dist/check/util/code.d.ts +19 -0
- package/dist/check/util/code.js +113 -0
- package/dist/check/util/color.d.ts +10 -0
- package/dist/check/util/color.js +53 -0
- package/dist/check/util/csp.d.ts +71 -0
- package/dist/check/util/csp.js +229 -0
- package/dist/check/util/html.d.ts +31 -0
- package/dist/check/util/html.js +65 -0
- package/dist/check/util/lines.d.ts +1 -0
- package/dist/check/util/lines.js +2 -0
- package/dist/check/util/literal.d.ts +1 -0
- package/dist/check/util/literal.js +3 -0
- package/dist/check/util/svelte.d.ts +42 -0
- package/dist/check/util/svelte.js +109 -0
- package/dist/cli/context.d.ts +40 -0
- package/dist/cli/context.js +107 -0
- package/dist/cli/io.d.ts +26 -0
- package/dist/cli/io.js +68 -0
- package/dist/cli/main.d.ts +24 -0
- package/dist/cli/main.js +269 -0
- package/dist/commands/check.d.ts +4 -0
- package/dist/commands/check.js +54 -0
- package/dist/commands/deploy.d.ts +20 -0
- package/dist/commands/deploy.js +315 -0
- package/dist/commands/dev.d.ts +29 -0
- package/dist/commands/dev.js +149 -0
- package/dist/commands/image.d.ts +12 -0
- package/dist/commands/image.js +291 -0
- package/dist/commands/login.d.ts +3 -0
- package/dist/commands/login.js +116 -0
- package/dist/commands/pull.d.ts +12 -0
- package/dist/commands/pull.js +178 -0
- package/dist/commands/site.d.ts +9 -0
- package/dist/commands/site.js +84 -0
- package/dist/commands/sync.d.ts +2 -0
- package/dist/commands/sync.js +126 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/project/agentFiles.d.ts +17 -0
- package/dist/project/agentFiles.js +156 -0
- package/dist/project/agentsBlock.d.ts +2 -0
- package/dist/project/agentsBlock.js +14 -0
- package/dist/project/siteConfig.d.ts +5 -0
- package/dist/project/siteConfig.js +35 -0
- package/dist/project/snapshot.d.ts +21 -0
- package/dist/project/snapshot.js +125 -0
- package/dist/project/svelteConfig.d.ts +4 -0
- package/dist/project/svelteConfig.js +74 -0
- package/dist/project/tar.d.ts +8 -0
- package/dist/project/tar.js +89 -0
- package/dist/project/untar.d.ts +27 -0
- package/dist/project/untar.js +232 -0
- package/dist/project/uploadFiles.d.ts +17 -0
- package/dist/project/uploadFiles.js +55 -0
- package/package.json +63 -7
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
// A11Y-*: statisch prüfbare Teile von WCAG 2.1 AA. axe-core folgt in Phase 2 (Stufe `browser`).
|
|
2
|
+
import { routeOfPage } from '../context.js';
|
|
3
|
+
import { outputRule, sourceRule } from '../rule.js';
|
|
4
|
+
import { COMPONENT } from '../sdk.js';
|
|
5
|
+
import { findAll } from '../util/code.js';
|
|
6
|
+
import { contrastRatio, parseColor } from '../util/color.js';
|
|
7
|
+
import { ancestors, isHidden, lineOf, parseHtml, textContent, } from '../util/html.js';
|
|
8
|
+
import { getAttr, hasSpread } from '../util/svelte.js';
|
|
9
|
+
// ------------------------------------------------------------------ A11Y-001
|
|
10
|
+
function htmlLangMissing(doc) {
|
|
11
|
+
const html = doc.elements.find((e) => e.tag === 'html');
|
|
12
|
+
if (!html)
|
|
13
|
+
return 'no-html';
|
|
14
|
+
return (html.attrs.lang ?? '').trim() ? null : html;
|
|
15
|
+
}
|
|
16
|
+
const a11y001Source = sourceRule('A11Y-001', (ctx) => {
|
|
17
|
+
const path = 'src/app.html';
|
|
18
|
+
const text = ctx.text(path);
|
|
19
|
+
if (text === null)
|
|
20
|
+
return [
|
|
21
|
+
{
|
|
22
|
+
file: path,
|
|
23
|
+
message: '`src/app.html` fehlt.',
|
|
24
|
+
fix: 'Stelle `src/app.html` aus dem Starter wieder her.',
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
const doc = parseHtml(text);
|
|
28
|
+
const missing = htmlLangMissing(doc);
|
|
29
|
+
if (!missing)
|
|
30
|
+
return [];
|
|
31
|
+
return [
|
|
32
|
+
{
|
|
33
|
+
file: path,
|
|
34
|
+
line: missing === 'no-html' ? null : lineOf(doc, missing),
|
|
35
|
+
message: '`<html>` hat kein `lang`-Attribut.',
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
});
|
|
39
|
+
const a11y001Output = outputRule('A11Y-001', (ctx) => {
|
|
40
|
+
const out = [];
|
|
41
|
+
for (const page of ctx.pages()) {
|
|
42
|
+
const missing = htmlLangMissing(ctx.html(page));
|
|
43
|
+
if (missing)
|
|
44
|
+
out.push({ file: page, message: `Die Seite \`${routeOfPage(page)}\` hat kein \`<html lang>\`.` });
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
});
|
|
48
|
+
// ------------------------------------------------------------------ A11Y-002
|
|
49
|
+
const a11y002Source = sourceRule('A11Y-002', (ctx) => {
|
|
50
|
+
const out = [];
|
|
51
|
+
for (const path of ctx.svelteFiles()) {
|
|
52
|
+
for (const el of ctx.svelte(path)?.elements ?? []) {
|
|
53
|
+
if (el.kind === 'element' && el.name === 'img') {
|
|
54
|
+
out.push(ctx.at(path, el.start, `\`${path}\` nutzt \`<img>\` statt \`<MediaImage>\`.`));
|
|
55
|
+
}
|
|
56
|
+
else if ((el.name === 'enhanced:img' || (el.kind === 'component' && el.name === COMPONENT.mediaImage)) &&
|
|
57
|
+
!hasSpread(el)) {
|
|
58
|
+
if (el.name === COMPONENT.mediaImage && getAttr(el, 'media'))
|
|
59
|
+
continue; // Alternativtext kommt aus dem CMS.
|
|
60
|
+
const alt = getAttr(el, 'alt');
|
|
61
|
+
if (!alt) {
|
|
62
|
+
out.push(ctx.at(path, el.start, `\`<${el.name}>\` in \`${path}\` hat kein \`alt\`.`, 'Beschreibe das Bild in `alt="…"`. Rein dekorativ: `alt="" decorative`.'));
|
|
63
|
+
}
|
|
64
|
+
else if (alt.value === '' && !getAttr(el, 'decorative')) {
|
|
65
|
+
out.push(ctx.at(path, el.start, `\`<${el.name}>\` in \`${path}\` hat ein leeres \`alt\` ohne \`decorative\`.`, 'Beschreibe das Bild in `alt="…"` oder ergänze `decorative`, wenn es rein dekorativ ist.'));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
for (const path of ctx.htmlFiles()) {
|
|
71
|
+
const doc = parseHtml(ctx.code(path));
|
|
72
|
+
for (const el of doc.elements.filter((e) => e.tag === 'img' && e.attrs.alt === undefined)) {
|
|
73
|
+
out.push({ file: path, line: lineOf(doc, el), message: `\`<img>\` in \`${path}\` hat kein \`alt\`.` });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return out;
|
|
77
|
+
});
|
|
78
|
+
const a11y002Output = outputRule('A11Y-002', (ctx) => {
|
|
79
|
+
const out = [];
|
|
80
|
+
for (const page of ctx.pages()) {
|
|
81
|
+
const doc = ctx.html(page);
|
|
82
|
+
for (const el of doc.elements) {
|
|
83
|
+
const needsAlt = el.tag === 'img' ||
|
|
84
|
+
el.tag === 'area' ||
|
|
85
|
+
(el.tag === 'input' && (el.attrs.type ?? '').toLowerCase() === 'image');
|
|
86
|
+
if (needsAlt && el.attrs.alt === undefined && el.attrs['aria-label'] === undefined && !isHidden(el)) {
|
|
87
|
+
out.push({
|
|
88
|
+
file: page,
|
|
89
|
+
line: lineOf(doc, el),
|
|
90
|
+
message: `Ein Bild auf \`${routeOfPage(page)}\` hat kein \`alt\` (\`${el.attrs.src ?? ''}\`).`,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return out;
|
|
96
|
+
});
|
|
97
|
+
// ------------------------------------------------------------------ A11Y-003
|
|
98
|
+
const a11y003 = outputRule('A11Y-003', (ctx) => {
|
|
99
|
+
const out = [];
|
|
100
|
+
for (const page of ctx.contentPages()) {
|
|
101
|
+
const doc = ctx.html(page);
|
|
102
|
+
const route = routeOfPage(page);
|
|
103
|
+
const headings = doc.elements.filter((e) => /^h[1-6]$/.test(e.tag) && !isHidden(e));
|
|
104
|
+
const h1 = headings.filter((h) => h.tag === 'h1');
|
|
105
|
+
if (h1.length !== 1) {
|
|
106
|
+
out.push({
|
|
107
|
+
file: page,
|
|
108
|
+
line: h1[1] ? lineOf(doc, h1[1]) : null,
|
|
109
|
+
message: `Die Seite \`${route}\` hat ${h1.length} \`<h1>\`, erwartet ist genau eine.`,
|
|
110
|
+
fix: h1.length === 0
|
|
111
|
+
? 'Gib der Seite eine Hauptüberschrift `<h1>`.'
|
|
112
|
+
: 'Mache die weiteren `<h1>` zu `<h2>`.',
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
let prev = 0;
|
|
116
|
+
for (const h of headings) {
|
|
117
|
+
const level = Number(h.tag.slice(1));
|
|
118
|
+
if (prev > 0 && level > prev + 1) {
|
|
119
|
+
out.push({
|
|
120
|
+
file: page,
|
|
121
|
+
line: lineOf(doc, h),
|
|
122
|
+
message: `Seite \`${route}\`: Überschriften springen von h${prev} auf h${level}.`,
|
|
123
|
+
fix: `Nutze \`<h${prev + 1}>\` (die nächste Ebene) und gestalte die Größe per CSS.`,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
prev = level;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return out;
|
|
130
|
+
});
|
|
131
|
+
// ------------------------------------------------------------------ A11Y-004
|
|
132
|
+
const UNLABELED_INPUT_TYPES = new Set(['hidden', 'submit', 'button', 'reset', 'image']);
|
|
133
|
+
const a11y004 = outputRule('A11Y-004', (ctx) => {
|
|
134
|
+
const out = [];
|
|
135
|
+
for (const page of ctx.pages()) {
|
|
136
|
+
const doc = ctx.html(page);
|
|
137
|
+
const labelFor = new Set(doc.elements.filter((e) => e.tag === 'label' && e.attrs.for).map((e) => e.attrs.for));
|
|
138
|
+
for (const el of doc.elements) {
|
|
139
|
+
if (!['input', 'select', 'textarea'].includes(el.tag))
|
|
140
|
+
continue;
|
|
141
|
+
if (el.tag === 'input' && UNLABELED_INPUT_TYPES.has((el.attrs.type ?? 'text').toLowerCase()))
|
|
142
|
+
continue;
|
|
143
|
+
if (isHidden(el))
|
|
144
|
+
continue;
|
|
145
|
+
const labelled = (el.attrs['aria-label'] ?? '').trim() !== '' ||
|
|
146
|
+
(el.attrs['aria-labelledby'] ?? '').trim() !== '' ||
|
|
147
|
+
(el.attrs.title ?? '').trim() !== '' ||
|
|
148
|
+
(el.attrs.id !== undefined && labelFor.has(el.attrs.id)) ||
|
|
149
|
+
ancestors(el).some((a) => a.tag === 'label');
|
|
150
|
+
if (!labelled) {
|
|
151
|
+
const name = el.attrs.name ?? el.attrs.id ?? el.tag;
|
|
152
|
+
out.push({
|
|
153
|
+
file: page,
|
|
154
|
+
line: lineOf(doc, el),
|
|
155
|
+
message: `Das Feld \`${name}\` auf \`${routeOfPage(page)}\` hat keine Beschriftung.`,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return out;
|
|
161
|
+
});
|
|
162
|
+
// ------------------------------------------------------------------ A11Y-005
|
|
163
|
+
const VAGUE_LINK_TEXTS = new Set([
|
|
164
|
+
'hier',
|
|
165
|
+
'hier klicken',
|
|
166
|
+
'klick hier',
|
|
167
|
+
'klicke hier',
|
|
168
|
+
'klicken sie hier',
|
|
169
|
+
'click here',
|
|
170
|
+
'here',
|
|
171
|
+
'link',
|
|
172
|
+
'mehr',
|
|
173
|
+
'more',
|
|
174
|
+
]);
|
|
175
|
+
function accessibleName(el) {
|
|
176
|
+
const aria = (el.attrs['aria-label'] ?? '').trim();
|
|
177
|
+
if (aria)
|
|
178
|
+
return aria;
|
|
179
|
+
if ((el.attrs['aria-labelledby'] ?? '').trim())
|
|
180
|
+
return '(aria-labelledby)';
|
|
181
|
+
const text = textContent(el).replace(/\s+/g, ' ').trim();
|
|
182
|
+
if (text)
|
|
183
|
+
return text;
|
|
184
|
+
const collect = (node) => node.children.flatMap((c) => 'tag' in c
|
|
185
|
+
? [
|
|
186
|
+
...(c.tag === 'img' || c.tag === 'svg' ? [c.attrs.alt ?? c.attrs['aria-label'] ?? ''] : []),
|
|
187
|
+
...collect(c),
|
|
188
|
+
]
|
|
189
|
+
: []);
|
|
190
|
+
const alt = collect(el).join(' ').trim();
|
|
191
|
+
if (alt)
|
|
192
|
+
return alt;
|
|
193
|
+
return (el.attrs.title ?? '').trim();
|
|
194
|
+
}
|
|
195
|
+
const a11y005 = outputRule('A11Y-005', (ctx) => {
|
|
196
|
+
const out = [];
|
|
197
|
+
for (const page of ctx.pages()) {
|
|
198
|
+
const doc = ctx.html(page);
|
|
199
|
+
for (const el of doc.elements) {
|
|
200
|
+
const isLink = el.tag === 'a' && el.attrs.href !== undefined;
|
|
201
|
+
if ((!isLink && el.tag !== 'button') || isHidden(el))
|
|
202
|
+
continue;
|
|
203
|
+
const name = accessibleName(el);
|
|
204
|
+
const what = isLink ? `Der Link \`${el.attrs.href ?? ''}\`` : 'Eine Schaltfläche';
|
|
205
|
+
if (!name) {
|
|
206
|
+
out.push({
|
|
207
|
+
file: page,
|
|
208
|
+
line: lineOf(doc, el),
|
|
209
|
+
message: `${what} auf \`${routeOfPage(page)}\` hat keinen Text.`,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
else if (isLink && VAGUE_LINK_TEXTS.has(name.toLowerCase().replace(/[.!:…]+$/, ''))) {
|
|
213
|
+
out.push({
|
|
214
|
+
file: page,
|
|
215
|
+
line: lineOf(doc, el),
|
|
216
|
+
message: `${what} auf \`${routeOfPage(page)}\` hat nur den Text „${name}“.`,
|
|
217
|
+
fix: 'Beschreibe das Ziel im Linktext, z. B. „Alle Angebote ansehen“.',
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return out;
|
|
223
|
+
});
|
|
224
|
+
// ------------------------------------------------------------------ A11Y-006
|
|
225
|
+
const CUSTOM_PROP = /(--color-[a-z0-9-]+)\s*:\s*([^;}]+)/gi;
|
|
226
|
+
function collectTokens(ctx) {
|
|
227
|
+
const tokens = new Map();
|
|
228
|
+
const scan = (file, text, offset) => {
|
|
229
|
+
for (const m of text.matchAll(CUSTOM_PROP)) {
|
|
230
|
+
const name = (m[1] ?? '').toLowerCase();
|
|
231
|
+
if (!tokens.has(name))
|
|
232
|
+
tokens.set(name, {
|
|
233
|
+
value: (m[2] ?? '').trim(),
|
|
234
|
+
file,
|
|
235
|
+
line: ctx.lines(file).at(offset + m.index).line,
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
for (const path of ctx.cssFiles())
|
|
240
|
+
scan(path, ctx.code(path), 0);
|
|
241
|
+
for (const path of ctx.svelteFiles())
|
|
242
|
+
for (const s of ctx.svelte(path)?.styles ?? [])
|
|
243
|
+
scan(path, s.content, s.start);
|
|
244
|
+
return tokens;
|
|
245
|
+
}
|
|
246
|
+
function resolveToken(tokens, name, depth = 0) {
|
|
247
|
+
const v = tokens.get(name)?.value;
|
|
248
|
+
if (!v || depth > 5)
|
|
249
|
+
return null;
|
|
250
|
+
const ref = /^var\(\s*(--[a-z0-9-]+)\s*(?:,[^)]*)?\)$/i.exec(v);
|
|
251
|
+
return ref?.[1] ? resolveToken(tokens, ref[1].toLowerCase(), depth + 1) : v;
|
|
252
|
+
}
|
|
253
|
+
/** Text-auf-Hintergrund-Paare: `--color-on-<x>` auf `--color-<x>`, `--color-text` auf `--color-background`. */
|
|
254
|
+
function tokenPairs(tokens) {
|
|
255
|
+
const pairs = [];
|
|
256
|
+
for (const name of tokens.keys()) {
|
|
257
|
+
const m = /^--color-on-(.+)$/.exec(name);
|
|
258
|
+
if (m && tokens.has(`--color-${m[1]}`))
|
|
259
|
+
pairs.push([name, `--color-${m[1]}`]);
|
|
260
|
+
}
|
|
261
|
+
const bg = ['--color-background', '--color-bg', '--color-surface'].find((n) => tokens.has(n));
|
|
262
|
+
for (const fg of [
|
|
263
|
+
'--color-text',
|
|
264
|
+
'--color-foreground',
|
|
265
|
+
'--color-fg',
|
|
266
|
+
'--color-text-muted',
|
|
267
|
+
'--color-muted',
|
|
268
|
+
]) {
|
|
269
|
+
if (bg && tokens.has(fg))
|
|
270
|
+
pairs.push([fg, bg]);
|
|
271
|
+
}
|
|
272
|
+
return pairs;
|
|
273
|
+
}
|
|
274
|
+
const a11y006 = sourceRule('A11Y-006', (ctx) => {
|
|
275
|
+
const tokens = collectTokens(ctx);
|
|
276
|
+
const out = [];
|
|
277
|
+
for (const [fg, bg] of tokenPairs(tokens)) {
|
|
278
|
+
const a = parseColor(resolveToken(tokens, fg) ?? '');
|
|
279
|
+
const b = parseColor(resolveToken(tokens, bg) ?? '');
|
|
280
|
+
if (!a || !b)
|
|
281
|
+
continue;
|
|
282
|
+
const ratio = contrastRatio(a, b);
|
|
283
|
+
if (ratio >= 4.5)
|
|
284
|
+
continue;
|
|
285
|
+
const at = tokens.get(fg);
|
|
286
|
+
out.push({
|
|
287
|
+
file: at?.file ?? null,
|
|
288
|
+
line: at?.line ?? null,
|
|
289
|
+
message: `Kontrast ${ratio.toFixed(2).replace('.', ',')}:1 zwischen \`${fg}\` und \`${bg}\` reicht nicht. Mindestens 4,5:1.`,
|
|
290
|
+
fix: `Mache \`${fg}\` dunkler oder heller, bis der Kontrast zu \`${bg}\` mindestens 4,5:1 beträgt.`,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
return out;
|
|
294
|
+
});
|
|
295
|
+
// ------------------------------------------------------------------ A11Y-007
|
|
296
|
+
const OUTLINE_NONE = /outline\s*:\s*(?:none|0(?:px)?)\s*(?:!important)?\s*[;}]/gi;
|
|
297
|
+
const a11y007 = sourceRule('A11Y-007', (ctx) => {
|
|
298
|
+
const out = [];
|
|
299
|
+
const cssChunks = [];
|
|
300
|
+
for (const path of ctx.cssFiles())
|
|
301
|
+
cssChunks.push({ file: path, text: ctx.code(path), offset: 0 });
|
|
302
|
+
for (const path of ctx.svelteFiles())
|
|
303
|
+
for (const s of ctx.svelte(path)?.styles ?? [])
|
|
304
|
+
cssChunks.push({ file: path, text: s.content, offset: s.start });
|
|
305
|
+
for (const chunk of cssChunks) {
|
|
306
|
+
if (/:focus-visible/.test(chunk.text))
|
|
307
|
+
continue; // Ersatz für den Fokus vorhanden.
|
|
308
|
+
for (const m of chunk.text.matchAll(OUTLINE_NONE)) {
|
|
309
|
+
out.push(ctx.at(chunk.file, chunk.offset + m.index, `\`outline: none\` in \`${chunk.file}\` ohne \`:focus-visible\`-Ersatz.`, 'Entferne `outline: none` oder ergänze eine sichtbare `:focus-visible`-Regel in derselben Datei.'));
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
for (const path of ctx.svelteFiles()) {
|
|
313
|
+
for (const el of ctx.svelte(path)?.elements ?? []) {
|
|
314
|
+
const t = getAttr(el, 'tabindex');
|
|
315
|
+
if (t && typeof t.value === 'string' && Number(t.value) > 0) {
|
|
316
|
+
out.push(ctx.at(path, t.start, `\`tabindex="${t.value}"\` in \`${path}\` verändert die Tab-Reihenfolge.`, 'Nutze `tabindex="0"` oder `-1`, nie größer als 0.'));
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
for (const path of ctx.htmlFiles()) {
|
|
321
|
+
for (const m of findAll(ctx.code(path), /tabindex\s*=\s*["']?[1-9]/gi, ctx.lines(path))) {
|
|
322
|
+
out.push({
|
|
323
|
+
file: path,
|
|
324
|
+
line: m.line,
|
|
325
|
+
column: m.column,
|
|
326
|
+
message: `\`${m.text}\` in \`${path}\` verändert die Tab-Reihenfolge.`,
|
|
327
|
+
fix: 'Nutze `tabindex="0"` oder `-1`.',
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
for (const m of findAll(ctx.code(path), /user-scalable\s*=\s*(?:no|0)|maximum-scale\s*=\s*1(?:\.0)?\b/gi, ctx.lines(path))) {
|
|
331
|
+
out.push({
|
|
332
|
+
file: path,
|
|
333
|
+
line: m.line,
|
|
334
|
+
column: m.column,
|
|
335
|
+
message: `\`${m.text}\` in \`${path}\` verhindert das Zoomen.`,
|
|
336
|
+
fix: 'Setze `<meta name="viewport" content="width=device-width, initial-scale=1" />`.',
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return out;
|
|
341
|
+
});
|
|
342
|
+
// ------------------------------------------------------------------ A11Y-008
|
|
343
|
+
const a11y008 = outputRule('A11Y-008', (ctx) => {
|
|
344
|
+
const out = [];
|
|
345
|
+
const titles = new Map();
|
|
346
|
+
for (const page of ctx.contentPages()) {
|
|
347
|
+
const doc = ctx.html(page);
|
|
348
|
+
const route = routeOfPage(page);
|
|
349
|
+
const titleEl = doc.elements.find((e) => e.tag === 'title' && !ancestors(e).some((a) => a.tag === 'svg'));
|
|
350
|
+
const title = titleEl ? textContent(titleEl).replace(/\s+/g, ' ').trim() : '';
|
|
351
|
+
if (!title) {
|
|
352
|
+
out.push({
|
|
353
|
+
file: page,
|
|
354
|
+
message: `Die Seite \`${route}\` hat keinen Titel.`,
|
|
355
|
+
fix: 'Ergänze `<svelte:head><title>…</title></svelte:head>` in der Seite.',
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
titles.set(title, [...(titles.get(title) ?? []), route]);
|
|
360
|
+
}
|
|
361
|
+
const desc = doc.elements.find((e) => e.tag === 'meta' && (e.attrs.name ?? '').toLowerCase() === 'description');
|
|
362
|
+
if (!(desc?.attrs.content ?? '').trim()) {
|
|
363
|
+
out.push({
|
|
364
|
+
file: page,
|
|
365
|
+
message: `Die Seite \`${route}\` hat keine Beschreibung (\`meta description\`).`,
|
|
366
|
+
fix: 'Ergänze `<meta name="description" content="…" />` in `<svelte:head>`.',
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
for (const [title, routes] of titles) {
|
|
371
|
+
if (routes.length < 2)
|
|
372
|
+
continue;
|
|
373
|
+
out.push({
|
|
374
|
+
file: null,
|
|
375
|
+
message: `Der Titel „${title}“ steht auf mehreren Seiten: ${routes.join(', ')}.`,
|
|
376
|
+
fix: 'Gib jeder Seite einen eigenen Titel.',
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
return out;
|
|
380
|
+
});
|
|
381
|
+
// ------------------------------------------------------------------ A11Y-009
|
|
382
|
+
const a11y009Source = sourceRule('A11Y-009', (ctx) => {
|
|
383
|
+
const out = [];
|
|
384
|
+
for (const path of ctx.svelteFiles()) {
|
|
385
|
+
for (const el of ctx.svelte(path)?.elements ?? []) {
|
|
386
|
+
if (el.kind === 'element' && el.name === 'video') {
|
|
387
|
+
out.push(ctx.at(path, el.start, `\`${path}\` nutzt \`<video>\` statt \`<MediaVideo>\`.`));
|
|
388
|
+
}
|
|
389
|
+
else if (el.kind === 'component' &&
|
|
390
|
+
el.name === COMPONENT.mediaVideo &&
|
|
391
|
+
!getAttr(el, 'title') &&
|
|
392
|
+
!hasSpread(el)) {
|
|
393
|
+
out.push(ctx.at(path, el.start, `\`<MediaVideo>\` in \`${path}\` hat keinen \`title\`.`, 'Gib `title="…"` an, z. B. `title="Rundgang durch die Wohnung"`.'));
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return out;
|
|
398
|
+
});
|
|
399
|
+
const a11y009Output = outputRule('A11Y-009', (ctx) => {
|
|
400
|
+
const out = [];
|
|
401
|
+
for (const page of ctx.pages()) {
|
|
402
|
+
const doc = ctx.html(page);
|
|
403
|
+
for (const el of doc.elements) {
|
|
404
|
+
if (el.tag === 'video' && 'autoplay' in el.attrs && !('muted' in el.attrs)) {
|
|
405
|
+
out.push({
|
|
406
|
+
file: page,
|
|
407
|
+
line: lineOf(doc, el),
|
|
408
|
+
message: `Ein Video auf \`${routeOfPage(page)}\` startet automatisch mit Ton.`,
|
|
409
|
+
fix: 'Entferne `autoplay` oder ergänze `muted`.',
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
if (el.tag === 'iframe' && !(el.attrs.title ?? '').trim() && !isHidden(el)) {
|
|
413
|
+
out.push({
|
|
414
|
+
file: page,
|
|
415
|
+
line: lineOf(doc, el),
|
|
416
|
+
message: `Ein \`<iframe>\` auf \`${routeOfPage(page)}\` hat keinen \`title\`.`,
|
|
417
|
+
fix: 'Nutze `<MediaVideo>` und gib `title` an.',
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return out;
|
|
423
|
+
});
|
|
424
|
+
export const a11ySourceRules = [a11y001Source, a11y002Source, a11y006, a11y007, a11y009Source];
|
|
425
|
+
export const a11yOutputRules = [
|
|
426
|
+
a11y001Output,
|
|
427
|
+
a11y002Output,
|
|
428
|
+
a11y003,
|
|
429
|
+
a11y004,
|
|
430
|
+
a11y005,
|
|
431
|
+
a11y008,
|
|
432
|
+
a11y009Output,
|
|
433
|
+
];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type OutputRule, type SourceRule } from '../rule.js';
|
|
2
|
+
/** Schrift- und Skript-CDNs (PRV-002). */
|
|
3
|
+
export declare const CDN_HOSTS: readonly string[];
|
|
4
|
+
/** Löst einen Link relativ zur Seite auf; `null` für externe Ziele. */
|
|
5
|
+
export declare function resolveHref(href: string, pageRoute: string): string | null;
|
|
6
|
+
declare function normalizeRoute(path: string): string;
|
|
7
|
+
export declare const privacySourceRules: SourceRule[];
|
|
8
|
+
export declare const privacyOutputRules: OutputRule[];
|
|
9
|
+
export { normalizeRoute };
|