@accesslint/storybook-addon 0.8.5 → 0.8.6
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/dist/chunk-XTEGJNR3.js +110 -0
- package/dist/index.cjs +114 -0
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +5 -0
- package/dist/manager.js +3 -3
- package/dist/portable.cjs +11 -3
- package/dist/portable.d.cts +15 -2
- package/dist/portable.d.ts +15 -2
- package/dist/portable.js +11 -3
- package/dist/preview.cjs +10 -2
- package/dist/preview.d.cts +13 -2
- package/dist/preview.d.ts +13 -2
- package/dist/preview.js +1 -92
- package/dist/vitest-setup.cjs +11 -3
- package/dist/vitest-setup.js +11 -3
- package/package.json +1 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { configureRules, createChunkedAudit, getActiveRules, getRuleById } from '@accesslint/core';
|
|
2
|
+
import { addons } from 'storybook/preview-api';
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// src/preview.ts
|
|
11
|
+
var preview_exports = {};
|
|
12
|
+
__export(preview_exports, {
|
|
13
|
+
afterEach: () => afterEach,
|
|
14
|
+
initialGlobals: () => initialGlobals,
|
|
15
|
+
parameters: () => parameters
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// src/constants.ts
|
|
19
|
+
var ADDON_ID = "accesslint/a11y";
|
|
20
|
+
var RESULT_EVENT = `${ADDON_ID}/result`;
|
|
21
|
+
|
|
22
|
+
// src/preview.ts
|
|
23
|
+
var initialGlobals = {
|
|
24
|
+
accesslint: {}
|
|
25
|
+
};
|
|
26
|
+
var parameters = {
|
|
27
|
+
accesslint: {}
|
|
28
|
+
};
|
|
29
|
+
configureRules({
|
|
30
|
+
disabledRules: ["accesslint-045"]
|
|
31
|
+
});
|
|
32
|
+
var BUDGET_MS = 12;
|
|
33
|
+
function yieldToMain() {
|
|
34
|
+
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
35
|
+
}
|
|
36
|
+
function scopeViolations(violations) {
|
|
37
|
+
const root = document.getElementById("storybook-root");
|
|
38
|
+
if (!root) return violations;
|
|
39
|
+
return violations.filter((v) => {
|
|
40
|
+
const local = v.selector.replace(/^.*>>>\s*iframe>\s*/, "");
|
|
41
|
+
try {
|
|
42
|
+
const el = document.querySelector(local);
|
|
43
|
+
return el && root.contains(el);
|
|
44
|
+
} catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function enrichViolations(violations) {
|
|
50
|
+
return violations.map((v) => {
|
|
51
|
+
const rule = getRuleById(v.ruleId);
|
|
52
|
+
return {
|
|
53
|
+
...v,
|
|
54
|
+
element: void 0,
|
|
55
|
+
// not serializable
|
|
56
|
+
description: rule?.description,
|
|
57
|
+
wcag: rule?.wcag,
|
|
58
|
+
level: rule?.level,
|
|
59
|
+
guidance: rule?.guidance
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
var afterEach = async ({
|
|
64
|
+
reporting,
|
|
65
|
+
parameters: parameters2,
|
|
66
|
+
viewMode,
|
|
67
|
+
tags,
|
|
68
|
+
id
|
|
69
|
+
}) => {
|
|
70
|
+
const accesslintParam = parameters2?.accesslint;
|
|
71
|
+
if (accesslintParam?.disable === true || accesslintParam?.test === "off") return;
|
|
72
|
+
if (viewMode !== "story") return;
|
|
73
|
+
const skipTags = typeof __ACCESSLINT_SKIP_TAGS__ !== "undefined" ? __ACCESSLINT_SKIP_TAGS__ : [];
|
|
74
|
+
const allSkipTags = ["skip-accesslint", ...skipTags];
|
|
75
|
+
const matchedTag = tags?.find((t) => allSkipTags.includes(t));
|
|
76
|
+
if (matchedTag) {
|
|
77
|
+
const result2 = { skipped: true, reason: matchedTag };
|
|
78
|
+
addons.getChannel().emit(RESULT_EVENT, { storyId: id, result: result2 });
|
|
79
|
+
reporting.addReport({
|
|
80
|
+
type: "accesslint",
|
|
81
|
+
version: 1,
|
|
82
|
+
result: result2,
|
|
83
|
+
status: "passed"
|
|
84
|
+
});
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const audit = createChunkedAudit(document);
|
|
88
|
+
while (audit.processChunk(BUDGET_MS)) {
|
|
89
|
+
await yieldToMain();
|
|
90
|
+
}
|
|
91
|
+
const violations = audit.getViolations();
|
|
92
|
+
const scoped = scopeViolations(violations);
|
|
93
|
+
const enriched = enrichViolations(scoped);
|
|
94
|
+
const hasViolations = enriched.length > 0;
|
|
95
|
+
const mode = accesslintParam?.test === "todo" ? "warning" : "failed";
|
|
96
|
+
const status = hasViolations ? mode : "passed";
|
|
97
|
+
const result = {
|
|
98
|
+
violations: enriched,
|
|
99
|
+
ruleCount: getActiveRules().length
|
|
100
|
+
};
|
|
101
|
+
addons.getChannel().emit(RESULT_EVENT, { storyId: id, result, status });
|
|
102
|
+
reporting.addReport({
|
|
103
|
+
type: "accesslint",
|
|
104
|
+
version: 1,
|
|
105
|
+
result,
|
|
106
|
+
status
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export { afterEach, initialGlobals, parameters, preview_exports };
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,116 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var csf = require('storybook/internal/csf');
|
|
4
|
+
var core = require('@accesslint/core');
|
|
5
|
+
var previewApi = require('storybook/preview-api');
|
|
6
|
+
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// src/preview.ts
|
|
14
|
+
var preview_exports = {};
|
|
15
|
+
__export(preview_exports, {
|
|
16
|
+
afterEach: () => afterEach,
|
|
17
|
+
initialGlobals: () => initialGlobals,
|
|
18
|
+
parameters: () => parameters
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// src/constants.ts
|
|
22
|
+
var ADDON_ID = "accesslint/a11y";
|
|
23
|
+
var RESULT_EVENT = `${ADDON_ID}/result`;
|
|
24
|
+
|
|
25
|
+
// src/preview.ts
|
|
26
|
+
var initialGlobals = {
|
|
27
|
+
accesslint: {}
|
|
28
|
+
};
|
|
29
|
+
var parameters = {
|
|
30
|
+
accesslint: {}
|
|
31
|
+
};
|
|
32
|
+
core.configureRules({
|
|
33
|
+
disabledRules: ["accesslint-045"]
|
|
34
|
+
});
|
|
35
|
+
var BUDGET_MS = 12;
|
|
36
|
+
function yieldToMain() {
|
|
37
|
+
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
38
|
+
}
|
|
39
|
+
function scopeViolations(violations) {
|
|
40
|
+
const root = document.getElementById("storybook-root");
|
|
41
|
+
if (!root) return violations;
|
|
42
|
+
return violations.filter((v) => {
|
|
43
|
+
const local = v.selector.replace(/^.*>>>\s*iframe>\s*/, "");
|
|
44
|
+
try {
|
|
45
|
+
const el = document.querySelector(local);
|
|
46
|
+
return el && root.contains(el);
|
|
47
|
+
} catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function enrichViolations(violations) {
|
|
53
|
+
return violations.map((v) => {
|
|
54
|
+
const rule = core.getRuleById(v.ruleId);
|
|
55
|
+
return {
|
|
56
|
+
...v,
|
|
57
|
+
element: void 0,
|
|
58
|
+
// not serializable
|
|
59
|
+
description: rule?.description,
|
|
60
|
+
wcag: rule?.wcag,
|
|
61
|
+
level: rule?.level,
|
|
62
|
+
guidance: rule?.guidance
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
var afterEach = async ({
|
|
67
|
+
reporting,
|
|
68
|
+
parameters: parameters2,
|
|
69
|
+
viewMode,
|
|
70
|
+
tags,
|
|
71
|
+
id
|
|
72
|
+
}) => {
|
|
73
|
+
const accesslintParam = parameters2?.accesslint;
|
|
74
|
+
if (accesslintParam?.disable === true || accesslintParam?.test === "off") return;
|
|
75
|
+
if (viewMode !== "story") return;
|
|
76
|
+
const skipTags = typeof __ACCESSLINT_SKIP_TAGS__ !== "undefined" ? __ACCESSLINT_SKIP_TAGS__ : [];
|
|
77
|
+
const allSkipTags = ["skip-accesslint", ...skipTags];
|
|
78
|
+
const matchedTag = tags?.find((t) => allSkipTags.includes(t));
|
|
79
|
+
if (matchedTag) {
|
|
80
|
+
const result2 = { skipped: true, reason: matchedTag };
|
|
81
|
+
previewApi.addons.getChannel().emit(RESULT_EVENT, { storyId: id, result: result2 });
|
|
82
|
+
reporting.addReport({
|
|
83
|
+
type: "accesslint",
|
|
84
|
+
version: 1,
|
|
85
|
+
result: result2,
|
|
86
|
+
status: "passed"
|
|
87
|
+
});
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const audit = core.createChunkedAudit(document);
|
|
91
|
+
while (audit.processChunk(BUDGET_MS)) {
|
|
92
|
+
await yieldToMain();
|
|
93
|
+
}
|
|
94
|
+
const violations = audit.getViolations();
|
|
95
|
+
const scoped = scopeViolations(violations);
|
|
96
|
+
const enriched = enrichViolations(scoped);
|
|
97
|
+
const hasViolations = enriched.length > 0;
|
|
98
|
+
const mode = accesslintParam?.test === "todo" ? "warning" : "failed";
|
|
99
|
+
const status = hasViolations ? mode : "passed";
|
|
100
|
+
const result = {
|
|
101
|
+
violations: enriched,
|
|
102
|
+
ruleCount: core.getActiveRules().length
|
|
103
|
+
};
|
|
104
|
+
previewApi.addons.getChannel().emit(RESULT_EVENT, { storyId: id, result, status });
|
|
105
|
+
reporting.addReport({
|
|
106
|
+
type: "accesslint",
|
|
107
|
+
version: 1,
|
|
108
|
+
result,
|
|
109
|
+
status
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// src/index.ts
|
|
114
|
+
var index_default = () => csf.definePreviewAddon(preview_exports);
|
|
115
|
+
|
|
116
|
+
module.exports = index_default;
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/manager.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useMemo, useState, useRef, useCallback } from 'react';
|
|
2
|
-
import * as managerApi from 'storybook/
|
|
3
|
-
import { useChannel } from 'storybook/
|
|
4
|
-
import { styled, useTheme } from 'storybook/
|
|
2
|
+
import * as managerApi from 'storybook/manager-api';
|
|
3
|
+
import { useChannel } from 'storybook/manager-api';
|
|
4
|
+
import { styled, useTheme } from 'storybook/theming';
|
|
5
5
|
import { STORY_CHANGED } from 'storybook/internal/core-events';
|
|
6
6
|
|
|
7
7
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
package/dist/portable.cjs
CHANGED
|
@@ -12,7 +12,9 @@ var __export = (target, all) => {
|
|
|
12
12
|
// src/preview.ts
|
|
13
13
|
var preview_exports = {};
|
|
14
14
|
__export(preview_exports, {
|
|
15
|
-
afterEach: () => afterEach
|
|
15
|
+
afterEach: () => afterEach,
|
|
16
|
+
initialGlobals: () => initialGlobals,
|
|
17
|
+
parameters: () => parameters
|
|
16
18
|
});
|
|
17
19
|
|
|
18
20
|
// src/constants.ts
|
|
@@ -20,6 +22,12 @@ var ADDON_ID = "accesslint/a11y";
|
|
|
20
22
|
var RESULT_EVENT = `${ADDON_ID}/result`;
|
|
21
23
|
|
|
22
24
|
// src/preview.ts
|
|
25
|
+
var initialGlobals = {
|
|
26
|
+
accesslint: {}
|
|
27
|
+
};
|
|
28
|
+
var parameters = {
|
|
29
|
+
accesslint: {}
|
|
30
|
+
};
|
|
23
31
|
core.configureRules({
|
|
24
32
|
disabledRules: ["accesslint-045"]
|
|
25
33
|
});
|
|
@@ -56,12 +64,12 @@ function enrichViolations(violations) {
|
|
|
56
64
|
}
|
|
57
65
|
var afterEach = async ({
|
|
58
66
|
reporting,
|
|
59
|
-
parameters,
|
|
67
|
+
parameters: parameters2,
|
|
60
68
|
viewMode,
|
|
61
69
|
tags,
|
|
62
70
|
id
|
|
63
71
|
}) => {
|
|
64
|
-
const accesslintParam =
|
|
72
|
+
const accesslintParam = parameters2?.accesslint;
|
|
65
73
|
if (accesslintParam?.disable === true || accesslintParam?.test === "off") return;
|
|
66
74
|
if (viewMode !== "story") return;
|
|
67
75
|
const skipTags = typeof __ACCESSLINT_SKIP_TAGS__ !== "undefined" ? __ACCESSLINT_SKIP_TAGS__ : [];
|
package/dist/portable.d.cts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
declare const initialGlobals: {
|
|
2
|
+
accesslint: {};
|
|
3
|
+
};
|
|
4
|
+
declare const parameters: {
|
|
5
|
+
accesslint: {};
|
|
6
|
+
};
|
|
1
7
|
declare const afterEach: ({ reporting, parameters, viewMode, tags, id, }: {
|
|
2
8
|
reporting: {
|
|
3
|
-
addReport: (report:
|
|
9
|
+
addReport: (report: {
|
|
10
|
+
type: string;
|
|
11
|
+
version?: number;
|
|
12
|
+
result: unknown;
|
|
13
|
+
status: "failed" | "passed" | "warning";
|
|
14
|
+
}) => void;
|
|
4
15
|
};
|
|
5
16
|
parameters: Record<string, unknown>;
|
|
6
17
|
viewMode: string;
|
|
@@ -9,8 +20,10 @@ declare const afterEach: ({ reporting, parameters, viewMode, tags, id, }: {
|
|
|
9
20
|
}) => Promise<void>;
|
|
10
21
|
|
|
11
22
|
declare const accesslintAnnotations_afterEach: typeof afterEach;
|
|
23
|
+
declare const accesslintAnnotations_initialGlobals: typeof initialGlobals;
|
|
24
|
+
declare const accesslintAnnotations_parameters: typeof parameters;
|
|
12
25
|
declare namespace accesslintAnnotations {
|
|
13
|
-
export { accesslintAnnotations_afterEach as afterEach };
|
|
26
|
+
export { accesslintAnnotations_afterEach as afterEach, accesslintAnnotations_initialGlobals as initialGlobals, accesslintAnnotations_parameters as parameters };
|
|
14
27
|
}
|
|
15
28
|
|
|
16
29
|
/**
|
package/dist/portable.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
declare const initialGlobals: {
|
|
2
|
+
accesslint: {};
|
|
3
|
+
};
|
|
4
|
+
declare const parameters: {
|
|
5
|
+
accesslint: {};
|
|
6
|
+
};
|
|
1
7
|
declare const afterEach: ({ reporting, parameters, viewMode, tags, id, }: {
|
|
2
8
|
reporting: {
|
|
3
|
-
addReport: (report:
|
|
9
|
+
addReport: (report: {
|
|
10
|
+
type: string;
|
|
11
|
+
version?: number;
|
|
12
|
+
result: unknown;
|
|
13
|
+
status: "failed" | "passed" | "warning";
|
|
14
|
+
}) => void;
|
|
4
15
|
};
|
|
5
16
|
parameters: Record<string, unknown>;
|
|
6
17
|
viewMode: string;
|
|
@@ -9,8 +20,10 @@ declare const afterEach: ({ reporting, parameters, viewMode, tags, id, }: {
|
|
|
9
20
|
}) => Promise<void>;
|
|
10
21
|
|
|
11
22
|
declare const accesslintAnnotations_afterEach: typeof afterEach;
|
|
23
|
+
declare const accesslintAnnotations_initialGlobals: typeof initialGlobals;
|
|
24
|
+
declare const accesslintAnnotations_parameters: typeof parameters;
|
|
12
25
|
declare namespace accesslintAnnotations {
|
|
13
|
-
export { accesslintAnnotations_afterEach as afterEach };
|
|
26
|
+
export { accesslintAnnotations_afterEach as afterEach, accesslintAnnotations_initialGlobals as initialGlobals, accesslintAnnotations_parameters as parameters };
|
|
14
27
|
}
|
|
15
28
|
|
|
16
29
|
/**
|
package/dist/portable.js
CHANGED
|
@@ -10,7 +10,9 @@ var __export = (target, all) => {
|
|
|
10
10
|
// src/preview.ts
|
|
11
11
|
var preview_exports = {};
|
|
12
12
|
__export(preview_exports, {
|
|
13
|
-
afterEach: () => afterEach
|
|
13
|
+
afterEach: () => afterEach,
|
|
14
|
+
initialGlobals: () => initialGlobals,
|
|
15
|
+
parameters: () => parameters
|
|
14
16
|
});
|
|
15
17
|
|
|
16
18
|
// src/constants.ts
|
|
@@ -18,6 +20,12 @@ var ADDON_ID = "accesslint/a11y";
|
|
|
18
20
|
var RESULT_EVENT = `${ADDON_ID}/result`;
|
|
19
21
|
|
|
20
22
|
// src/preview.ts
|
|
23
|
+
var initialGlobals = {
|
|
24
|
+
accesslint: {}
|
|
25
|
+
};
|
|
26
|
+
var parameters = {
|
|
27
|
+
accesslint: {}
|
|
28
|
+
};
|
|
21
29
|
configureRules({
|
|
22
30
|
disabledRules: ["accesslint-045"]
|
|
23
31
|
});
|
|
@@ -54,12 +62,12 @@ function enrichViolations(violations) {
|
|
|
54
62
|
}
|
|
55
63
|
var afterEach = async ({
|
|
56
64
|
reporting,
|
|
57
|
-
parameters,
|
|
65
|
+
parameters: parameters2,
|
|
58
66
|
viewMode,
|
|
59
67
|
tags,
|
|
60
68
|
id
|
|
61
69
|
}) => {
|
|
62
|
-
const accesslintParam =
|
|
70
|
+
const accesslintParam = parameters2?.accesslint;
|
|
63
71
|
if (accesslintParam?.disable === true || accesslintParam?.test === "off") return;
|
|
64
72
|
if (viewMode !== "story") return;
|
|
65
73
|
const skipTags = typeof __ACCESSLINT_SKIP_TAGS__ !== "undefined" ? __ACCESSLINT_SKIP_TAGS__ : [];
|
package/dist/preview.cjs
CHANGED
|
@@ -10,6 +10,12 @@ var ADDON_ID = "accesslint/a11y";
|
|
|
10
10
|
var RESULT_EVENT = `${ADDON_ID}/result`;
|
|
11
11
|
|
|
12
12
|
// src/preview.ts
|
|
13
|
+
var initialGlobals = {
|
|
14
|
+
accesslint: {}
|
|
15
|
+
};
|
|
16
|
+
var parameters = {
|
|
17
|
+
accesslint: {}
|
|
18
|
+
};
|
|
13
19
|
core.configureRules({
|
|
14
20
|
disabledRules: ["accesslint-045"]
|
|
15
21
|
});
|
|
@@ -46,12 +52,12 @@ function enrichViolations(violations) {
|
|
|
46
52
|
}
|
|
47
53
|
var afterEach = async ({
|
|
48
54
|
reporting,
|
|
49
|
-
parameters,
|
|
55
|
+
parameters: parameters2,
|
|
50
56
|
viewMode,
|
|
51
57
|
tags,
|
|
52
58
|
id
|
|
53
59
|
}) => {
|
|
54
|
-
const accesslintParam =
|
|
60
|
+
const accesslintParam = parameters2?.accesslint;
|
|
55
61
|
if (accesslintParam?.disable === true || accesslintParam?.test === "off") return;
|
|
56
62
|
if (viewMode !== "story") return;
|
|
57
63
|
const skipTags = typeof __ACCESSLINT_SKIP_TAGS__ !== "undefined" ? __ACCESSLINT_SKIP_TAGS__ : [];
|
|
@@ -92,3 +98,5 @@ var afterEach = async ({
|
|
|
92
98
|
};
|
|
93
99
|
|
|
94
100
|
exports.afterEach = afterEach;
|
|
101
|
+
exports.initialGlobals = initialGlobals;
|
|
102
|
+
exports.parameters = parameters;
|
package/dist/preview.d.cts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
declare const initialGlobals: {
|
|
2
|
+
accesslint: {};
|
|
3
|
+
};
|
|
4
|
+
declare const parameters: {
|
|
5
|
+
accesslint: {};
|
|
6
|
+
};
|
|
1
7
|
declare const afterEach: ({ reporting, parameters, viewMode, tags, id, }: {
|
|
2
8
|
reporting: {
|
|
3
|
-
addReport: (report:
|
|
9
|
+
addReport: (report: {
|
|
10
|
+
type: string;
|
|
11
|
+
version?: number;
|
|
12
|
+
result: unknown;
|
|
13
|
+
status: "failed" | "passed" | "warning";
|
|
14
|
+
}) => void;
|
|
4
15
|
};
|
|
5
16
|
parameters: Record<string, unknown>;
|
|
6
17
|
viewMode: string;
|
|
@@ -8,4 +19,4 @@ declare const afterEach: ({ reporting, parameters, viewMode, tags, id, }: {
|
|
|
8
19
|
id?: string;
|
|
9
20
|
}) => Promise<void>;
|
|
10
21
|
|
|
11
|
-
export { afterEach };
|
|
22
|
+
export { afterEach, initialGlobals, parameters };
|
package/dist/preview.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
declare const initialGlobals: {
|
|
2
|
+
accesslint: {};
|
|
3
|
+
};
|
|
4
|
+
declare const parameters: {
|
|
5
|
+
accesslint: {};
|
|
6
|
+
};
|
|
1
7
|
declare const afterEach: ({ reporting, parameters, viewMode, tags, id, }: {
|
|
2
8
|
reporting: {
|
|
3
|
-
addReport: (report:
|
|
9
|
+
addReport: (report: {
|
|
10
|
+
type: string;
|
|
11
|
+
version?: number;
|
|
12
|
+
result: unknown;
|
|
13
|
+
status: "failed" | "passed" | "warning";
|
|
14
|
+
}) => void;
|
|
4
15
|
};
|
|
5
16
|
parameters: Record<string, unknown>;
|
|
6
17
|
viewMode: string;
|
|
@@ -8,4 +19,4 @@ declare const afterEach: ({ reporting, parameters, viewMode, tags, id, }: {
|
|
|
8
19
|
id?: string;
|
|
9
20
|
}) => Promise<void>;
|
|
10
21
|
|
|
11
|
-
export { afterEach };
|
|
22
|
+
export { afterEach, initialGlobals, parameters };
|
package/dist/preview.js
CHANGED
|
@@ -1,92 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { addons } from 'storybook/preview-api';
|
|
3
|
-
|
|
4
|
-
// src/preview.ts
|
|
5
|
-
|
|
6
|
-
// src/constants.ts
|
|
7
|
-
var ADDON_ID = "accesslint/a11y";
|
|
8
|
-
var RESULT_EVENT = `${ADDON_ID}/result`;
|
|
9
|
-
|
|
10
|
-
// src/preview.ts
|
|
11
|
-
configureRules({
|
|
12
|
-
disabledRules: ["accesslint-045"]
|
|
13
|
-
});
|
|
14
|
-
var BUDGET_MS = 12;
|
|
15
|
-
function yieldToMain() {
|
|
16
|
-
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
17
|
-
}
|
|
18
|
-
function scopeViolations(violations) {
|
|
19
|
-
const root = document.getElementById("storybook-root");
|
|
20
|
-
if (!root) return violations;
|
|
21
|
-
return violations.filter((v) => {
|
|
22
|
-
const local = v.selector.replace(/^.*>>>\s*iframe>\s*/, "");
|
|
23
|
-
try {
|
|
24
|
-
const el = document.querySelector(local);
|
|
25
|
-
return el && root.contains(el);
|
|
26
|
-
} catch {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
function enrichViolations(violations) {
|
|
32
|
-
return violations.map((v) => {
|
|
33
|
-
const rule = getRuleById(v.ruleId);
|
|
34
|
-
return {
|
|
35
|
-
...v,
|
|
36
|
-
element: void 0,
|
|
37
|
-
// not serializable
|
|
38
|
-
description: rule?.description,
|
|
39
|
-
wcag: rule?.wcag,
|
|
40
|
-
level: rule?.level,
|
|
41
|
-
guidance: rule?.guidance
|
|
42
|
-
};
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
var afterEach = async ({
|
|
46
|
-
reporting,
|
|
47
|
-
parameters,
|
|
48
|
-
viewMode,
|
|
49
|
-
tags,
|
|
50
|
-
id
|
|
51
|
-
}) => {
|
|
52
|
-
const accesslintParam = parameters?.accesslint;
|
|
53
|
-
if (accesslintParam?.disable === true || accesslintParam?.test === "off") return;
|
|
54
|
-
if (viewMode !== "story") return;
|
|
55
|
-
const skipTags = typeof __ACCESSLINT_SKIP_TAGS__ !== "undefined" ? __ACCESSLINT_SKIP_TAGS__ : [];
|
|
56
|
-
const allSkipTags = ["skip-accesslint", ...skipTags];
|
|
57
|
-
const matchedTag = tags?.find((t) => allSkipTags.includes(t));
|
|
58
|
-
if (matchedTag) {
|
|
59
|
-
const result2 = { skipped: true, reason: matchedTag };
|
|
60
|
-
addons.getChannel().emit(RESULT_EVENT, { storyId: id, result: result2 });
|
|
61
|
-
reporting.addReport({
|
|
62
|
-
type: "accesslint",
|
|
63
|
-
version: 1,
|
|
64
|
-
result: result2,
|
|
65
|
-
status: "passed"
|
|
66
|
-
});
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
const audit = createChunkedAudit(document);
|
|
70
|
-
while (audit.processChunk(BUDGET_MS)) {
|
|
71
|
-
await yieldToMain();
|
|
72
|
-
}
|
|
73
|
-
const violations = audit.getViolations();
|
|
74
|
-
const scoped = scopeViolations(violations);
|
|
75
|
-
const enriched = enrichViolations(scoped);
|
|
76
|
-
const hasViolations = enriched.length > 0;
|
|
77
|
-
const mode = accesslintParam?.test === "todo" ? "warning" : "failed";
|
|
78
|
-
const status = hasViolations ? mode : "passed";
|
|
79
|
-
const result = {
|
|
80
|
-
violations: enriched,
|
|
81
|
-
ruleCount: getActiveRules().length
|
|
82
|
-
};
|
|
83
|
-
addons.getChannel().emit(RESULT_EVENT, { storyId: id, result, status });
|
|
84
|
-
reporting.addReport({
|
|
85
|
-
type: "accesslint",
|
|
86
|
-
version: 1,
|
|
87
|
-
result,
|
|
88
|
-
status
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export { afterEach };
|
|
1
|
+
export { afterEach, initialGlobals, parameters } from './chunk-XTEGJNR3.js';
|
package/dist/vitest-setup.cjs
CHANGED
|
@@ -15,7 +15,9 @@ var __export = (target, all) => {
|
|
|
15
15
|
// src/preview.ts
|
|
16
16
|
var preview_exports = {};
|
|
17
17
|
__export(preview_exports, {
|
|
18
|
-
afterEach: () => afterEach
|
|
18
|
+
afterEach: () => afterEach,
|
|
19
|
+
initialGlobals: () => initialGlobals,
|
|
20
|
+
parameters: () => parameters
|
|
19
21
|
});
|
|
20
22
|
|
|
21
23
|
// src/constants.ts
|
|
@@ -23,6 +25,12 @@ var ADDON_ID = "accesslint/a11y";
|
|
|
23
25
|
var RESULT_EVENT = `${ADDON_ID}/result`;
|
|
24
26
|
|
|
25
27
|
// src/preview.ts
|
|
28
|
+
var initialGlobals = {
|
|
29
|
+
accesslint: {}
|
|
30
|
+
};
|
|
31
|
+
var parameters = {
|
|
32
|
+
accesslint: {}
|
|
33
|
+
};
|
|
26
34
|
core.configureRules({
|
|
27
35
|
disabledRules: ["accesslint-045"]
|
|
28
36
|
});
|
|
@@ -59,12 +67,12 @@ function enrichViolations(violations) {
|
|
|
59
67
|
}
|
|
60
68
|
var afterEach = async ({
|
|
61
69
|
reporting,
|
|
62
|
-
parameters,
|
|
70
|
+
parameters: parameters2,
|
|
63
71
|
viewMode,
|
|
64
72
|
tags,
|
|
65
73
|
id
|
|
66
74
|
}) => {
|
|
67
|
-
const accesslintParam =
|
|
75
|
+
const accesslintParam = parameters2?.accesslint;
|
|
68
76
|
if (accesslintParam?.disable === true || accesslintParam?.test === "off") return;
|
|
69
77
|
if (viewMode !== "story") return;
|
|
70
78
|
const skipTags = typeof __ACCESSLINT_SKIP_TAGS__ !== "undefined" ? __ACCESSLINT_SKIP_TAGS__ : [];
|
package/dist/vitest-setup.js
CHANGED
|
@@ -13,7 +13,9 @@ var __export = (target, all) => {
|
|
|
13
13
|
// src/preview.ts
|
|
14
14
|
var preview_exports = {};
|
|
15
15
|
__export(preview_exports, {
|
|
16
|
-
afterEach: () => afterEach
|
|
16
|
+
afterEach: () => afterEach,
|
|
17
|
+
initialGlobals: () => initialGlobals,
|
|
18
|
+
parameters: () => parameters
|
|
17
19
|
});
|
|
18
20
|
|
|
19
21
|
// src/constants.ts
|
|
@@ -21,6 +23,12 @@ var ADDON_ID = "accesslint/a11y";
|
|
|
21
23
|
var RESULT_EVENT = `${ADDON_ID}/result`;
|
|
22
24
|
|
|
23
25
|
// src/preview.ts
|
|
26
|
+
var initialGlobals = {
|
|
27
|
+
accesslint: {}
|
|
28
|
+
};
|
|
29
|
+
var parameters = {
|
|
30
|
+
accesslint: {}
|
|
31
|
+
};
|
|
24
32
|
configureRules({
|
|
25
33
|
disabledRules: ["accesslint-045"]
|
|
26
34
|
});
|
|
@@ -57,12 +65,12 @@ function enrichViolations(violations) {
|
|
|
57
65
|
}
|
|
58
66
|
var afterEach = async ({
|
|
59
67
|
reporting,
|
|
60
|
-
parameters,
|
|
68
|
+
parameters: parameters2,
|
|
61
69
|
viewMode,
|
|
62
70
|
tags,
|
|
63
71
|
id
|
|
64
72
|
}) => {
|
|
65
|
-
const accesslintParam =
|
|
73
|
+
const accesslintParam = parameters2?.accesslint;
|
|
66
74
|
if (accesslintParam?.disable === true || accesslintParam?.test === "off") return;
|
|
67
75
|
if (viewMode !== "story") return;
|
|
68
76
|
const skipTags = typeof __ACCESSLINT_SKIP_TAGS__ !== "undefined" ? __ACCESSLINT_SKIP_TAGS__ : [];
|