-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
67 lines (59 loc) · 1.62 KB
/
Copy pathtypes.ts
File metadata and controls
67 lines (59 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Shared contract for the alt-text-scan plugin.
import type {Page} from 'playwright'
// The scanner's Finding shape. Mirrors the structure of
// accessibility-scanner/.github/actions/find/src/types.d.ts
export type Finding = {
scannerType: string
ruleId?: string
url: string
html?: string
problemShort: string
problemUrl: string
solutionShort: string
solutionLong?: string
screenshotId?: string
}
// The arguments the scanner passes to a plugin's default export.
export type PluginArgs = {
page: Page
addFinding: (finding: Finding) => Promise<void>
}
// Normalized representation of one <img> on the page.
export type ImageRecord = {
src: string | null
alt: string | null
role: string | null
ariaHidden: boolean
ariaLabel: string | null
ariaLabelledBy: string | null
outerHTML: string
boundingBox: BoundingBox | null
}
// Pixel position and size of an image in the page's rendered layout.
export type BoundingBox = {
x: number
y: number
width: number
height: number
}
// Input handed to every rule's evaluate() function.
export type RuleContext = {
url: string
images: ImageRecord[]
}
// What a rule emits per offending image. Translated to Finding in findings.ts.
export type RuleResult = {
image: ImageRecord
problemShort: string
solutionShort: string
solutionLong?: string
}
// A rule is a pure, synchronous function over RuleContext.
export type Rule = {
id: string
problemUrl: string
// Whether the rule runs when the consumer hasn't explicitly configured it.
// Optional; treated as `true` when absent.
defaultEnabled?: boolean
evaluate(ctx: RuleContext): RuleResult[]
}