@accesslint/storybook-addon 0.8.0 → 0.8.3

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/manager.js CHANGED
@@ -56,6 +56,7 @@ var Panel = ({ active }) => {
56
56
  }), [isDark, theme]);
57
57
  const [violations, setViolations] = useState([]);
58
58
  const [ruleCount, setRuleCount] = useState(0);
59
+ const [skippedReason, setSkippedReason] = useState(null);
59
60
  const [expandedIndex, setExpandedIndex] = useState(null);
60
61
  const buttonRefs = useRef([]);
61
62
  useChannel({
@@ -63,13 +64,22 @@ var Panel = ({ active }) => {
63
64
  const report = reporters.find((r) => r.type === "accesslint");
64
65
  if (!report) return;
65
66
  const result = report.result;
67
+ if (result.skipped) {
68
+ setViolations([]);
69
+ setRuleCount(0);
70
+ setSkippedReason(result.reason ?? "skipped");
71
+ setExpandedIndex(null);
72
+ return;
73
+ }
66
74
  setViolations(result.violations ?? []);
67
75
  setRuleCount(result.ruleCount ?? 0);
76
+ setSkippedReason(null);
68
77
  setExpandedIndex(null);
69
78
  },
70
79
  [STORY_CHANGED]: () => {
71
80
  setViolations([]);
72
81
  setRuleCount(0);
82
+ setSkippedReason(null);
73
83
  setExpandedIndex(null);
74
84
  }
75
85
  });
@@ -108,7 +118,7 @@ var Panel = ({ active }) => {
108
118
  color: colors.textMuted,
109
119
  borderBottom: `1px solid ${colors.border}`,
110
120
  flexShrink: 0
111
- } }, /* @__PURE__ */ React.createElement("span", null, ruleCount, " rules"), /* @__PURE__ */ React.createElement("span", { style: { color: "#2e7d32" } }, passed, " passed"), /* @__PURE__ */ React.createElement("span", { style: { color: violations.length > 0 ? "#d32f2f" : colors.textMuted } }, new Set(violations.map((v) => v.ruleId)).size, " failed")), violations.length === 0 ? /* @__PURE__ */ React.createElement("p", { style: { padding: "12px", margin: 0, fontSize: "13px", color: colors.textMuted } }, "No accessibility violations found.") : /* @__PURE__ */ React.createElement("div", { style: { flex: 1, overflow: "auto", minHeight: 0 } }, /* @__PURE__ */ React.createElement(
121
+ } }, /* @__PURE__ */ React.createElement("span", null, ruleCount, " rules"), /* @__PURE__ */ React.createElement("span", { style: { color: "#2e7d32" } }, passed, " passed"), /* @__PURE__ */ React.createElement("span", { style: { color: violations.length > 0 ? "#d32f2f" : colors.textMuted } }, new Set(violations.map((v) => v.ruleId)).size, " failed")), violations.length === 0 ? /* @__PURE__ */ React.createElement("p", { style: { padding: "12px", margin: 0, fontSize: "13px", color: colors.textMuted } }, skippedReason ? `Accessibility audit skipped (${skippedReason} tag).` : "No accessibility violations found.") : /* @__PURE__ */ React.createElement("div", { style: { flex: 1, overflow: "auto", minHeight: 0 } }, /* @__PURE__ */ React.createElement(
112
122
  "ul",
113
123
  {
114
124
  style: { listStyle: "none", padding: 0, margin: 0 },
package/dist/portable.cjs CHANGED
@@ -16,6 +16,10 @@ __export(preview_exports, {
16
16
  core.configureRules({
17
17
  disabledRules: ["accesslint-045"]
18
18
  });
19
+ var BUDGET_MS = 12;
20
+ function yieldToMain() {
21
+ return new Promise((resolve) => setTimeout(resolve, 0));
22
+ }
19
23
  function scopeViolations(violations) {
20
24
  const root = document.getElementById("storybook-root");
21
25
  if (!root) return violations;
@@ -52,11 +56,24 @@ var afterEach = async ({
52
56
  const accesslintParam = parameters?.accesslint;
53
57
  if (accesslintParam?.disable === true || accesslintParam?.test === "off") return;
54
58
  if (viewMode !== "story") return;
55
- if (tags?.includes("no-a11y")) return;
56
59
  const skipTags = typeof __ACCESSLINT_SKIP_TAGS__ !== "undefined" ? __ACCESSLINT_SKIP_TAGS__ : [];
57
- if (skipTags.length > 0 && tags?.some((t) => skipTags.includes(t))) return;
58
- const result = core.runAudit(document);
59
- const scoped = scopeViolations(result.violations);
60
+ const allSkipTags = ["no-a11y", ...skipTags];
61
+ const matchedTag = tags?.find((t) => allSkipTags.includes(t));
62
+ if (matchedTag) {
63
+ reporting.addReport({
64
+ type: "accesslint",
65
+ version: 1,
66
+ result: { skipped: true, reason: matchedTag },
67
+ status: "passed"
68
+ });
69
+ return;
70
+ }
71
+ const audit = core.createChunkedAudit(document);
72
+ while (audit.processChunk(BUDGET_MS)) {
73
+ await yieldToMain();
74
+ }
75
+ const violations = audit.getViolations();
76
+ const scoped = scopeViolations(violations);
60
77
  const enriched = enrichViolations(scoped);
61
78
  const hasViolations = enriched.length > 0;
62
79
  const mode = accesslintParam?.test === "todo" ? "warning" : "failed";
@@ -65,7 +82,7 @@ var afterEach = async ({
65
82
  version: 1,
66
83
  result: {
67
84
  violations: enriched,
68
- ruleCount: result.ruleCount
85
+ ruleCount: core.getActiveRules().length
69
86
  },
70
87
  status: hasViolations ? mode : "passed"
71
88
  });
package/dist/portable.js CHANGED
@@ -1,4 +1,4 @@
1
- import { configureRules, runAudit, getRuleById } from '@accesslint/core';
1
+ import { configureRules, createChunkedAudit, getActiveRules, getRuleById } from '@accesslint/core';
2
2
 
3
3
  var __defProp = Object.defineProperty;
4
4
  var __export = (target, all) => {
@@ -14,6 +14,10 @@ __export(preview_exports, {
14
14
  configureRules({
15
15
  disabledRules: ["accesslint-045"]
16
16
  });
17
+ var BUDGET_MS = 12;
18
+ function yieldToMain() {
19
+ return new Promise((resolve) => setTimeout(resolve, 0));
20
+ }
17
21
  function scopeViolations(violations) {
18
22
  const root = document.getElementById("storybook-root");
19
23
  if (!root) return violations;
@@ -50,11 +54,24 @@ var afterEach = async ({
50
54
  const accesslintParam = parameters?.accesslint;
51
55
  if (accesslintParam?.disable === true || accesslintParam?.test === "off") return;
52
56
  if (viewMode !== "story") return;
53
- if (tags?.includes("no-a11y")) return;
54
57
  const skipTags = typeof __ACCESSLINT_SKIP_TAGS__ !== "undefined" ? __ACCESSLINT_SKIP_TAGS__ : [];
55
- if (skipTags.length > 0 && tags?.some((t) => skipTags.includes(t))) return;
56
- const result = runAudit(document);
57
- const scoped = scopeViolations(result.violations);
58
+ const allSkipTags = ["no-a11y", ...skipTags];
59
+ const matchedTag = tags?.find((t) => allSkipTags.includes(t));
60
+ if (matchedTag) {
61
+ reporting.addReport({
62
+ type: "accesslint",
63
+ version: 1,
64
+ result: { skipped: true, reason: matchedTag },
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);
58
75
  const enriched = enrichViolations(scoped);
59
76
  const hasViolations = enriched.length > 0;
60
77
  const mode = accesslintParam?.test === "todo" ? "warning" : "failed";
@@ -63,7 +80,7 @@ var afterEach = async ({
63
80
  version: 1,
64
81
  result: {
65
82
  violations: enriched,
66
- ruleCount: result.ruleCount
83
+ ruleCount: getActiveRules().length
67
84
  },
68
85
  status: hasViolations ? mode : "passed"
69
86
  });
package/dist/preview.cjs CHANGED
@@ -6,6 +6,10 @@ var core = require('@accesslint/core');
6
6
  core.configureRules({
7
7
  disabledRules: ["accesslint-045"]
8
8
  });
9
+ var BUDGET_MS = 12;
10
+ function yieldToMain() {
11
+ return new Promise((resolve) => setTimeout(resolve, 0));
12
+ }
9
13
  function scopeViolations(violations) {
10
14
  const root = document.getElementById("storybook-root");
11
15
  if (!root) return violations;
@@ -42,11 +46,24 @@ var afterEach = async ({
42
46
  const accesslintParam = parameters?.accesslint;
43
47
  if (accesslintParam?.disable === true || accesslintParam?.test === "off") return;
44
48
  if (viewMode !== "story") return;
45
- if (tags?.includes("no-a11y")) return;
46
49
  const skipTags = typeof __ACCESSLINT_SKIP_TAGS__ !== "undefined" ? __ACCESSLINT_SKIP_TAGS__ : [];
47
- if (skipTags.length > 0 && tags?.some((t) => skipTags.includes(t))) return;
48
- const result = core.runAudit(document);
49
- const scoped = scopeViolations(result.violations);
50
+ const allSkipTags = ["no-a11y", ...skipTags];
51
+ const matchedTag = tags?.find((t) => allSkipTags.includes(t));
52
+ if (matchedTag) {
53
+ reporting.addReport({
54
+ type: "accesslint",
55
+ version: 1,
56
+ result: { skipped: true, reason: matchedTag },
57
+ status: "passed"
58
+ });
59
+ return;
60
+ }
61
+ const audit = core.createChunkedAudit(document);
62
+ while (audit.processChunk(BUDGET_MS)) {
63
+ await yieldToMain();
64
+ }
65
+ const violations = audit.getViolations();
66
+ const scoped = scopeViolations(violations);
50
67
  const enriched = enrichViolations(scoped);
51
68
  const hasViolations = enriched.length > 0;
52
69
  const mode = accesslintParam?.test === "todo" ? "warning" : "failed";
@@ -55,7 +72,7 @@ var afterEach = async ({
55
72
  version: 1,
56
73
  result: {
57
74
  violations: enriched,
58
- ruleCount: result.ruleCount
75
+ ruleCount: core.getActiveRules().length
59
76
  },
60
77
  status: hasViolations ? mode : "passed"
61
78
  });
package/dist/preview.js CHANGED
@@ -1,9 +1,13 @@
1
- import { configureRules, runAudit, getRuleById } from '@accesslint/core';
1
+ import { configureRules, createChunkedAudit, getActiveRules, getRuleById } from '@accesslint/core';
2
2
 
3
3
  // src/preview.ts
4
4
  configureRules({
5
5
  disabledRules: ["accesslint-045"]
6
6
  });
7
+ var BUDGET_MS = 12;
8
+ function yieldToMain() {
9
+ return new Promise((resolve) => setTimeout(resolve, 0));
10
+ }
7
11
  function scopeViolations(violations) {
8
12
  const root = document.getElementById("storybook-root");
9
13
  if (!root) return violations;
@@ -40,11 +44,24 @@ var afterEach = async ({
40
44
  const accesslintParam = parameters?.accesslint;
41
45
  if (accesslintParam?.disable === true || accesslintParam?.test === "off") return;
42
46
  if (viewMode !== "story") return;
43
- if (tags?.includes("no-a11y")) return;
44
47
  const skipTags = typeof __ACCESSLINT_SKIP_TAGS__ !== "undefined" ? __ACCESSLINT_SKIP_TAGS__ : [];
45
- if (skipTags.length > 0 && tags?.some((t) => skipTags.includes(t))) return;
46
- const result = runAudit(document);
47
- const scoped = scopeViolations(result.violations);
48
+ const allSkipTags = ["no-a11y", ...skipTags];
49
+ const matchedTag = tags?.find((t) => allSkipTags.includes(t));
50
+ if (matchedTag) {
51
+ reporting.addReport({
52
+ type: "accesslint",
53
+ version: 1,
54
+ result: { skipped: true, reason: matchedTag },
55
+ status: "passed"
56
+ });
57
+ return;
58
+ }
59
+ const audit = createChunkedAudit(document);
60
+ while (audit.processChunk(BUDGET_MS)) {
61
+ await yieldToMain();
62
+ }
63
+ const violations = audit.getViolations();
64
+ const scoped = scopeViolations(violations);
48
65
  const enriched = enrichViolations(scoped);
49
66
  const hasViolations = enriched.length > 0;
50
67
  const mode = accesslintParam?.test === "todo" ? "warning" : "failed";
@@ -53,7 +70,7 @@ var afterEach = async ({
53
70
  version: 1,
54
71
  result: {
55
72
  violations: enriched,
56
- ruleCount: result.ruleCount
73
+ ruleCount: getActiveRules().length
57
74
  },
58
75
  status: hasViolations ? mode : "passed"
59
76
  });
@@ -20,6 +20,10 @@ __export(preview_exports, {
20
20
  core.configureRules({
21
21
  disabledRules: ["accesslint-045"]
22
22
  });
23
+ var BUDGET_MS = 12;
24
+ function yieldToMain() {
25
+ return new Promise((resolve) => setTimeout(resolve, 0));
26
+ }
23
27
  function scopeViolations(violations) {
24
28
  const root = document.getElementById("storybook-root");
25
29
  if (!root) return violations;
@@ -56,11 +60,24 @@ var afterEach = async ({
56
60
  const accesslintParam = parameters?.accesslint;
57
61
  if (accesslintParam?.disable === true || accesslintParam?.test === "off") return;
58
62
  if (viewMode !== "story") return;
59
- if (tags?.includes("no-a11y")) return;
60
63
  const skipTags = typeof __ACCESSLINT_SKIP_TAGS__ !== "undefined" ? __ACCESSLINT_SKIP_TAGS__ : [];
61
- if (skipTags.length > 0 && tags?.some((t) => skipTags.includes(t))) return;
62
- const result = core.runAudit(document);
63
- const scoped = scopeViolations(result.violations);
64
+ const allSkipTags = ["no-a11y", ...skipTags];
65
+ const matchedTag = tags?.find((t) => allSkipTags.includes(t));
66
+ if (matchedTag) {
67
+ reporting.addReport({
68
+ type: "accesslint",
69
+ version: 1,
70
+ result: { skipped: true, reason: matchedTag },
71
+ status: "passed"
72
+ });
73
+ return;
74
+ }
75
+ const audit = core.createChunkedAudit(document);
76
+ while (audit.processChunk(BUDGET_MS)) {
77
+ await yieldToMain();
78
+ }
79
+ const violations = audit.getViolations();
80
+ const scoped = scopeViolations(violations);
64
81
  const enriched = enrichViolations(scoped);
65
82
  const hasViolations = enriched.length > 0;
66
83
  const mode = accesslintParam?.test === "todo" ? "warning" : "failed";
@@ -69,7 +86,7 @@ var afterEach = async ({
69
86
  version: 1,
70
87
  result: {
71
88
  violations: enriched,
72
- ruleCount: result.ruleCount
89
+ ruleCount: core.getActiveRules().length
73
90
  },
74
91
  status: hasViolations ? mode : "passed"
75
92
  });
@@ -1,7 +1,7 @@
1
1
  import { expect } from 'storybook/test';
2
2
  import { expect as expect$1 } from 'vitest';
3
3
  import { composeConfigs } from 'storybook/preview-api';
4
- import { configureRules, runAudit, getRuleById } from '@accesslint/core';
4
+ import { configureRules, createChunkedAudit, getActiveRules, getRuleById } from '@accesslint/core';
5
5
  import { accesslintMatchers } from '@accesslint/vitest/matchers';
6
6
 
7
7
  var __defProp = Object.defineProperty;
@@ -18,6 +18,10 @@ __export(preview_exports, {
18
18
  configureRules({
19
19
  disabledRules: ["accesslint-045"]
20
20
  });
21
+ var BUDGET_MS = 12;
22
+ function yieldToMain() {
23
+ return new Promise((resolve) => setTimeout(resolve, 0));
24
+ }
21
25
  function scopeViolations(violations) {
22
26
  const root = document.getElementById("storybook-root");
23
27
  if (!root) return violations;
@@ -54,11 +58,24 @@ var afterEach = async ({
54
58
  const accesslintParam = parameters?.accesslint;
55
59
  if (accesslintParam?.disable === true || accesslintParam?.test === "off") return;
56
60
  if (viewMode !== "story") return;
57
- if (tags?.includes("no-a11y")) return;
58
61
  const skipTags = typeof __ACCESSLINT_SKIP_TAGS__ !== "undefined" ? __ACCESSLINT_SKIP_TAGS__ : [];
59
- if (skipTags.length > 0 && tags?.some((t) => skipTags.includes(t))) return;
60
- const result = runAudit(document);
61
- const scoped = scopeViolations(result.violations);
62
+ const allSkipTags = ["no-a11y", ...skipTags];
63
+ const matchedTag = tags?.find((t) => allSkipTags.includes(t));
64
+ if (matchedTag) {
65
+ reporting.addReport({
66
+ type: "accesslint",
67
+ version: 1,
68
+ result: { skipped: true, reason: matchedTag },
69
+ status: "passed"
70
+ });
71
+ return;
72
+ }
73
+ const audit = createChunkedAudit(document);
74
+ while (audit.processChunk(BUDGET_MS)) {
75
+ await yieldToMain();
76
+ }
77
+ const violations = audit.getViolations();
78
+ const scoped = scopeViolations(violations);
62
79
  const enriched = enrichViolations(scoped);
63
80
  const hasViolations = enriched.length > 0;
64
81
  const mode = accesslintParam?.test === "todo" ? "warning" : "failed";
@@ -67,7 +84,7 @@ var afterEach = async ({
67
84
  version: 1,
68
85
  result: {
69
86
  violations: enriched,
70
- ruleCount: result.ruleCount
87
+ ruleCount: getActiveRules().length
71
88
  },
72
89
  status: hasViolations ? mode : "passed"
73
90
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@accesslint/storybook-addon",
3
- "version": "0.8.0",
3
+ "version": "0.8.3",
4
4
  "description": "Catch accessibility violations in your Storybook stories as you develop",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -67,10 +67,11 @@
67
67
  "storybook": "^10.2.0",
68
68
  "tsup": "^8.4.0",
69
69
  "typescript": "^5.7.0",
70
- "vitest": "^3.0.0"
70
+ "vitest": "^4.0.18"
71
71
  },
72
72
  "peerDependencies": {
73
- "storybook": "^9.0.0 || ^10.0.0"
73
+ "storybook": "^9.0.0 || ^10.0.0",
74
+ "vitest": ">=3.0.0"
74
75
  },
75
76
  "keywords": [
76
77
  "storybook-addon",