Skip to content

Commit 5dac26f

Browse files
authored
Upgrade to Storybook 8 in FAST Foundation (#6929)
* add eslint rules for type imports * add vite client types for SVG imports * upgrade to Storybook 8 * migrate Storybook config for v8 * remove storybook manager script * migrate Storybook preview script for v8 * separate type-only imports * eslintrc change * update tests to work with Storybook 8 * restore sideEffects config by using vite glob imports in storybook preview - use globalThis for html function in tests * remove unused dev dependencies - Update csf - Fix storybook helper types - update docs * fix parse5 type imports * update api-report * resolve lockfile * Change files
1 parent 848779c commit 5dac26f

File tree

174 files changed

+2635
-4631
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+2635
-4631
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "upgrade to Storybook 8",
4+
"packageName": "@microsoft/fast-foundation",
5+
"email": "[email protected]",
6+
"dependentChangeType": "prerelease"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "none",
3+
"comment": "fix parse5 type imports",
4+
"packageName": "@microsoft/fast-ssr",
5+
"email": "[email protected]",
6+
"dependentChangeType": "none"
7+
}

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232
"**/react-dom",
3333
"**/react-syntax-highlighter",
3434
"**/typescript",
35-
"**/webpack",
36-
"**/@storybook/builder-webpack5",
37-
"**/@storybook/builder-webpack5/**"
35+
"**/webpack"
3836
]
3937
},
4038
"engines": {

packages/web-components/fast-foundation/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ dist
33
node_modules
44
*.spec.ts
55
!*.pw.spec.ts
6+
.eslintrc.*
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const path = require("path");
2+
3+
module.exports = {
4+
extends: [
5+
"@microsoft/eslint-config-fast-dna",
6+
"prettier",
7+
"plugin:storybook/recommended",
8+
],
9+
rules: {
10+
"@typescript-eslint/naming-convention": [
11+
"error",
12+
{
13+
selector: "typeLike",
14+
format: ["UPPER_CASE", "camelCase", "PascalCase"],
15+
leadingUnderscore: "allow",
16+
},
17+
],
18+
"@typescript-eslint/ban-types": [
19+
"error",
20+
{
21+
types: {
22+
"{}": false,
23+
Function: false,
24+
Object: false,
25+
},
26+
extendDefaults: true,
27+
},
28+
],
29+
},
30+
overrides: [
31+
{
32+
files: ["**/*.cjs"],
33+
env: {
34+
commonjs: true,
35+
node: true,
36+
},
37+
rules: {
38+
"@typescript-eslint/no-var-requires": "off",
39+
},
40+
},
41+
{
42+
files: ["**/*.ts"],
43+
excludedFiles: ["playwright.config.ts"],
44+
parserOptions: {
45+
parser: "@typescript-eslint/parser",
46+
project: path.resolve(__dirname, "./tsconfig.json"),
47+
},
48+
rules: {
49+
"@typescript-eslint/consistent-type-imports": "error",
50+
"@typescript-eslint/consistent-type-exports": [
51+
"error",
52+
{ fixMixedExportsWithInlineTypeSpecifier: false },
53+
],
54+
},
55+
},
56+
{
57+
files: ["**/*.ts"],
58+
excludedFiles: ["**/*.stories.ts"],
59+
rules: {
60+
"no-restricted-imports": [
61+
"error",
62+
{ patterns: ["**/stories/**", "**/*.pw.spec.ts"] },
63+
],
64+
},
65+
},
66+
],
67+
};

packages/web-components/fast-foundation/.eslintrc.json

Lines changed: 0 additions & 39 deletions
This file was deleted.

packages/web-components/fast-foundation/.storybook/main.cjs

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import type { StorybookConfig } from "@storybook/html-vite";
2+
3+
const config: StorybookConfig = {
4+
stories: ["../src/**/stories/*.stories.ts", "debug.stories.ts"],
5+
framework: "@storybook/html-vite",
6+
addons: ["@storybook/addon-essentials"],
7+
core: {
8+
disableTelemetry: true,
9+
disableWhatsNewNotifications: true,
10+
},
11+
async viteFinal(config) {
12+
const { mergeConfig } = await import("vite");
13+
14+
return mergeConfig(config, {
15+
build: { chunkSizeWarningLimit: 1000 },
16+
resolve: {
17+
alias: [{ find: /^(.*\.svg)$/, replacement: "$1?raw" }],
18+
},
19+
});
20+
},
21+
};
22+
23+
export default config;

packages/web-components/fast-foundation/.storybook/manager.mjs

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/web-components/fast-foundation/.storybook/preview.js

Lines changed: 0 additions & 71 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/// <reference types="vite/client" />
2+
3+
// Import all component definitions. This is a vite-specific feature:
4+
// https://vitejs.dev/guide/features.html#glob-import
5+
const modules = import.meta.glob("../src/**/*.register.ts");
6+
7+
for (const path in modules) {
8+
modules[path]();
9+
}
10+
11+
// Provide the `html` tag function as a global. This is needed for some tests.
12+
(async () => {
13+
const { html } = await import("@microsoft/fast-element");
14+
15+
Object.defineProperty(globalThis, "html", {
16+
value: html,
17+
writable: false,
18+
});
19+
})();

packages/web-components/fast-foundation/docs/api-report.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
55
```ts
66

7-
import { CaptureType } from '@microsoft/fast-element';
8-
import { Constructable } from '@microsoft/fast-element';
9-
import { CSSDirective } from '@microsoft/fast-element';
7+
import type { CaptureType } from '@microsoft/fast-element';
8+
import type { Constructable } from '@microsoft/fast-element';
9+
import type { CSSDirective } from '@microsoft/fast-element';
1010
import { Direction } from '@microsoft/fast-web-utilities';
1111
import type { ElementsFilter } from '@microsoft/fast-element';
12-
import { ElementStyles } from '@microsoft/fast-element';
13-
import { ElementViewTemplate } from '@microsoft/fast-element';
12+
import type { ElementStyles } from '@microsoft/fast-element';
13+
import type { ElementViewTemplate } from '@microsoft/fast-element';
1414
import { FASTElement } from '@microsoft/fast-element';
1515
import { FASTElementDefinition } from '@microsoft/fast-element';
16-
import { HostBehavior } from '@microsoft/fast-element';
17-
import { HostController } from '@microsoft/fast-element';
18-
import { HTMLDirective } from '@microsoft/fast-element';
16+
import type { HostBehavior } from '@microsoft/fast-element';
17+
import type { HostController } from '@microsoft/fast-element';
18+
import type { HTMLDirective } from '@microsoft/fast-element';
1919
import { Orientation } from '@microsoft/fast-web-utilities';
2020
import type { SyntheticViewTemplate } from '@microsoft/fast-element';
21-
import { ViewTemplate } from '@microsoft/fast-element';
21+
import type { ViewTemplate } from '@microsoft/fast-element';
2222

2323
// @public
2424
export const AccordionExpandMode: {
@@ -2895,9 +2895,9 @@ export type YearFormat = ValuesOf<typeof YearFormat>;
28952895

28962896
// Warnings were encountered during analysis:
28972897
//
2898-
// dist/dts/calendar/calendar.d.ts:51:5 - (ae-incompatible-release-tags) The symbol "dataGridCell" is marked as @public, but its signature references "TemplateElementDependency" which is marked as @beta
2899-
// dist/dts/calendar/calendar.d.ts:52:5 - (ae-incompatible-release-tags) The symbol "dataGridRow" is marked as @public, but its signature references "TemplateElementDependency" which is marked as @beta
2900-
// dist/dts/calendar/calendar.d.ts:53:5 - (ae-incompatible-release-tags) The symbol "dataGrid" is marked as @public, but its signature references "TemplateElementDependency" which is marked as @beta
2898+
// dist/dts/calendar/calendar.d.ts:52:5 - (ae-incompatible-release-tags) The symbol "dataGridCell" is marked as @public, but its signature references "TemplateElementDependency" which is marked as @beta
2899+
// dist/dts/calendar/calendar.d.ts:53:5 - (ae-incompatible-release-tags) The symbol "dataGridRow" is marked as @public, but its signature references "TemplateElementDependency" which is marked as @beta
2900+
// dist/dts/calendar/calendar.d.ts:54:5 - (ae-incompatible-release-tags) The symbol "dataGrid" is marked as @public, but its signature references "TemplateElementDependency" which is marked as @beta
29012901
// dist/dts/data-grid/data-grid-row.template.d.ts:9:5 - (ae-incompatible-release-tags) The symbol "dataGridCell" is marked as @public, but its signature references "TemplateElementDependency" which is marked as @beta
29022902
// dist/dts/data-grid/data-grid.template.d.ts:9:5 - (ae-incompatible-release-tags) The symbol "dataGridRow" is marked as @public, but its signature references "TemplateElementDependency" which is marked as @beta
29032903
// dist/dts/picker/picker.template.d.ts:9:5 - (ae-incompatible-release-tags) The symbol "anchoredRegion" is marked as @public, but its signature references "TemplateElementDependency" which is marked as @beta

0 commit comments

Comments
 (0)