Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.

Commit 71c8f56

Browse files
committed
Add preview annotations and fix typecheck errors
- Export initialGlobals and parameters from preview.ts - Add default export with definePreviewAddon() in index.ts - Move index.ts from nodeEntries to previewEntries - Fix storybook imports to use public export paths - Add @types/react and @types/react-dom dev dependencies
1 parent b39c14e commit 71c8f56

5 files changed

Lines changed: 22 additions & 9 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@accesslint/storybook-addon",
3-
"version": "0.8.5",
3+
"version": "0.8.6",
44
"description": "Catch accessibility violations in your Storybook stories as you develop",
55
"license": "MIT",
66
"publishConfig": {

src/Panel.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState, useMemo, useRef, useCallback, type FC } from "react";
2-
import { useChannel } from "storybook/internal/manager-api";
3-
import { useTheme } from "storybook/internal/theming";
2+
import { useChannel } from "storybook/manager-api";
3+
import { useTheme } from "storybook/theming";
44
import { STORY_CHANGED } from "storybook/internal/core-events";
55
import { RESULT_EVENT, HIGHLIGHT, REMOVE_HIGHLIGHT } from "./constants";
66

@@ -45,7 +45,7 @@ const LEVEL_COLOR: Record<string, string> = {
4545
};
4646

4747
interface PanelProps {
48-
active: boolean;
48+
active?: boolean;
4949
}
5050

5151
export const Panel: FC<PanelProps> = ({ active }) => {

src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
// Preset entry — re-exports for node environment
2-
export {};
1+
import { definePreviewAddon } from "storybook/internal/csf";
2+
import type { ProjectAnnotations, Renderer } from "storybook/internal/types";
3+
import * as addonAnnotations from "./preview";
4+
5+
export default () =>
6+
definePreviewAddon(addonAnnotations as ProjectAnnotations<Renderer>);

src/manager.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
2-
import * as managerApi from "storybook/internal/manager-api";
3-
import { styled } from "storybook/internal/theming";
2+
import * as managerApi from "storybook/manager-api";
3+
import { styled } from "storybook/theming";
44
import { ADDON_ID, PARAM_KEY, STATUS_TYPE_ID, RESULT_EVENT } from "./constants";
55
import { Panel } from "./Panel";
66

@@ -29,6 +29,7 @@ if (testProviderStore && statusStore) {
2929
}
3030

3131
// ActionList and Form only exist in Storybook 10+
32+
declare const require: (id: string) => any;
3233
let ActionList: any = null;
3334
let Form: any = null;
3435
try {

src/preview.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ import { createChunkedAudit, getActiveRules, getRuleById, configureRules } from
22
import { addons } from "storybook/preview-api";
33
import { RESULT_EVENT } from "./constants";
44

5+
export const initialGlobals = {
6+
accesslint: {},
7+
};
8+
9+
export const parameters = {
10+
accesslint: {},
11+
};
12+
513
// Defined by the accesslintTest() Vite plugin when tags.skip is configured
614
declare const __ACCESSLINT_SKIP_TAGS__: string[];
715

@@ -53,7 +61,7 @@ export const afterEach = async ({
5361
tags,
5462
id,
5563
}: {
56-
reporting: { addReport: (report: Record<string, unknown>) => void };
64+
reporting: { addReport: (report: { type: string; version?: number; result: unknown; status: "failed" | "passed" | "warning" }) => void };
5765
parameters: Record<string, unknown>;
5866
viewMode: string;
5967
tags?: string[];

0 commit comments

Comments
 (0)