From a844844540a69a1186ffd5f12d5876625cf2310c Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 15 Jun 2022 16:11:44 +0200 Subject: [PATCH 01/12] remove regenerator-runtime, where it's no longer used --- addons/a11y/package.json | 1 - addons/actions/package.json | 1 - addons/backgrounds/package.json | 1 - addons/docs/package.json | 1 - addons/essentials/package.json | 1 - addons/jest/package.json | 1 - addons/links/package.json | 1 - addons/outline/package.json | 1 - .../storyshots/storyshots-core/package.json | 1 - .../storyshots-puppeteer/package.json | 3 +- addons/storysource/package.json | 3 +- addons/toolbars/package.json | 3 +- addons/viewport/package.json | 3 +- frameworks/angular/package.json | 1 - frameworks/ember/package.json | 1 - frameworks/html-webpack5/package.json | 3 +- frameworks/preact-webpack5/package.json | 3 +- frameworks/react-webpack5/package.json | 3 +- frameworks/server-webpack5/package.json | 3 +- frameworks/svelte-webpack5/package.json | 3 +- frameworks/vue-webpack5/package.json | 3 +- frameworks/vue3-webpack5/package.json | 3 +- .../web-components-webpack5/package.json | 3 +- lib/addons/package.json | 3 +- lib/api/package.json | 1 - lib/client-api/package.json | 1 - lib/codemod/package.json | 3 +- lib/components/package.json | 1 - lib/core-server/package.json | 1 - lib/csf-tools/package.json | 1 - lib/docs-tools/package.json | 3 +- lib/manager-webpack5/package.json | 1 - lib/preview-web/package.json | 1 - lib/router/package.json | 3 +- lib/source-loader/package.json | 3 +- lib/store/package.json | 1 - lib/telemetry/package.json | 3 +- lib/theming/package.json | 3 +- lib/ui/package.json | 1 - presets/preact-webpack/package.json | 3 +- presets/react-webpack/package.json | 3 +- presets/server-webpack/package.json | 1 - presets/svelte-webpack/package.json | 1 - presets/vue-webpack/package.json | 1 - presets/vue3-webpack/package.json | 1 - presets/web-components-webpack/package.json | 3 +- renderers/html/package.json | 1 - renderers/preact/package.json | 1 - renderers/react/package.json | 1 - renderers/server/package.json | 1 - renderers/svelte/package.json | 1 - renderers/vue/package.json | 1 - renderers/vue3/package.json | 1 - renderers/web-components/package.json | 1 - yarn.lock | 54 ------------------- 55 files changed, 22 insertions(+), 130 deletions(-) diff --git a/addons/a11y/package.json b/addons/a11y/package.json index ee41e7ac8a78..c62969858884 100644 --- a/addons/a11y/package.json +++ b/addons/a11y/package.json @@ -51,7 +51,6 @@ "global": "^4.4.0", "lodash": "^4.17.21", "react-sizeme": "^3.0.1", - "regenerator-runtime": "^0.13.7", "ts-dedent": "^2.0.0", "util-deprecate": "^1.0.2" }, diff --git a/addons/actions/package.json b/addons/actions/package.json index 4fd1fdde517c..00975e49524c 100644 --- a/addons/actions/package.json +++ b/addons/actions/package.json @@ -48,7 +48,6 @@ "polished": "^4.2.2", "prop-types": "^15.7.2", "react-inspector": "^5.1.0", - "regenerator-runtime": "^0.13.7", "telejson": "^6.0.8", "ts-dedent": "^2.0.0", "util-deprecate": "^1.0.2", diff --git a/addons/backgrounds/package.json b/addons/backgrounds/package.json index ad5c676d91cf..472782cac2d6 100644 --- a/addons/backgrounds/package.json +++ b/addons/backgrounds/package.json @@ -48,7 +48,6 @@ "core-js": "^3.8.2", "global": "^4.4.0", "memoizerific": "^1.11.3", - "regenerator-runtime": "^0.13.7", "ts-dedent": "^2.0.0", "util-deprecate": "^1.0.2" }, diff --git a/addons/docs/package.json b/addons/docs/package.json index eb4a8f4c1d65..37eddf5f46b2 100644 --- a/addons/docs/package.json +++ b/addons/docs/package.json @@ -72,7 +72,6 @@ "fast-deep-equal": "^3.1.3", "global": "^4.4.0", "lodash": "^4.17.21", - "regenerator-runtime": "^0.13.7", "remark-external-links": "^8.0.0", "remark-slug": "^6.0.0", "ts-dedent": "^2.0.0", diff --git a/addons/essentials/package.json b/addons/essentials/package.json index 2a2153ece678..5c81f2bec0cd 100644 --- a/addons/essentials/package.json +++ b/addons/essentials/package.json @@ -45,7 +45,6 @@ "@storybook/core-common": "7.0.0-alpha.2", "@storybook/node-logger": "7.0.0-alpha.2", "core-js": "^3.8.2", - "regenerator-runtime": "^0.13.7", "ts-dedent": "^2.0.0" }, "devDependencies": { diff --git a/addons/jest/package.json b/addons/jest/package.json index 14a6d977424f..c2c2b9af764f 100644 --- a/addons/jest/package.json +++ b/addons/jest/package.json @@ -49,7 +49,6 @@ "core-js": "^3.8.2", "global": "^4.4.0", "react-sizeme": "^3.0.1", - "regenerator-runtime": "^0.13.7", "upath": "^1.2.0" }, "peerDependencies": { diff --git a/addons/links/package.json b/addons/links/package.json index aaffc9d314b7..ace62a23e691 100644 --- a/addons/links/package.json +++ b/addons/links/package.json @@ -42,7 +42,6 @@ "core-js": "^3.8.2", "global": "^4.4.0", "prop-types": "^15.7.2", - "regenerator-runtime": "^0.13.7", "ts-dedent": "^2.0.0" }, "peerDependencies": { diff --git a/addons/outline/package.json b/addons/outline/package.json index dcc4d7e1dc9d..7d4cb05b0682 100644 --- a/addons/outline/package.json +++ b/addons/outline/package.json @@ -48,7 +48,6 @@ "@storybook/csf": "0.0.2--canary.4566f4d.1", "core-js": "^3.8.2", "global": "^4.4.0", - "regenerator-runtime": "^0.13.7", "ts-dedent": "^2.0.0" }, "peerDependencies": { diff --git a/addons/storyshots/storyshots-core/package.json b/addons/storyshots/storyshots-core/package.json index 51311d014873..cc64377ec125 100644 --- a/addons/storyshots/storyshots-core/package.json +++ b/addons/storyshots/storyshots-core/package.json @@ -55,7 +55,6 @@ "pretty-format": "^26.6.2", "react-test-renderer": "^16.8.0 || ^17.0.0", "read-pkg-up": "^7.0.1", - "regenerator-runtime": "^0.13.7", "ts-dedent": "^2.0.0" }, "devDependencies": { diff --git a/addons/storyshots/storyshots-puppeteer/package.json b/addons/storyshots/storyshots-puppeteer/package.json index 95189de1e37a..314d66a59b3a 100644 --- a/addons/storyshots/storyshots-puppeteer/package.json +++ b/addons/storyshots/storyshots-puppeteer/package.json @@ -38,8 +38,7 @@ "@storybook/node-logger": "7.0.0-alpha.2", "@types/jest-image-snapshot": "^4.1.3", "core-js": "^3.8.2", - "jest-image-snapshot": "^4.3.0", - "regenerator-runtime": "^0.13.7" + "jest-image-snapshot": "^4.3.0" }, "devDependencies": { "@storybook/csf": "0.0.2--canary.4566f4d.1", diff --git a/addons/storysource/package.json b/addons/storysource/package.json index 7e5410738cc0..23f58272c81c 100644 --- a/addons/storysource/package.json +++ b/addons/storysource/package.json @@ -44,8 +44,7 @@ "core-js": "^3.8.2", "estraverse": "^5.2.0", "prop-types": "^15.7.2", - "react-syntax-highlighter": "^15.4.5", - "regenerator-runtime": "^0.13.7" + "react-syntax-highlighter": "^15.4.5" }, "devDependencies": { "@types/react": "^16.14.23", diff --git a/addons/toolbars/package.json b/addons/toolbars/package.json index 21593199b0ea..200b08ed47d5 100644 --- a/addons/toolbars/package.json +++ b/addons/toolbars/package.json @@ -43,8 +43,7 @@ "@storybook/client-logger": "7.0.0-alpha.2", "@storybook/components": "7.0.0-alpha.2", "@storybook/theming": "7.0.0-alpha.2", - "core-js": "^3.8.2", - "regenerator-runtime": "^0.13.7" + "core-js": "^3.8.2" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0", diff --git a/addons/viewport/package.json b/addons/viewport/package.json index 03341bd51b36..b6462b583f61 100644 --- a/addons/viewport/package.json +++ b/addons/viewport/package.json @@ -44,8 +44,7 @@ "core-js": "^3.8.2", "global": "^4.4.0", "memoizerific": "^1.11.3", - "prop-types": "^15.7.2", - "regenerator-runtime": "^0.13.7" + "prop-types": "^15.7.2" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0", diff --git a/frameworks/angular/package.json b/frameworks/angular/package.json index dac8544a3c51..ac4b3d13cd88 100644 --- a/frameworks/angular/package.json +++ b/frameworks/angular/package.json @@ -62,7 +62,6 @@ "react": "^16.14.0", "react-dom": "^16.14.0", "read-pkg-up": "^7.0.1", - "regenerator-runtime": "^0.13.7", "sass-loader": "^12.6.0", "telejson": "^6.0.8", "ts-dedent": "^2.0.0", diff --git a/frameworks/ember/package.json b/frameworks/ember/package.json index 645847989a8d..6f9463af54f7 100644 --- a/frameworks/ember/package.json +++ b/frameworks/ember/package.json @@ -40,7 +40,6 @@ "react": "16.14.0", "react-dom": "16.14.0", "read-pkg-up": "^7.0.1", - "regenerator-runtime": "^0.13.7", "ts-dedent": "^2.0.0" }, "peerDependencies": { diff --git a/frameworks/html-webpack5/package.json b/frameworks/html-webpack5/package.json index d05c8c6507fe..06260feb33a7 100644 --- a/frameworks/html-webpack5/package.json +++ b/frameworks/html-webpack5/package.json @@ -41,8 +41,7 @@ "core-js": "^3.8.2", "global": "^4.4.0", "react": "16.14.0", - "react-dom": "16.14.0", - "regenerator-runtime": "^0.13.7" + "react-dom": "16.14.0" }, "peerDependencies": { "@babel/core": "*" diff --git a/frameworks/preact-webpack5/package.json b/frameworks/preact-webpack5/package.json index d9f4c90b5ccd..8a026c3d3e24 100644 --- a/frameworks/preact-webpack5/package.json +++ b/frameworks/preact-webpack5/package.json @@ -40,8 +40,7 @@ "@types/node": "^14.14.20 || ^16.0.0", "core-js": "^3.8.2", "react": "16.14.0", - "react-dom": "16.14.0", - "regenerator-runtime": "^0.13.7" + "react-dom": "16.14.0" }, "devDependencies": { "preact": "^10.5.13" diff --git a/frameworks/react-webpack5/package.json b/frameworks/react-webpack5/package.json index 537d211437e4..2ae2edd10807 100644 --- a/frameworks/react-webpack5/package.json +++ b/frameworks/react-webpack5/package.json @@ -38,8 +38,7 @@ "@storybook/preset-react-webpack": "7.0.0-alpha.2", "@storybook/react": "7.0.0-alpha.2", "@types/node": "^14.14.20 || ^16.0.0", - "core-js": "^3.8.2", - "regenerator-runtime": "^0.13.7" + "core-js": "^3.8.2" }, "devDependencies": { "jest-specific-snapshot": "^4.0.0" diff --git a/frameworks/server-webpack5/package.json b/frameworks/server-webpack5/package.json index a586e7075a32..eca7998359de 100644 --- a/frameworks/server-webpack5/package.json +++ b/frameworks/server-webpack5/package.json @@ -40,8 +40,7 @@ "@types/node": "^14.14.20 || ^16.0.0", "core-js": "^3.8.2", "react": "16.14.0", - "react-dom": "16.14.0", - "regenerator-runtime": "^0.13.7" + "react-dom": "16.14.0" }, "engines": { "node": ">=10.13.0" diff --git a/frameworks/svelte-webpack5/package.json b/frameworks/svelte-webpack5/package.json index 679609327e1f..73774bd14d5f 100644 --- a/frameworks/svelte-webpack5/package.json +++ b/frameworks/svelte-webpack5/package.json @@ -40,8 +40,7 @@ "@storybook/svelte": "7.0.0-alpha.2", "core-js": "^3.8.2", "react": "16.14.0", - "react-dom": "16.14.0", - "regenerator-runtime": "^0.13.7" + "react-dom": "16.14.0" }, "devDependencies": { "svelte": "^3.48.0", diff --git a/frameworks/vue-webpack5/package.json b/frameworks/vue-webpack5/package.json index 2ea58ac1d3fb..a1826e982823 100644 --- a/frameworks/vue-webpack5/package.json +++ b/frameworks/vue-webpack5/package.json @@ -40,8 +40,7 @@ "@types/node": "^14.14.20 || ^16.0.0", "core-js": "^3.8.2", "react": "16.14.0", - "react-dom": "16.14.0", - "regenerator-runtime": "^0.13.7" + "react-dom": "16.14.0" }, "devDependencies": { "vue": "^2.6.12", diff --git a/frameworks/vue3-webpack5/package.json b/frameworks/vue3-webpack5/package.json index e5da4f25d3e4..28646c38fa31 100644 --- a/frameworks/vue3-webpack5/package.json +++ b/frameworks/vue3-webpack5/package.json @@ -40,8 +40,7 @@ "@types/node": "^14.14.20 || ^16.0.0", "core-js": "^3.8.2", "react": "16.14.0", - "react-dom": "16.14.0", - "regenerator-runtime": "^0.13.7" + "react-dom": "16.14.0" }, "devDependencies": { "@vue/compiler-sfc": "3.0.0", diff --git a/frameworks/web-components-webpack5/package.json b/frameworks/web-components-webpack5/package.json index 384f417b798e..ef8078d0572c 100644 --- a/frameworks/web-components-webpack5/package.json +++ b/frameworks/web-components-webpack5/package.json @@ -43,8 +43,7 @@ "@types/node": "^14.14.20 || ^16.0.0", "core-js": "^3.8.2", "react": "16.14.0", - "react-dom": "16.14.0", - "regenerator-runtime": "^0.13.7" + "react-dom": "16.14.0" }, "devDependencies": { "lit-html": "2.0.2" diff --git a/lib/addons/package.json b/lib/addons/package.json index c63bb0437a4c..c48d305a2e21 100644 --- a/lib/addons/package.json +++ b/lib/addons/package.json @@ -42,8 +42,7 @@ "@storybook/theming": "7.0.0-alpha.2", "@types/webpack-env": "^1.16.4", "core-js": "^3.8.2", - "global": "^4.4.0", - "regenerator-runtime": "^0.13.7" + "global": "^4.4.0" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0", diff --git a/lib/api/package.json b/lib/api/package.json index 6233d870fca7..f48a20f6f480 100644 --- a/lib/api/package.json +++ b/lib/api/package.json @@ -43,7 +43,6 @@ "global": "^4.4.0", "lodash": "^4.17.21", "memoizerific": "^1.11.3", - "regenerator-runtime": "^0.13.7", "store2": "^2.12.0", "telejson": "^6.0.8", "ts-dedent": "^2.0.0", diff --git a/lib/client-api/package.json b/lib/client-api/package.json index be20e4d03f70..613bb6322b14 100644 --- a/lib/client-api/package.json +++ b/lib/client-api/package.json @@ -48,7 +48,6 @@ "lodash": "^4.17.21", "memoizerific": "^1.11.3", "qs": "^6.10.0", - "regenerator-runtime": "^0.13.7", "store2": "^2.12.0", "synchronous-promise": "^2.0.15", "ts-dedent": "^2.0.0", diff --git a/lib/codemod/package.json b/lib/codemod/package.json index a6f74079e093..02979870715a 100644 --- a/lib/codemod/package.json +++ b/lib/codemod/package.json @@ -52,8 +52,7 @@ "jscodeshift": "^0.13.1", "lodash": "^4.17.21", "prettier": ">=2.2.1 <=2.3.0", - "recast": "^0.19.0", - "regenerator-runtime": "^0.13.7" + "recast": "^0.19.0" }, "devDependencies": { "jest": "^26.6.3", diff --git a/lib/components/package.json b/lib/components/package.json index 290c5e8dff5a..b54f00ca504d 100644 --- a/lib/components/package.json +++ b/lib/components/package.json @@ -56,7 +56,6 @@ "core-js": "^3.8.2", "memoizerific": "^1.11.3", "qs": "^6.10.0", - "regenerator-runtime": "^0.13.7", "util-deprecate": "^1.0.2" }, "devDependencies": { diff --git a/lib/core-server/package.json b/lib/core-server/package.json index 9a301e48ca43..91405591fb8f 100644 --- a/lib/core-server/package.json +++ b/lib/core-server/package.json @@ -66,7 +66,6 @@ "pretty-hrtime": "^1.0.3", "prompts": "^2.4.0", "read-pkg-up": "^7.0.1", - "regenerator-runtime": "^0.13.7", "serve-favicon": "^2.5.0", "slash": "^3.0.0", "telejson": "^6.0.8", diff --git a/lib/csf-tools/package.json b/lib/csf-tools/package.json index f65a9aedfe5c..b7dc9ac33dd4 100644 --- a/lib/csf-tools/package.json +++ b/lib/csf-tools/package.json @@ -44,7 +44,6 @@ "core-js": "^3.8.2", "fs-extra": "^9.0.1", "global": "^4.4.0", - "regenerator-runtime": "^0.13.7", "ts-dedent": "^2.0.0" }, "devDependencies": { diff --git a/lib/docs-tools/package.json b/lib/docs-tools/package.json index 1c5a215524d0..a8fcb7266492 100644 --- a/lib/docs-tools/package.json +++ b/lib/docs-tools/package.json @@ -38,8 +38,7 @@ "@storybook/store": "7.0.0-alpha.2", "core-js": "^3.8.2", "doctrine": "^3.0.0", - "lodash": "^4.17.21", - "regenerator-runtime": "^0.13.7" + "lodash": "^4.17.21" }, "devDependencies": { "jest-specific-snapshot": "^4.0.0", diff --git a/lib/manager-webpack5/package.json b/lib/manager-webpack5/package.json index e53d3015c24c..723b582b9eae 100644 --- a/lib/manager-webpack5/package.json +++ b/lib/manager-webpack5/package.json @@ -59,7 +59,6 @@ "node-fetch": "^2.6.7", "process": "^0.11.10", "read-pkg-up": "^7.0.1", - "regenerator-runtime": "^0.13.7", "resolve-from": "^5.0.0", "style-loader": "^3.3.1", "telejson": "^6.0.8", diff --git a/lib/preview-web/package.json b/lib/preview-web/package.json index ee883a671033..a88d0202beda 100644 --- a/lib/preview-web/package.json +++ b/lib/preview-web/package.json @@ -51,7 +51,6 @@ "global": "^4.4.0", "lodash": "^4.17.21", "qs": "^6.10.0", - "regenerator-runtime": "^0.13.7", "synchronous-promise": "^2.0.15", "ts-dedent": "^2.0.0", "unfetch": "^4.2.0", diff --git a/lib/router/package.json b/lib/router/package.json index dc0e2a0e79e9..0bb4f874e5de 100644 --- a/lib/router/package.json +++ b/lib/router/package.json @@ -36,8 +36,7 @@ "@storybook/client-logger": "7.0.0-alpha.2", "core-js": "^3.8.2", "memoizerific": "^1.11.3", - "qs": "^6.10.0", - "regenerator-runtime": "^0.13.7" + "qs": "^6.10.0" }, "devDependencies": { "fast-deep-equal": "^3.1.3", diff --git a/lib/source-loader/package.json b/lib/source-loader/package.json index ddb153402601..7d512d030372 100644 --- a/lib/source-loader/package.json +++ b/lib/source-loader/package.json @@ -41,8 +41,7 @@ "estraverse": "^5.2.0", "global": "^4.4.0", "lodash": "^4.17.21", - "prettier": ">=2.2.1 <=2.3.0", - "regenerator-runtime": "^0.13.7" + "prettier": ">=2.2.1 <=2.3.0" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0", diff --git a/lib/store/package.json b/lib/store/package.json index 0f4261617606..d46180b62a49 100644 --- a/lib/store/package.json +++ b/lib/store/package.json @@ -49,7 +49,6 @@ "global": "^4.4.0", "lodash": "^4.17.21", "memoizerific": "^1.11.3", - "regenerator-runtime": "^0.13.7", "slash": "^3.0.0", "stable": "^0.1.8", "synchronous-promise": "^2.0.15", diff --git a/lib/telemetry/package.json b/lib/telemetry/package.json index 5a06bd6db4f2..1cb15cbb030d 100644 --- a/lib/telemetry/package.json +++ b/lib/telemetry/package.json @@ -43,8 +43,7 @@ "global": "^4.4.0", "isomorphic-unfetch": "^3.1.0", "nanoid": "^3.3.1", - "read-pkg-up": "^7.0.1", - "regenerator-runtime": "^0.13.7" + "read-pkg-up": "^7.0.1" }, "publishConfig": { "access": "public" diff --git a/lib/theming/package.json b/lib/theming/package.json index 2e887937cb34..38af9751bd40 100644 --- a/lib/theming/package.json +++ b/lib/theming/package.json @@ -35,8 +35,7 @@ "dependencies": { "@storybook/client-logger": "7.0.0-alpha.2", "core-js": "^3.8.2", - "memoizerific": "^1.11.3", - "regenerator-runtime": "^0.13.7" + "memoizerific": "^1.11.3" }, "devDependencies": { "@emotion/cache": "^11.7.1", diff --git a/lib/ui/package.json b/lib/ui/package.json index 3f107ce12cc8..7f0ab6da71c8 100644 --- a/lib/ui/package.json +++ b/lib/ui/package.json @@ -47,7 +47,6 @@ "qs": "^6.10.0", "react": "^16.8.0 || ^17.0.0 || ^18.0.0", "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0", - "regenerator-runtime": "^0.13.7", "resolve-from": "^5.0.0", "util": "^0.12.4" }, diff --git a/presets/preact-webpack/package.json b/presets/preact-webpack/package.json index 3e457886ef8c..51d279b886ff 100644 --- a/presets/preact-webpack/package.json +++ b/presets/preact-webpack/package.json @@ -37,8 +37,7 @@ "@types/node": "^14.14.20 || ^16.0.0", "core-js": "^3.8.2", "react": "16.14.0", - "react-dom": "16.14.0", - "regenerator-runtime": "^0.13.7" + "react-dom": "16.14.0" }, "devDependencies": { "preact": "^10.5.13" diff --git a/presets/react-webpack/package.json b/presets/react-webpack/package.json index dac886db736a..d4062669f256 100644 --- a/presets/react-webpack/package.json +++ b/presets/react-webpack/package.json @@ -47,8 +47,7 @@ "babel-plugin-react-docgen": "^4.2.1", "core-js": "^3.8.2", "fs-extra": "^9.0.1", - "react-refresh": "^0.11.0", - "regenerator-runtime": "^0.13.7" + "react-refresh": "^0.11.0" }, "devDependencies": { "@types/util-deprecate": "^1.0.0" diff --git a/presets/server-webpack/package.json b/presets/server-webpack/package.json index 04b82382a278..e8b78753dae7 100644 --- a/presets/server-webpack/package.json +++ b/presets/server-webpack/package.json @@ -40,7 +40,6 @@ "global": "^4.4.0", "react": "16.14.0", "react-dom": "16.14.0", - "regenerator-runtime": "^0.13.7", "safe-identifier": "^0.4.1", "ts-dedent": "^2.0.0", "yaml-loader": "^0.8.0" diff --git a/presets/svelte-webpack/package.json b/presets/svelte-webpack/package.json index d43398ba836a..cd87ada961aa 100644 --- a/presets/svelte-webpack/package.json +++ b/presets/svelte-webpack/package.json @@ -38,7 +38,6 @@ "core-js": "^3.8.2", "react": "16.14.0", "react-dom": "16.14.0", - "regenerator-runtime": "^0.13.7", "sveltedoc-parser": "4.1.0", "ts-dedent": "^2.0.0" }, diff --git a/presets/vue-webpack/package.json b/presets/vue-webpack/package.json index b2252006ab87..7a776ee81063 100644 --- a/presets/vue-webpack/package.json +++ b/presets/vue-webpack/package.json @@ -38,7 +38,6 @@ "core-js": "^3.8.2", "react": "16.14.0", "react-dom": "16.14.0", - "regenerator-runtime": "^0.13.7", "ts-loader": "^9.2.8", "vue-docgen-api": "^4.44.23", "vue-docgen-loader": "^1.5.1", diff --git a/presets/vue3-webpack/package.json b/presets/vue3-webpack/package.json index aa9ee16e9080..ce3a25592447 100644 --- a/presets/vue3-webpack/package.json +++ b/presets/vue3-webpack/package.json @@ -39,7 +39,6 @@ "core-js": "^3.8.2", "react": "16.14.0", "react-dom": "16.14.0", - "regenerator-runtime": "^0.13.7", "ts-loader": "^9.2.8", "vue-docgen-api": "^4.46.0", "vue-docgen-loader": "^1.5.1", diff --git a/presets/web-components-webpack/package.json b/presets/web-components-webpack/package.json index 4032e9d1e426..5a8ba2156124 100644 --- a/presets/web-components-webpack/package.json +++ b/presets/web-components-webpack/package.json @@ -42,8 +42,7 @@ "babel-plugin-bundled-import-meta": "^0.3.1", "core-js": "^3.8.2", "react": "16.14.0", - "react-dom": "16.14.0", - "regenerator-runtime": "^0.13.7" + "react-dom": "16.14.0" }, "devDependencies": { "lit-html": "2.0.2" diff --git a/renderers/html/package.json b/renderers/html/package.json index d20d4736de3a..20f865fbd667 100644 --- a/renderers/html/package.json +++ b/renderers/html/package.json @@ -42,7 +42,6 @@ "global": "^4.4.0", "react": "16.14.0", "react-dom": "16.14.0", - "regenerator-runtime": "^0.13.7", "ts-dedent": "^2.0.0" }, "peerDependencies": { diff --git a/renderers/preact/package.json b/renderers/preact/package.json index 1b16f1ac1a05..e5927e81f6d5 100644 --- a/renderers/preact/package.json +++ b/renderers/preact/package.json @@ -40,7 +40,6 @@ "global": "^4.4.0", "react": "16.14.0", "react-dom": "16.14.0", - "regenerator-runtime": "^0.13.7", "ts-dedent": "^2.0.0" }, "devDependencies": { diff --git a/renderers/react/package.json b/renderers/react/package.json index ff7d7417a7ee..0244038f6959 100644 --- a/renderers/react/package.json +++ b/renderers/react/package.json @@ -51,7 +51,6 @@ "lodash": "^4.17.21", "prop-types": "^15.7.2", "react-element-to-jsx-string": "^14.3.4", - "regenerator-runtime": "^0.13.7", "ts-dedent": "^2.0.0", "util-deprecate": "^1.0.2" }, diff --git a/renderers/server/package.json b/renderers/server/package.json index 6ceef9f7e010..37ac573a0898 100644 --- a/renderers/server/package.json +++ b/renderers/server/package.json @@ -41,7 +41,6 @@ "global": "^4.4.0", "react": "16.14.0", "react-dom": "16.14.0", - "regenerator-runtime": "^0.13.7", "ts-dedent": "^2.0.0" }, "engines": { diff --git a/renderers/svelte/package.json b/renderers/svelte/package.json index 887c43a1f739..4f5a4a7e04e5 100644 --- a/renderers/svelte/package.json +++ b/renderers/svelte/package.json @@ -43,7 +43,6 @@ "global": "^4.4.0", "react": "16.14.0", "react-dom": "16.14.0", - "regenerator-runtime": "^0.13.7", "sveltedoc-parser": "4.1.0" }, "devDependencies": { diff --git a/renderers/vue/package.json b/renderers/vue/package.json index 415a9d15269c..558627cb684c 100644 --- a/renderers/vue/package.json +++ b/renderers/vue/package.json @@ -42,7 +42,6 @@ "global": "^4.4.0", "react": "16.14.0", "react-dom": "16.14.0", - "regenerator-runtime": "^0.13.7", "ts-dedent": "^2.0.0" }, "devDependencies": { diff --git a/renderers/vue3/package.json b/renderers/vue3/package.json index 7b7c695546ca..80bf11088fef 100644 --- a/renderers/vue3/package.json +++ b/renderers/vue3/package.json @@ -42,7 +42,6 @@ "global": "^4.4.0", "react": "16.14.0", "react-dom": "16.14.0", - "regenerator-runtime": "^0.13.7", "ts-dedent": "^2.0.0" }, "devDependencies": { diff --git a/renderers/web-components/package.json b/renderers/web-components/package.json index 0f843725b8dd..d0bc01f2dd5e 100644 --- a/renderers/web-components/package.json +++ b/renderers/web-components/package.json @@ -46,7 +46,6 @@ "global": "^4.4.0", "react": "16.14.0", "react-dom": "16.14.0", - "regenerator-runtime": "^0.13.7", "ts-dedent": "^2.0.0" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index 94f05e93eac2..0525381ec8bb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6597,7 +6597,6 @@ __metadata: global: ^4.4.0 lodash: ^4.17.21 react-sizeme: ^3.0.1 - regenerator-runtime: ^0.13.7 ts-dedent: ^2.0.0 util-deprecate: ^1.0.2 peerDependencies: @@ -6630,7 +6629,6 @@ __metadata: polished: ^4.2.2 prop-types: ^15.7.2 react-inspector: ^5.1.0 - regenerator-runtime: ^0.13.7 telejson: ^6.0.8 ts-dedent: ^2.0.0 util-deprecate: ^1.0.2 @@ -6660,7 +6658,6 @@ __metadata: core-js: ^3.8.2 global: ^4.4.0 memoizerific: ^1.11.3 - regenerator-runtime: ^0.13.7 ts-dedent: ^2.0.0 util-deprecate: ^1.0.2 peerDependencies: @@ -6732,7 +6729,6 @@ __metadata: fast-deep-equal: ^3.1.3 global: ^4.4.0 lodash: ^4.17.21 - regenerator-runtime: ^0.13.7 remark-external-links: ^8.0.0 remark-slug: ^6.0.0 ts-dedent: ^2.0.0 @@ -6771,7 +6767,6 @@ __metadata: "@storybook/vue": 7.0.0-alpha.2 "@types/jest": ^26.0.16 core-js: ^3.8.2 - regenerator-runtime: ^0.13.7 ts-dedent: ^2.0.0 peerDependencies: "@babel/core": ^7.9.6 @@ -6849,7 +6844,6 @@ __metadata: core-js: ^3.8.2 global: ^4.4.0 react-sizeme: ^3.0.1 - regenerator-runtime: ^0.13.7 upath: ^1.2.0 peerDependencies: react: ^16.8.0 || ^17.0.0 || ^18.0.0 @@ -6874,7 +6868,6 @@ __metadata: core-js: ^3.8.2 global: ^4.4.0 prop-types: ^15.7.2 - regenerator-runtime: ^0.13.7 ts-dedent: ^2.0.0 peerDependencies: react: ^16.8.0 || ^17.0.0 || ^18.0.0 @@ -6922,7 +6915,6 @@ __metadata: "@storybook/csf": 0.0.2--canary.4566f4d.1 core-js: ^3.8.2 global: ^4.4.0 - regenerator-runtime: ^0.13.7 ts-dedent: ^2.0.0 peerDependencies: react: ^16.8.0 || ^17.0.0 || ^18.0.0 @@ -6959,7 +6951,6 @@ __metadata: "@types/puppeteer": ^5.4.0 core-js: ^3.8.2 jest-image-snapshot: ^4.3.0 - regenerator-runtime: ^0.13.7 peerDependencies: "@storybook/addon-storyshots": 7.0.0-alpha.2 puppeteer: ^2.0.0 || ^3.0.0 @@ -7004,7 +6995,6 @@ __metadata: pretty-format: ^26.6.2 react-test-renderer: ^16.8.0 || ^17.0.0 read-pkg-up: ^7.0.1 - regenerator-runtime: ^0.13.7 rxjs: ^6.6.3 ts-dedent: ^2.0.0 vue-jest: ^5.0.0-alpha.8 @@ -7076,7 +7066,6 @@ __metadata: estraverse: ^5.2.0 prop-types: ^15.7.2 react-syntax-highlighter: ^15.4.5 - regenerator-runtime: ^0.13.7 peerDependencies: react: ^16.8.0 || ^17.0.0 || ^18.0.0 react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 @@ -7098,7 +7087,6 @@ __metadata: "@storybook/components": 7.0.0-alpha.2 "@storybook/theming": 7.0.0-alpha.2 core-js: ^3.8.2 - regenerator-runtime: ^0.13.7 peerDependencies: react: ^16.8.0 || ^17.0.0 || ^18.0.0 react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 @@ -7124,7 +7112,6 @@ __metadata: global: ^4.4.0 memoizerific: ^1.11.3 prop-types: ^15.7.2 - regenerator-runtime: ^0.13.7 peerDependencies: react: ^16.8.0 || ^17.0.0 || ^18.0.0 react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 @@ -7150,7 +7137,6 @@ __metadata: "@types/webpack-env": ^1.16.4 core-js: ^3.8.2 global: ^4.4.0 - regenerator-runtime: ^0.13.7 peerDependencies: react: ^16.8.0 || ^17.0.0 || ^18.0.0 react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 @@ -7253,7 +7239,6 @@ __metadata: react: ^16.14.0 react-dom: ^16.14.0 read-pkg-up: ^7.0.1 - regenerator-runtime: ^0.13.7 sass-loader: ^12.6.0 telejson: ^6.0.8 tmp: ^0.2.1 @@ -7310,7 +7295,6 @@ __metadata: memoizerific: ^1.11.3 preval.macro: ^5.0.0 qs: ^6.10.1 - regenerator-runtime: ^0.13.7 store2: ^2.12.0 telejson: ^6.0.8 ts-dedent: ^2.0.0 @@ -7568,7 +7552,6 @@ __metadata: lodash: ^4.17.21 memoizerific: ^1.11.3 qs: ^6.10.0 - regenerator-runtime: ^0.13.7 store2: ^2.12.0 synchronous-promise: ^2.0.15 ts-dedent: ^2.0.0 @@ -7626,7 +7609,6 @@ __metadata: lodash: ^4.17.21 prettier: ">=2.2.1 <=2.3.0" recast: ^0.19.0 - regenerator-runtime: ^0.13.7 languageName: unknown linkType: soft @@ -7660,7 +7642,6 @@ __metadata: react-popper-tooltip: ^3.1.1 react-syntax-highlighter: ^15.4.5 react-textarea-autosize: ^8.3.0 - regenerator-runtime: ^0.13.7 ts-dedent: ^2.0.0 util-deprecate: ^1.0.2 peerDependencies: @@ -7837,7 +7818,6 @@ __metadata: pretty-hrtime: ^1.0.3 prompts: ^2.4.0 read-pkg-up: ^7.0.1 - regenerator-runtime: ^0.13.7 serve-favicon: ^2.5.0 slash: ^3.0.0 telejson: ^6.0.8 @@ -7890,7 +7870,6 @@ __metadata: fs-extra: ^9.0.1 global: ^4.4.0 js-yaml: ^3.14.1 - regenerator-runtime: ^0.13.7 ts-dedent: ^2.0.0 languageName: unknown linkType: soft @@ -7956,7 +7935,6 @@ __metadata: doctrine: ^3.0.0 jest-specific-snapshot: ^4.0.0 lodash: ^4.17.21 - regenerator-runtime: ^0.13.7 require-from-string: ^2.0.2 languageName: unknown linkType: soft @@ -7988,7 +7966,6 @@ __metadata: react: 16.14.0 react-dom: 16.14.0 read-pkg-up: ^7.0.1 - regenerator-runtime: ^0.13.7 ts-dedent: ^2.0.0 peerDependencies: "@babel/core": "*" @@ -8096,7 +8073,6 @@ __metadata: global: ^4.4.0 react: 16.14.0 react-dom: 16.14.0 - regenerator-runtime: ^0.13.7 peerDependencies: "@babel/core": "*" languageName: unknown @@ -8116,7 +8092,6 @@ __metadata: global: ^4.4.0 react: 16.14.0 react-dom: 16.14.0 - regenerator-runtime: ^0.13.7 ts-dedent: ^2.0.0 peerDependencies: "@babel/core": "*" @@ -8230,7 +8205,6 @@ __metadata: node-fetch: ^2.6.7 process: ^0.11.10 read-pkg-up: ^7.0.1 - regenerator-runtime: ^0.13.7 resolve-from: ^5.0.0 style-loader: ^3.3.1 telejson: ^6.0.8 @@ -8332,7 +8306,6 @@ __metadata: preact: ^10.5.13 react: 16.14.0 react-dom: 16.14.0 - regenerator-runtime: ^0.13.7 peerDependencies: "@babel/core": "*" preact: ^8.0.0||^10.0.0 @@ -8352,7 +8325,6 @@ __metadata: preact: ^10.5.13 react: 16.14.0 react-dom: 16.14.0 - regenerator-runtime: ^0.13.7 ts-dedent: ^2.0.0 peerDependencies: preact: ^8.0.0||^10.0.0 @@ -8405,7 +8377,6 @@ __metadata: preact: ^10.5.13 react: 16.14.0 react-dom: 16.14.0 - regenerator-runtime: ^0.13.7 peerDependencies: "@babel/core": "*" preact: ^8.0.0||^10.0.0 @@ -8432,7 +8403,6 @@ __metadata: core-js: ^3.8.2 fs-extra: ^9.0.1 react-refresh: ^0.11.0 - regenerator-runtime: ^0.13.7 peerDependencies: "@babel/core": ^7.11.5 jest-specific-snapshot: ^4.0.0 @@ -8473,7 +8443,6 @@ __metadata: jest-specific-snapshot: ^4.0.0 react: 16.14.0 react-dom: 16.14.0 - regenerator-runtime: ^0.13.7 safe-identifier: ^0.4.1 ts-dedent: ^2.0.0 yaml: ^1.10.0 @@ -8490,7 +8459,6 @@ __metadata: core-js: ^3.8.2 react: 16.14.0 react-dom: 16.14.0 - regenerator-runtime: ^0.13.7 svelte: ^3.31.2 svelte-loader: ^3.1.2 sveltedoc-parser: 4.1.0 @@ -8512,7 +8480,6 @@ __metadata: core-js: ^3.8.2 react: 16.14.0 react-dom: 16.14.0 - regenerator-runtime: ^0.13.7 ts-loader: ^9.2.8 vue: ^2.6.12 vue-docgen-api: ^4.44.23 @@ -8541,7 +8508,6 @@ __metadata: core-js: ^3.8.2 react: 16.14.0 react-dom: 16.14.0 - regenerator-runtime: ^0.13.7 ts-loader: ^9.2.8 vue: ^3.2.33 vue-docgen-api: ^4.46.0 @@ -8570,7 +8536,6 @@ __metadata: lit-html: 2.0.2 react: 16.14.0 react-dom: 16.14.0 - regenerator-runtime: ^0.13.7 peerDependencies: lit-html: ^1.4.1 || ^2.0.0 languageName: unknown @@ -8591,7 +8556,6 @@ __metadata: global: ^4.4.0 lodash: ^4.17.21 qs: ^6.10.0 - regenerator-runtime: ^0.13.7 synchronous-promise: ^2.0.15 ts-dedent: ^2.0.0 unfetch: ^4.2.0 @@ -8631,7 +8595,6 @@ __metadata: "@types/node": ^14.14.20 || ^16.0.0 core-js: ^3.8.2 jest-specific-snapshot: ^4.0.0 - regenerator-runtime: ^0.13.7 peerDependencies: "@babel/core": ^7.11.5 react: ^16.8.0 || ^17.0.0 || ^18.0.0 @@ -8668,7 +8631,6 @@ __metadata: lodash: ^4.17.21 prop-types: ^15.7.2 react-element-to-jsx-string: ^14.3.4 - regenerator-runtime: ^0.13.7 ts-dedent: ^2.0.0 util-deprecate: ^1.0.2 peerDependencies: @@ -8962,7 +8924,6 @@ __metadata: qs: ^6.10.0 react-router: 6.0.2 react-router-dom: 6.0.2 - regenerator-runtime: ^0.13.7 ts-dedent: ^2.0.0 ts-node: ^10.4.0 peerDependencies: @@ -9032,7 +8993,6 @@ __metadata: core-js: ^3.8.2 react: 16.14.0 react-dom: 16.14.0 - regenerator-runtime: ^0.13.7 languageName: unknown linkType: soft @@ -9049,7 +9009,6 @@ __metadata: global: ^4.4.0 react: 16.14.0 react-dom: 16.14.0 - regenerator-runtime: ^0.13.7 ts-dedent: ^2.0.0 languageName: unknown linkType: soft @@ -9066,7 +9025,6 @@ __metadata: global: ^4.4.0 lodash: ^4.17.21 prettier: ">=2.2.1 <=2.3.0" - regenerator-runtime: ^0.13.7 peerDependencies: react: ^16.8.0 || ^17.0.0 || ^18.0.0 react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 @@ -9086,7 +9044,6 @@ __metadata: global: ^4.4.0 lodash: ^4.17.21 memoizerific: ^1.11.3 - regenerator-runtime: ^0.13.7 slash: ^3.0.0 stable: ^0.1.8 synchronous-promise: ^2.0.15 @@ -9110,7 +9067,6 @@ __metadata: core-js: ^3.8.2 react: 16.14.0 react-dom: 16.14.0 - regenerator-runtime: ^0.13.7 svelte: ^3.48.0 svelte-loader: ^3.1.2 peerDependencies: @@ -9134,7 +9090,6 @@ __metadata: global: ^4.4.0 react: 16.14.0 react-dom: 16.14.0 - regenerator-runtime: ^0.13.7 svelte: ^3.31.2 sveltedoc-parser: 4.1.0 peerDependencies: @@ -9158,7 +9113,6 @@ __metadata: isomorphic-unfetch: ^3.1.0 nanoid: ^3.3.1 read-pkg-up: ^7.0.1 - regenerator-runtime: ^0.13.7 languageName: unknown linkType: soft @@ -9216,7 +9170,6 @@ __metadata: global: ^4.4.0 memoizerific: ^1.11.3 polished: ^4.2.2 - regenerator-runtime: ^0.13.7 ts-dedent: ^2.0.0 ts-node: ^10.4.0 peerDependencies: @@ -9295,7 +9248,6 @@ __metadata: react-draggable: ^4.4.3 react-helmet-async: ^1.0.7 react-sizeme: ^3.0.1 - regenerator-runtime: ^0.13.7 resolve-from: ^5.0.0 store2: ^2.12.0 ts-node: ^10.4.0 @@ -9316,7 +9268,6 @@ __metadata: core-js: ^3.8.2 react: 16.14.0 react-dom: 16.14.0 - regenerator-runtime: ^0.13.7 vue: ^2.6.12 vue-loader: ^15.7.0 vue-template-compiler: ^2.6.14 @@ -9344,7 +9295,6 @@ __metadata: core-js: ^3.8.2 react: 16.14.0 react-dom: 16.14.0 - regenerator-runtime: ^0.13.7 vue: 3.0.0 peerDependencies: "@babel/core": "*" @@ -9367,7 +9317,6 @@ __metadata: global: ^4.4.0 react: 16.14.0 react-dom: 16.14.0 - regenerator-runtime: ^0.13.7 ts-dedent: ^2.0.0 vue: 3.0.0 peerDependencies: @@ -9391,7 +9340,6 @@ __metadata: global: ^4.4.0 react: 16.14.0 react-dom: 16.14.0 - regenerator-runtime: ^0.13.7 ts-dedent: ^2.0.0 vue: ^2.6.12 peerDependencies: @@ -9417,7 +9365,6 @@ __metadata: lit-html: 2.0.2 react: 16.14.0 react-dom: 16.14.0 - regenerator-runtime: ^0.13.7 peerDependencies: lit-html: ^1.4.1 || ^2.0.0 languageName: unknown @@ -9440,7 +9387,6 @@ __metadata: lit-html: 2.0.2 react: 16.14.0 react-dom: 16.14.0 - regenerator-runtime: ^0.13.7 ts-dedent: ^2.0.0 peerDependencies: lit-html: ^1.4.1 || ^2.0.0 From db2f1f5becdc348c1561ce64c181861343f9dc32 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 15 Jun 2022 16:20:38 +0200 Subject: [PATCH 02/12] no shims or polyfills --- lib/core-client/package.json | 2 - lib/core-client/src/globals/polyfills.ts | 1 - .../src/manager/conditional-polyfills.ts | 19 -- lib/core-client/src/manager/index.ts | 7 +- lib/core-client/src/typings.d.ts | 1 - lib/core-server/typings.d.ts | 1 - lib/manager-webpack5/typings.d.ts | 1 - lib/preview-web/package.json | 1 - yarn.lock | 182 +----------------- 9 files changed, 11 insertions(+), 204 deletions(-) delete mode 100644 lib/core-client/src/manager/conditional-polyfills.ts diff --git a/lib/core-client/package.json b/lib/core-client/package.json index 6950df31ab19..c71e09dfb06a 100644 --- a/lib/core-client/package.json +++ b/lib/core-client/package.json @@ -43,7 +43,6 @@ "@storybook/preview-web": "7.0.0-alpha.2", "@storybook/store": "7.0.0-alpha.2", "@storybook/ui": "7.0.0-alpha.2", - "airbnb-js-shims": "^2.2.1", "ansi-to-html": "^0.6.11", "core-js": "^3.8.2", "global": "^4.4.0", @@ -51,7 +50,6 @@ "qs": "^6.10.0", "regenerator-runtime": "^0.13.7", "ts-dedent": "^2.0.0", - "unfetch": "^4.2.0", "util-deprecate": "^1.0.2" }, "peerDependenciesMeta": { diff --git a/lib/core-client/src/globals/polyfills.ts b/lib/core-client/src/globals/polyfills.ts index 23015707ef0b..2ca8b3e828a0 100644 --- a/lib/core-client/src/globals/polyfills.ts +++ b/lib/core-client/src/globals/polyfills.ts @@ -1,3 +1,2 @@ import 'regenerator-runtime/runtime'; -import 'airbnb-js-shims'; import 'core-js/features/symbol'; diff --git a/lib/core-client/src/manager/conditional-polyfills.ts b/lib/core-client/src/manager/conditional-polyfills.ts deleted file mode 100644 index 146dd4155f55..000000000000 --- a/lib/core-client/src/manager/conditional-polyfills.ts +++ /dev/null @@ -1,19 +0,0 @@ -import global from 'global'; - -const { window: globalWindow } = global; - -export const importPolyfills = () => { - const polyfills = []; - - if (!globalWindow.fetch) { - // manually patch window.fetch; - // see issue: - const patch = ({ default: fetch }: any) => { - globalWindow.fetch = fetch; - }; - - polyfills.push(import('unfetch/dist/unfetch').then(patch)); - } - - return Promise.all(polyfills); -}; diff --git a/lib/core-client/src/manager/index.ts b/lib/core-client/src/manager/index.ts index 03226e41961e..45f7a9f8098b 100644 --- a/lib/core-client/src/manager/index.ts +++ b/lib/core-client/src/manager/index.ts @@ -2,11 +2,8 @@ import global from 'global'; import { renderStorybookUI } from '@storybook/ui'; import Provider from './provider'; -import { importPolyfills } from './conditional-polyfills'; const { document } = global; -importPolyfills().then(() => { - const rootEl = document.getElementById('root'); - renderStorybookUI(rootEl, new Provider()); -}); +const rootEl = document.getElementById('root'); +renderStorybookUI(rootEl, new Provider()); diff --git a/lib/core-client/src/typings.d.ts b/lib/core-client/src/typings.d.ts index 542f59c6360a..e5b2136dea29 100644 --- a/lib/core-client/src/typings.d.ts +++ b/lib/core-client/src/typings.d.ts @@ -1,6 +1,5 @@ declare module 'global'; declare module '@storybook/semver'; -declare module 'unfetch/dist/unfetch'; declare module 'lazy-universal-dotenv'; declare module 'pnp-webpack-plugin'; declare module '@storybook/ui/paths'; diff --git a/lib/core-server/typings.d.ts b/lib/core-server/typings.d.ts index eeb489a5e71a..7ac16810fb53 100644 --- a/lib/core-server/typings.d.ts +++ b/lib/core-server/typings.d.ts @@ -1,6 +1,5 @@ declare module 'global'; declare module '@storybook/semver'; -declare module 'unfetch/dist/unfetch'; declare module 'lazy-universal-dotenv'; declare module 'pnp-webpack-plugin'; declare module '@storybook/theming/paths'; diff --git a/lib/manager-webpack5/typings.d.ts b/lib/manager-webpack5/typings.d.ts index 70fcabe6c3bb..4c0d6c6d6914 100644 --- a/lib/manager-webpack5/typings.d.ts +++ b/lib/manager-webpack5/typings.d.ts @@ -1,6 +1,5 @@ declare module 'global'; declare module '@storybook/semver'; -declare module 'unfetch/dist/unfetch'; declare module 'lazy-universal-dotenv'; declare module '@storybook/theming/paths'; declare module '@storybook/ui/paths'; diff --git a/lib/preview-web/package.json b/lib/preview-web/package.json index a88d0202beda..8f6a44dcbd7f 100644 --- a/lib/preview-web/package.json +++ b/lib/preview-web/package.json @@ -53,7 +53,6 @@ "qs": "^6.10.0", "synchronous-promise": "^2.0.15", "ts-dedent": "^2.0.0", - "unfetch": "^4.2.0", "util-deprecate": "^1.0.2" }, "peerDependencies": { diff --git a/yarn.lock b/yarn.lock index 0525381ec8bb..87ede26dc145 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7664,7 +7664,6 @@ __metadata: "@storybook/preview-web": 7.0.0-alpha.2 "@storybook/store": 7.0.0-alpha.2 "@storybook/ui": 7.0.0-alpha.2 - airbnb-js-shims: ^2.2.1 ansi-to-html: ^0.6.11 core-js: ^3.8.2 global: ^4.4.0 @@ -12504,31 +12503,6 @@ __metadata: languageName: node linkType: hard -"airbnb-js-shims@npm:^2.2.1": - version: 2.2.1 - resolution: "airbnb-js-shims@npm:2.2.1" - dependencies: - array-includes: ^3.0.3 - array.prototype.flat: ^1.2.1 - array.prototype.flatmap: ^1.2.1 - es5-shim: ^4.5.13 - es6-shim: ^0.35.5 - function.prototype.name: ^1.1.0 - globalthis: ^1.0.0 - object.entries: ^1.1.0 - object.fromentries: ^2.0.0 || ^1.0.0 - object.getownpropertydescriptors: ^2.0.3 - object.values: ^1.1.0 - promise.allsettled: ^1.0.0 - promise.prototype.finally: ^3.1.0 - string.prototype.matchall: ^4.0.0 || ^3.0.1 - string.prototype.padend: ^3.0.0 - string.prototype.padstart: ^3.0.0 - symbol.prototype.description: ^1.0.0 - checksum: 55fdeb2673da440772d278816664b8e8da946b57adfd95b6635bc980ad235e388266c1488fdff3a055e95dc1c789e389821598b2711b59ce76ab4500f528216c - languageName: node - linkType: hard - "airbnb-prop-types@npm:^2.16.0": version: 2.16.0 resolution: "airbnb-prop-types@npm:2.16.0" @@ -13082,7 +13056,7 @@ __metadata: languageName: node linkType: hard -"array-includes@npm:^3.0.3, array-includes@npm:^3.1.4, array-includes@npm:^3.1.5": +"array-includes@npm:^3.1.4, array-includes@npm:^3.1.5": version: 3.1.5 resolution: "array-includes@npm:3.1.5" dependencies: @@ -13173,7 +13147,7 @@ __metadata: languageName: node linkType: hard -"array.prototype.flat@npm:^1.2.1, array.prototype.flat@npm:^1.2.3, array.prototype.flat@npm:^1.2.5": +"array.prototype.flat@npm:^1.2.3, array.prototype.flat@npm:^1.2.5": version: 1.3.0 resolution: "array.prototype.flat@npm:1.3.0" dependencies: @@ -13185,7 +13159,7 @@ __metadata: languageName: node linkType: hard -"array.prototype.flatmap@npm:^1.2.1, array.prototype.flatmap@npm:^1.3.0": +"array.prototype.flatmap@npm:^1.3.0": version: 1.3.0 resolution: "array.prototype.flatmap@npm:1.3.0" dependencies: @@ -13197,19 +13171,6 @@ __metadata: languageName: node linkType: hard -"array.prototype.map@npm:^1.0.4": - version: 1.0.4 - resolution: "array.prototype.map@npm:1.0.4" - dependencies: - call-bind: ^1.0.2 - define-properties: ^1.1.3 - es-abstract: ^1.19.0 - es-array-method-boxes-properly: ^1.0.0 - is-string: ^1.0.7 - checksum: b42d7d91b89b3b0b2cbb0211917af5be1f100843faeed71bed0cef38d040c980d0fc6433a5df4c13eaded2cccd7b209bbbad250c27f724900cb57c0c0e289dc0 - languageName: node - linkType: hard - "array.prototype.reduce@npm:^1.0.4": version: 1.0.4 resolution: "array.prototype.reduce@npm:1.0.4" @@ -20110,22 +20071,6 @@ __metadata: languageName: node linkType: hard -"es-get-iterator@npm:^1.0.2": - version: 1.1.2 - resolution: "es-get-iterator@npm:1.1.2" - dependencies: - call-bind: ^1.0.2 - get-intrinsic: ^1.1.0 - has-symbols: ^1.0.1 - is-arguments: ^1.1.0 - is-map: ^2.0.2 - is-set: ^2.0.2 - is-string: ^1.0.5 - isarray: ^2.0.5 - checksum: 76a832b3bfd85941c556287cd50a3ad612f5193264b761e2011503f311dfa20aa52b9ebd701d3f16022d4cb56a7130a4cfb50186427d3aecd0d4e547a471f68e - languageName: node - linkType: hard - "es-module-lexer@npm:^0.9.0": version: 0.9.3 resolution: "es-module-lexer@npm:0.9.3" @@ -20164,13 +20109,6 @@ __metadata: languageName: node linkType: hard -"es5-shim@npm:^4.5.13": - version: 4.6.7 - resolution: "es5-shim@npm:4.6.7" - checksum: f285a58ed1901d46872828776164c0837272d28374a3c74b31a893dc6b16c67d417509c4f587a87c7cdfa9faf9c97c70d774c81d8bf9dcca6d3d6bfdf4a7a28e - languageName: node - linkType: hard - "es6-iterator@npm:^2.0.3, es6-iterator@npm:~2.0.1": version: 2.0.3 resolution: "es6-iterator@npm:2.0.3" @@ -20232,13 +20170,6 @@ __metadata: languageName: node linkType: hard -"es6-shim@npm:^0.35.5": - version: 0.35.6 - resolution: "es6-shim@npm:0.35.6" - checksum: 4ed9ceb017826032ea403eef82c4af97275f4e62590f8e31f8af823056a573ce096007c179718f72ce9d5a35c658ce887668a79e341fd1b64f09c2d905d0f1d5 - languageName: node - linkType: hard - "es6-symbol@npm:3.1.1": version: 3.1.1 resolution: "es6-symbol@npm:3.1.1" @@ -23007,7 +22938,7 @@ __metadata: languageName: node linkType: hard -"function.prototype.name@npm:^1.1.0, function.prototype.name@npm:^1.1.2, function.prototype.name@npm:^1.1.3, function.prototype.name@npm:^1.1.5": +"function.prototype.name@npm:^1.1.2, function.prototype.name@npm:^1.1.3, function.prototype.name@npm:^1.1.5": version: 1.1.5 resolution: "function.prototype.name@npm:1.1.5" dependencies: @@ -23619,15 +23550,6 @@ __metadata: languageName: node linkType: hard -"globalthis@npm:^1.0.0": - version: 1.0.3 - resolution: "globalthis@npm:1.0.3" - dependencies: - define-properties: ^1.1.3 - checksum: 0db6e9af102a5254630351557ac15e6909bc7459d3e3f6b001e59fe784c96d31108818f032d9095739355a88467459e6488ff16584ee6250cd8c27dec05af4b0 - languageName: node - linkType: hard - "globby@npm:10.0.0": version: 10.0.0 resolution: "globby@npm:10.0.0" @@ -25518,7 +25440,7 @@ __metadata: languageName: node linkType: hard -"is-arguments@npm:^1.0.4, is-arguments@npm:^1.1.0": +"is-arguments@npm:^1.0.4": version: 1.1.1 resolution: "is-arguments@npm:1.1.1" dependencies: @@ -25912,13 +25834,6 @@ __metadata: languageName: node linkType: hard -"is-map@npm:^2.0.2": - version: 2.0.2 - resolution: "is-map@npm:2.0.2" - checksum: 119ff9137a37fd131a72fab3f4ab8c9d6a24b0a1ee26b4eff14dc625900d8675a97785eea5f4174265e2006ed076cc24e89f6e57ebd080a48338d914ec9168a5 - languageName: node - linkType: hard - "is-module@npm:^1.0.0": version: 1.0.0 resolution: "is-module@npm:1.0.0" @@ -26125,13 +26040,6 @@ __metadata: languageName: node linkType: hard -"is-set@npm:^2.0.2": - version: 2.0.2 - resolution: "is-set@npm:2.0.2" - checksum: 5f8bd1880df8c0004ce694e315e6e1e47a3452014be792880bb274a3b2cdb952fdb60789636ca6e084c7947ca8b7ae03ccaf54c93a7fcfed228af810559e5432 - languageName: node - linkType: hard - "is-shared-array-buffer@npm:^1.0.2": version: 1.0.2 resolution: "is-shared-array-buffer@npm:1.0.2" @@ -26324,13 +26232,6 @@ __metadata: languageName: node linkType: hard -"isarray@npm:^2.0.5": - version: 2.0.5 - resolution: "isarray@npm:2.0.5" - checksum: 4199f14a7a13da2177c66c31080008b7124331956f47bca57dd0b6ea9f11687aa25e565a2c7a2b519bc86988d10398e3049a1f5df13c9f6b7664154690ae79fd - languageName: node - linkType: hard - "isbinaryfile@npm:^4.0.6": version: 4.0.10 resolution: "isbinaryfile@npm:4.0.10" @@ -26491,23 +26392,6 @@ __metadata: languageName: node linkType: hard -"iterate-iterator@npm:^1.0.1": - version: 1.0.2 - resolution: "iterate-iterator@npm:1.0.2" - checksum: 74609b01a3ebc025601aa68ef40731b05d5e45c9fd4ecf233a14a34f2b3481e6974e1dcff390e87155a0648f056c186336bb4c70df2fdefeab08a9878b2eb1c2 - languageName: node - linkType: hard - -"iterate-value@npm:^1.0.2": - version: 1.0.2 - resolution: "iterate-value@npm:1.0.2" - dependencies: - es-get-iterator: ^1.0.2 - iterate-iterator: ^1.0.1 - checksum: 77d32a5ac84877da2133689ff5e3983aa8214bace7faee3c746bf79d4524cc3fb8c0344a20d3699be20a15f0959ecd582d53a05b97f5d04c306bcd426800a650 - languageName: node - linkType: hard - "jake@npm:^10.8.5": version: 10.8.5 resolution: "jake@npm:10.8.5" @@ -32669,7 +32553,7 @@ __metadata: languageName: node linkType: hard -"object.entries@npm:^1.1.0, object.entries@npm:^1.1.1, object.entries@npm:^1.1.2, object.entries@npm:^1.1.5": +"object.entries@npm:^1.1.1, object.entries@npm:^1.1.2, object.entries@npm:^1.1.5": version: 1.1.5 resolution: "object.entries@npm:1.1.5" dependencies: @@ -32680,7 +32564,7 @@ __metadata: languageName: node linkType: hard -"object.fromentries@npm:^2.0.0 || ^1.0.0, object.fromentries@npm:^2.0.3, object.fromentries@npm:^2.0.5": +"object.fromentries@npm:^2.0.3, object.fromentries@npm:^2.0.5": version: 2.0.5 resolution: "object.fromentries@npm:2.0.5" dependencies: @@ -32691,7 +32575,7 @@ __metadata: languageName: node linkType: hard -"object.getownpropertydescriptors@npm:^2.0.3, object.getownpropertydescriptors@npm:^2.1.0, object.getownpropertydescriptors@npm:^2.1.1, object.getownpropertydescriptors@npm:^2.1.2": +"object.getownpropertydescriptors@npm:^2.0.3, object.getownpropertydescriptors@npm:^2.1.0, object.getownpropertydescriptors@npm:^2.1.1": version: 2.1.4 resolution: "object.getownpropertydescriptors@npm:2.1.4" dependencies: @@ -35521,20 +35405,6 @@ __metadata: languageName: node linkType: hard -"promise.allsettled@npm:^1.0.0": - version: 1.0.5 - resolution: "promise.allsettled@npm:1.0.5" - dependencies: - array.prototype.map: ^1.0.4 - call-bind: ^1.0.2 - define-properties: ^1.1.3 - es-abstract: ^1.19.1 - get-intrinsic: ^1.1.1 - iterate-value: ^1.0.2 - checksum: 6cc51174a075b4f63e1a0e2a4526efe3f8ccba25c81ea916bd8398c2208a43b5bec6a64ca95e59fd01d1c72a15f0bc17be496e43a4c2fdcaf200100951b72fd6 - languageName: node - linkType: hard - "promise.hash.helper@npm:^1.0.7": version: 1.0.8 resolution: "promise.hash.helper@npm:1.0.8" @@ -35542,17 +35412,6 @@ __metadata: languageName: node linkType: hard -"promise.prototype.finally@npm:^3.1.0": - version: 3.1.3 - resolution: "promise.prototype.finally@npm:3.1.3" - dependencies: - call-bind: ^1.0.2 - define-properties: ^1.1.3 - es-abstract: ^1.19.1 - checksum: 1d90addb68d13a2f7aa3f35e5892548928d2c9e11074e3e33dd1d58885a357a306462fe957ce2fc9acf46b3a6dd09389daa18085257c1734dec3c128c3d09bd2 - languageName: node - linkType: hard - "promise@npm:^7.0.1": version: 7.3.1 resolution: "promise@npm:7.3.1" @@ -40262,7 +40121,7 @@ __metadata: languageName: node linkType: hard -"string.prototype.matchall@npm:^4.0.0 || ^3.0.1, string.prototype.matchall@npm:^4.0.6, string.prototype.matchall@npm:^4.0.7": +"string.prototype.matchall@npm:^4.0.6, string.prototype.matchall@npm:^4.0.7": version: 4.0.7 resolution: "string.prototype.matchall@npm:4.0.7" dependencies: @@ -40289,17 +40148,6 @@ __metadata: languageName: node linkType: hard -"string.prototype.padstart@npm:^3.0.0": - version: 3.1.3 - resolution: "string.prototype.padstart@npm:3.1.3" - dependencies: - call-bind: ^1.0.2 - define-properties: ^1.1.3 - es-abstract: ^1.19.1 - checksum: 3fbe6ba613461b19a69294ba4580b41906f1dc74d51234d0c34c8c1cc808578c0b87b67b46f7a91ff2c9b45c20676b98f326d5fb8b5221a39d1ebfdd899f42e7 - languageName: node - linkType: hard - "string.prototype.trim@npm:^1.2.1": version: 1.2.6 resolution: "string.prototype.trim@npm:1.2.6" @@ -40991,18 +40839,6 @@ __metadata: languageName: node linkType: hard -"symbol.prototype.description@npm:^1.0.0": - version: 1.0.5 - resolution: "symbol.prototype.description@npm:1.0.5" - dependencies: - call-bind: ^1.0.2 - get-symbol-description: ^1.0.0 - has-symbols: ^1.0.2 - object.getownpropertydescriptors: ^2.1.2 - checksum: 6009bb54faa50fd899772baa0c047d4d4fc85cd03b7e2b5e5385f23f4688879518103ab4a95a03b0b25e4c89c10cf0bb16c159865df2c932682cc56502693650 - languageName: node - linkType: hard - "symlink-or-copy@npm:^1.0.0, symlink-or-copy@npm:^1.0.1, symlink-or-copy@npm:^1.1.8, symlink-or-copy@npm:^1.2.0, symlink-or-copy@npm:^1.3.1": version: 1.3.1 resolution: "symlink-or-copy@npm:1.3.1" From fff143f6bc7005f4be8f78a51ff8ae135f5c8282 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 15 Jun 2022 16:21:15 +0200 Subject: [PATCH 03/12] lockfile update --- yarn.lock | 2 -- 1 file changed, 2 deletions(-) diff --git a/yarn.lock b/yarn.lock index 87ede26dc145..eaf0e44dc218 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7671,7 +7671,6 @@ __metadata: qs: ^6.10.0 regenerator-runtime: ^0.13.7 ts-dedent: ^2.0.0 - unfetch: ^4.2.0 util-deprecate: ^1.0.2 peerDependenciesMeta: typescript: @@ -8557,7 +8556,6 @@ __metadata: qs: ^6.10.0 synchronous-promise: ^2.0.15 ts-dedent: ^2.0.0 - unfetch: ^4.2.0 util-deprecate: ^1.0.2 peerDependencies: react: ^16.8.0 || ^17.0.0 || ^18.0.0 From 8e84f36d0f3abc75867b6b69de3e1c12c23b9166 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 16 Jun 2022 16:59:06 +0200 Subject: [PATCH 04/12] cleanup tsconfigs and make things strict if possible --- addons/a11y/tsconfig.json | 10 +-- .../src/containers/ActionLogger/index.tsx | 4 +- addons/actions/src/manager.tsx | 2 +- addons/actions/src/preview/action.ts | 1 + addons/actions/src/preview/withActions.ts | 2 +- addons/actions/tsconfig.json | 2 +- addons/controls/tsconfig.json | 2 +- addons/docs/tsconfig.json | 3 +- addons/essentials/src/index.ts | 4 +- addons/essentials/tsconfig.json | 2 +- addons/jest/tsconfig.json | 1 - .../links/src/react/components/RoutedLink.tsx | 4 +- addons/links/src/react/components/link.tsx | 15 ++-- addons/links/src/utils.ts | 6 +- addons/links/tsconfig.json | 2 +- .../storyshots/storyshots-core/tsconfig.json | 8 +- .../storyshots-puppeteer/tsconfig.json | 4 +- .../src/components/ToolbarMenuList.tsx | 6 +- .../src/components/ToolbarMenuListItem.tsx | 2 +- addons/toolbars/src/hoc/withKeyboardCycle.tsx | 2 +- .../src/utils/create-cycle-value-array.ts | 2 +- addons/toolbars/src/utils/get-selected.ts | 10 ++- addons/toolbars/tsconfig.json | 2 +- frameworks/ember/src/client/preview/render.ts | 4 +- .../server/framework-preset-babel-ember.ts | 8 +- frameworks/ember/tsconfig.json | 2 +- frameworks/html-webpack5/tsconfig.json | 2 +- frameworks/preact-webpack5/tsconfig.json | 2 +- frameworks/react-webpack5/src/preset.ts | 5 +- frameworks/react-webpack5/tsconfig.json | 2 +- frameworks/server-webpack5/tsconfig.json | 2 +- frameworks/svelte-webpack5/tsconfig.json | 2 +- frameworks/vue-webpack5/tsconfig.json | 2 +- frameworks/vue3-webpack5/tsconfig.json | 1 - .../web-components-webpack5/tsconfig.json | 2 +- lib/addons/src/main.ts | 2 +- lib/api/tsconfig.json | 10 +-- lib/builder-webpack5/src/index.ts | 14 +-- .../src/preview/base-webpack.config.ts | 6 +- lib/builder-webpack5/tsconfig.json | 2 +- lib/cli/tsconfig.json | 5 -- lib/client-logger/src/index.ts | 6 +- lib/client-logger/tsconfig.json | 4 +- lib/codemod/src/lib/utils.ts | 3 + lib/codemod/src/transforms/csf-2-to-3.ts | 4 +- lib/codemod/tsconfig.json | 3 - lib/components/src/Zoom/ZoomIFrame.tsx | 4 +- lib/components/tsconfig.json | 4 - lib/core-common/src/presets.ts | 46 +++++----- lib/core-common/src/utils/envs.ts | 2 +- lib/core-common/src/utils/findDistEsm.ts | 7 +- .../src/utils/get-storybook-info.ts | 2 +- .../src/utils/load-custom-presets.ts | 5 +- .../src/utils/normalize-stories.ts | 3 +- lib/core-common/src/utils/paths.ts | 10 ++- lib/core-common/tsconfig.json | 5 +- lib/core-server/src/build-static.ts | 12 +-- lib/core-server/tsconfig.json | 4 - lib/core-webpack/src/merge-webpack-config.ts | 68 +++++++------- lib/core-webpack/src/types.ts | 29 +++--- lib/core-webpack/tsconfig.json | 5 +- lib/csf-tools/src/ConfigFile.ts | 4 +- lib/csf-tools/tsconfig.json | 3 - .../src/argTypes/convert/flow/convert.ts | 1 + lib/docs-tools/tsconfig.json | 3 - lib/node-logger/src/index.ts | 2 + lib/node-logger/tsconfig.json | 4 +- lib/preview-web/src/StoryRender.ts | 28 +++--- lib/preview-web/src/UrlStore.ts | 3 + lib/preview-web/tsconfig.json | 7 -- lib/store/tsconfig.json | 3 - lib/telemetry/src/get-monorepo-type.ts | 15 ++-- lib/telemetry/src/index.ts | 4 +- lib/telemetry/src/storybook-metadata.ts | 10 ++- lib/telemetry/src/telemetry.ts | 2 +- lib/telemetry/src/types.ts | 2 +- lib/telemetry/tsconfig.json | 4 +- lib/ui/src/components/layout/container.tsx | 11 ++- .../notifications/NotificationItem.tsx | 4 +- lib/ui/src/components/panel/panel.tsx | 2 +- lib/ui/tsconfig.json | 1 - presets/html-webpack/src/index.ts | 16 +++- presets/html-webpack/tsconfig.json | 2 +- presets/preact-webpack/src/index.ts | 2 +- presets/preact-webpack/tsconfig.json | 2 +- .../react-webpack/src/framework-preset-cra.ts | 4 +- .../src/framework-preset-react-docs.ts | 6 +- .../src/framework-preset-react-dom-hack.ts | 2 +- .../src/framework-preset-react.ts | 6 +- presets/react-webpack/tsconfig.json | 2 +- presets/server-webpack/src/index.ts | 28 +++--- .../src/lib/compiler/stringifier.ts | 2 +- presets/server-webpack/tsconfig.json | 2 +- .../src/framework-preset-svelte-docs.ts | 20 +++-- .../src/framework-preset-svelte.ts | 8 +- .../src/svelte-docgen-loader.ts | 18 ++-- presets/svelte-webpack/tsconfig.json | 2 +- presets/vue-webpack/tsconfig.json | 1 - presets/vue3-webpack/tsconfig.json | 1 - presets/web-components-webpack/src/index.ts | 68 +++++++------- presets/web-components-webpack/tsconfig.json | 2 +- renderers/html/src/docs/sourceDecorator.ts | 6 +- renderers/html/src/preview/render.ts | 4 +- renderers/html/tsconfig.json | 2 +- renderers/preact/src/preview/render.tsx | 7 +- renderers/preact/tsconfig.json | 1 + renderers/react/src/docs/extractArgTypes.ts | 6 +- renderers/react/src/docs/jsxDecorator.tsx | 1 + .../lib/defaultValues/createDefaultValue.ts | 2 +- .../defaultValues/createFromRawDefaultProp.ts | 5 +- .../lib/defaultValues/prettyIdentifier.ts | 2 + .../src/docs/lib/inspection/acornParser.ts | 4 +- .../react/src/docs/propTypes/createType.ts | 32 ++++--- .../react/src/docs/propTypes/sortProps.ts | 2 +- renderers/react/src/preview/render.tsx | 2 +- renderers/react/src/testing/index.ts | 1 + renderers/react/tsconfig.json | 1 + renderers/server/src/preview/render.ts | 2 +- renderers/svelte/src/docs/extractArgTypes.ts | 90 ++++++++++--------- .../src/docs/extractComponentDescription.ts | 2 +- renderers/svelte/src/docs/sourceDecorator.ts | 13 +-- renderers/svelte/src/preview/render.ts | 2 +- renderers/svelte/tsconfig.json | 2 +- renderers/vue/src/preview/render.ts | 6 +- renderers/vue3/src/preview/render.ts | 4 +- .../web-components/src/preview/render.ts | 4 +- tsconfig.json | 1 + 127 files changed, 504 insertions(+), 402 deletions(-) diff --git a/addons/a11y/tsconfig.json b/addons/a11y/tsconfig.json index d608603eb9bd..4f9534826dd7 100644 --- a/addons/a11y/tsconfig.json +++ b/addons/a11y/tsconfig.json @@ -1,15 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": [ - "jest" - ], - "forceConsistentCasingInFileNames": true, - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true + "strict": true }, "include": [ "src/**/*" diff --git a/addons/actions/src/containers/ActionLogger/index.tsx b/addons/actions/src/containers/ActionLogger/index.tsx index 2de6c68f9ad9..e1f45154d9af 100644 --- a/addons/actions/src/containers/ActionLogger/index.tsx +++ b/addons/actions/src/containers/ActionLogger/index.tsx @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import deepEqual from 'fast-deep-equal'; -import { API } from '@storybook/api'; +import type { API } from '@storybook/api'; import { STORY_CHANGED } from '@storybook/core-events'; import { ActionLogger as ActionLoggerComponent } from '../../components/ActionLogger'; @@ -31,6 +31,8 @@ export default class ActionLogger extends Component { return `Actions${suffix}`; }, type: types.PANEL, - render: ({ active, key }) => , + render: ({ active, key }) => , paramKey: PARAM_KEY, }); }); diff --git a/addons/actions/src/preview/action.ts b/addons/actions/src/preview/action.ts index c8af13de05d1..05c1f7bb5897 100644 --- a/addons/actions/src/preview/action.ts +++ b/addons/actions/src/preview/action.ts @@ -20,6 +20,7 @@ const isReactSyntheticEvent = (e: unknown): e is SyntheticEvent => const serializeArg = (a: T) => { if (isReactSyntheticEvent(a)) { const e: SyntheticEvent = Object.create( + // @ts-ignore a.constructor.prototype, Object.getOwnPropertyDescriptors(a) ); diff --git a/addons/actions/src/preview/withActions.ts b/addons/actions/src/preview/withActions.ts index 1a1c121f9309..d48ded13eae7 100644 --- a/addons/actions/src/preview/withActions.ts +++ b/addons/actions/src/preview/withActions.ts @@ -31,7 +31,7 @@ const hasMatchInAncestry = (element: any, selector: any): boolean => { const createHandlers = (actionsFn: (...arg: any[]) => object, ...handles: any[]) => { const actionsObject = actionsFn(...handles); return Object.entries(actionsObject).map(([key, action]) => { - const [_, eventName, selector] = key.match(delegateEventSplitter); + const [_, eventName, selector] = key.match(delegateEventSplitter) || []; return { eventName, handler: (e: { target: any }) => { diff --git a/addons/actions/tsconfig.json b/addons/actions/tsconfig.json index 5014371ca67b..a39f63aa8d3a 100644 --- a/addons/actions/tsconfig.json +++ b/addons/actions/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["jest"] + "strict": true }, "include": [ "src/**/*" diff --git a/addons/controls/tsconfig.json b/addons/controls/tsconfig.json index e0e98d4d08f0..a39f63aa8d3a 100644 --- a/addons/controls/tsconfig.json +++ b/addons/controls/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["jest", "node"] + "strict": true }, "include": [ "src/**/*" diff --git a/addons/docs/tsconfig.json b/addons/docs/tsconfig.json index 12a02683f22b..37c5823b162c 100644 --- a/addons/docs/tsconfig.json +++ b/addons/docs/tsconfig.json @@ -1,8 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "skipLibCheck": true, - "types": ["jest", "node"] + "skipLibCheck": true }, "include": [ "src/**/*" diff --git a/addons/essentials/src/index.ts b/addons/essentials/src/index.ts index 7b5bc79e3741..e7f92b88bb7a 100644 --- a/addons/essentials/src/index.ts +++ b/addons/essentials/src/index.ts @@ -3,7 +3,7 @@ import { logger } from '@storybook/node-logger'; import { serverRequire } from '@storybook/core-common'; interface PresetOptions { - configDir?: string; + configDir: string; docs?: boolean; controls?: boolean; actions?: boolean; @@ -23,7 +23,7 @@ const requireMain = (configDir: string) => { return serverRequire(mainFile) ?? {}; }; -export function addons(options: PresetOptions = {}) { +export function addons(options: PresetOptions) { const checkInstalled = (addon: string, main: any) => { const existingAddon = main.addons?.find((entry: string | { name: string }) => { const name = typeof entry === 'string' ? entry : entry.name; diff --git a/addons/essentials/tsconfig.json b/addons/essentials/tsconfig.json index e0e98d4d08f0..a39f63aa8d3a 100644 --- a/addons/essentials/tsconfig.json +++ b/addons/essentials/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["jest", "node"] + "strict": true }, "include": [ "src/**/*" diff --git a/addons/jest/tsconfig.json b/addons/jest/tsconfig.json index 5014371ca67b..b0404cb09787 100644 --- a/addons/jest/tsconfig.json +++ b/addons/jest/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["jest"] }, "include": [ "src/**/*" diff --git a/addons/links/src/react/components/RoutedLink.tsx b/addons/links/src/react/components/RoutedLink.tsx index 7fbf75157ba4..a27a21221436 100644 --- a/addons/links/src/react/components/RoutedLink.tsx +++ b/addons/links/src/react/components/RoutedLink.tsx @@ -18,7 +18,9 @@ const RoutedLink: React.FC< const handleClick = (e: React.MouseEvent) => { if (isPlainLeftClick(e)) { e.preventDefault(); - onClick(e); + if (onClick) { + onClick(e); + } } }; diff --git a/addons/links/src/react/components/link.tsx b/addons/links/src/react/components/link.tsx index aa6207eff75c..714b62fb8b5f 100644 --- a/addons/links/src/react/components/link.tsx +++ b/addons/links/src/react/components/link.tsx @@ -19,8 +19,8 @@ const cancelled = (e: MouseEvent, cb = (_e: any) => {}) => { }; interface Props { - kind: string; - story: string; + kind: string | null; + story: string | null; children: ReactNode; } @@ -53,12 +53,17 @@ export default class LinkTo extends PureComponent { updateHref = async () => { const { kind, story } = this.props; - const href = await hrefTo(kind, story); - this.setState({ href }); + if (kind && story) { + const href = await hrefTo(kind, story); + this.setState({ href }); + } }; handleClick = () => { - navigate(this.props); + const { kind, story } = this.props; + if (kind && story) { + navigate({ kind, story }); + } }; render() { diff --git a/addons/links/src/utils.ts b/addons/links/src/utils.ts index 3ea03c30f0ef..328e8442e2a8 100644 --- a/addons/links/src/utils.ts +++ b/addons/links/src/utils.ts @@ -36,7 +36,9 @@ export const hrefTo = (title: ComponentTitle, name: StoryName): Promise return new Promise((resolve) => { const { location } = document; const query = parseQuery(location.search); + // @ts-ignore const existingId = [].concat(query.id)[0]; + // @ts-ignore const titleToLink = title || existingId.split('--', 2)[0]; const id = toId(titleToLink, name); const url = `${location.origin + location.pathname}?${Object.entries({ ...query, id }) @@ -55,11 +57,11 @@ export const linkTo = (...args: any[]) => { const resolver = valueOrCall(args); const title = resolver(idOrTitle); - const name = resolver(nameInput); + const name = nameInput ? resolver(nameInput) : false; if (title?.match(/--/) && !name) { navigate({ storyId: title }); - } else { + } else if (name) { navigate({ kind: title, story: name }); } }; diff --git a/addons/links/tsconfig.json b/addons/links/tsconfig.json index a836f0d11d8f..a39f63aa8d3a 100644 --- a/addons/links/tsconfig.json +++ b/addons/links/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["@testing-library/jest-dom"] + "strict": true }, "include": [ "src/**/*" diff --git a/addons/storyshots/storyshots-core/tsconfig.json b/addons/storyshots/storyshots-core/tsconfig.json index ab2a43a30102..318ec922baf7 100644 --- a/addons/storyshots/storyshots-core/tsconfig.json +++ b/addons/storyshots/storyshots-core/tsconfig.json @@ -1,13 +1,13 @@ { "extends": "../../../tsconfig.json", - "include": [ - "src/**/*.ts" - ], "compilerOptions": { "experimentalDecorators": true, "declaration": true, "jsx": "preserve", "skipLibCheck": true, "skipDefaultLibCheck": true - } + }, + "include": [ + "src/**/*.ts" + ] } \ No newline at end of file diff --git a/addons/storyshots/storyshots-puppeteer/tsconfig.json b/addons/storyshots/storyshots-puppeteer/tsconfig.json index 60ee7ab94115..bf38a53eb0c4 100644 --- a/addons/storyshots/storyshots-puppeteer/tsconfig.json +++ b/addons/storyshots/storyshots-puppeteer/tsconfig.json @@ -8,5 +8,7 @@ "include": [ "src/**/*" ], - "exclude": ["src/__tests__/**/*"] + "exclude": [ + "src/__tests__/**/*" + ] } diff --git a/addons/toolbars/src/components/ToolbarMenuList.tsx b/addons/toolbars/src/components/ToolbarMenuList.tsx index ae921689ad89..44a5659bb3f9 100644 --- a/addons/toolbars/src/components/ToolbarMenuList.tsx +++ b/addons/toolbars/src/components/ToolbarMenuList.tsx @@ -45,7 +45,7 @@ export const ToolbarMenuList: FC = withKeyboardCycle( } const handleItemClick = useCallback( - (value: string) => { + (value: string | undefined) => { updateGlobals({ [id]: value }); }, [currentValue, updateGlobals] @@ -85,9 +85,9 @@ export const ToolbarMenuList: FC = withKeyboardCycle( > ); diff --git a/addons/toolbars/src/components/ToolbarMenuListItem.tsx b/addons/toolbars/src/components/ToolbarMenuListItem.tsx index 487711decc6a..5107df73a06c 100644 --- a/addons/toolbars/src/components/ToolbarMenuListItem.tsx +++ b/addons/toolbars/src/components/ToolbarMenuListItem.tsx @@ -30,7 +30,7 @@ export const ToolbarMenuListItem = ({ const hasContent = left || right || title; const Item: ListItem = { - id: value, + id: value || currentValue, active: currentValue === value, onClick, }; diff --git a/addons/toolbars/src/hoc/withKeyboardCycle.tsx b/addons/toolbars/src/hoc/withKeyboardCycle.tsx index 9f8317d0de62..67683018bf4f 100644 --- a/addons/toolbars/src/hoc/withKeyboardCycle.tsx +++ b/addons/toolbars/src/hoc/withKeyboardCycle.tsx @@ -17,7 +17,7 @@ export const withKeyboardCycle = (Component: React.ComponentType([]); const currentValue = globals[id]; const reset = useCallback(() => { diff --git a/addons/toolbars/src/utils/create-cycle-value-array.ts b/addons/toolbars/src/utils/create-cycle-value-array.ts index af696d31bbbf..88d46423575d 100644 --- a/addons/toolbars/src/utils/create-cycle-value-array.ts +++ b/addons/toolbars/src/utils/create-cycle-value-array.ts @@ -5,7 +5,7 @@ const disallowedCycleableItemTypes: Array = ['reset']; export const createCycleValueArray = (items: ToolbarItem[]) => { // Do not allow items in the cycle arrays that are conditional in placement const valueArray = items - .filter((item) => !disallowedCycleableItemTypes.includes(item.type)) + .filter((item) => !disallowedCycleableItemTypes.includes(item.type as ToolbarItemType)) .map((item) => item.value); return valueArray; }; diff --git a/addons/toolbars/src/utils/get-selected.ts b/addons/toolbars/src/utils/get-selected.ts index 245f0b9fe04a..b1d3d419938a 100644 --- a/addons/toolbars/src/utils/get-selected.ts +++ b/addons/toolbars/src/utils/get-selected.ts @@ -12,10 +12,16 @@ export const getSelectedItem = ({ currentValue, items }: GetSelectedItemProps) = export const getSelectedIcon = ({ currentValue, items }: GetSelectedItemProps) => { const selectedItem = getSelectedItem({ currentValue, items }); - return selectedItem?.icon; + if (selectedItem) { + return selectedItem.icon; + } + return undefined; }; export const getSelectedTitle = ({ currentValue, items }: GetSelectedItemProps) => { const selectedItem = getSelectedItem({ currentValue, items }); - return selectedItem?.title; + if (selectedItem) { + return selectedItem.title; + } + return undefined; }; diff --git a/addons/toolbars/tsconfig.json b/addons/toolbars/tsconfig.json index 5014371ca67b..a39f63aa8d3a 100644 --- a/addons/toolbars/tsconfig.json +++ b/addons/toolbars/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["jest"] + "strict": true }, "include": [ "src/**/*" diff --git a/frameworks/ember/src/client/preview/render.ts b/frameworks/ember/src/client/preview/render.ts index 29f9375680a6..77dda1b3d5f4 100644 --- a/frameworks/ember/src/client/preview/render.ts +++ b/frameworks/ember/src/client/preview/render.ts @@ -20,7 +20,7 @@ let lastPromise = app.boot(); let hasRendered = false; let isRendering = false; -function render(options: OptionsArgs, el: HTMLElement) { +function render(options: OptionsArgs, el: Element) { if (isRendering) return; isRendering = true; @@ -62,7 +62,7 @@ function render(options: OptionsArgs, el: HTMLElement) { export function renderToDOM( { storyFn, kind, name, showMain, showError }: RenderContext, - domElement: HTMLElement + domElement: Element ) { const element = storyFn(); diff --git a/frameworks/ember/src/server/framework-preset-babel-ember.ts b/frameworks/ember/src/server/framework-preset-babel-ember.ts index da857b38fada..cab822afcfde 100644 --- a/frameworks/ember/src/server/framework-preset-babel-ember.ts +++ b/frameworks/ember/src/server/framework-preset-babel-ember.ts @@ -19,8 +19,10 @@ export function babel(config: TransformOptions, options: Options): TransformOpti options.presetsList.forEach((e: any, index: number) => { if (e.preset && e.preset.emberOptions) { emberOptions = e.preset.emberOptions; - // eslint-disable-next-line no-param-reassign - delete options.presetsList[index].preset.emberOptions; + if (options.presetsList) { + // eslint-disable-next-line no-param-reassign + delete options.presetsList[index].preset.emberOptions; + } } }); } @@ -44,7 +46,7 @@ export function babel(config: TransformOptions, options: Options): TransformOpti return { ...config, - plugins: [].concat(babelConfigPlugins, extraPlugins), + plugins: [...babelConfigPlugins, ...extraPlugins], }; } diff --git a/frameworks/ember/tsconfig.json b/frameworks/ember/tsconfig.json index 9a04c54b3658..06370360a7b1 100644 --- a/frameworks/ember/tsconfig.json +++ b/frameworks/ember/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["node"], + "strict": true, "resolveJsonModule": true }, "include": [ diff --git a/frameworks/html-webpack5/tsconfig.json b/frameworks/html-webpack5/tsconfig.json index 6de485f52855..83939a26978e 100644 --- a/frameworks/html-webpack5/tsconfig.json +++ b/frameworks/html-webpack5/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["node"] + "strict": true }, "include": [ "src/**/*" diff --git a/frameworks/preact-webpack5/tsconfig.json b/frameworks/preact-webpack5/tsconfig.json index 68d3d8a53952..d41628347c9b 100644 --- a/frameworks/preact-webpack5/tsconfig.json +++ b/frameworks/preact-webpack5/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["node"], + "strict": true, "resolveJsonModule": true }, "include": [ diff --git a/frameworks/react-webpack5/src/preset.ts b/frameworks/react-webpack5/src/preset.ts index e6136aebc262..67f02b764f90 100644 --- a/frameworks/react-webpack5/src/preset.ts +++ b/frameworks/react-webpack5/src/preset.ts @@ -16,9 +16,12 @@ export const core = async (config: StorybookConfig['core']) => { }; export const webpack: StorybookConfig['webpack'] = async (config) => { + // eslint-disable-next-line no-param-reassign + config.resolve = config.resolve || {}; + // eslint-disable-next-line no-param-reassign config.resolve.alias = { - ...config.resolve.alias, + ...config.resolve?.alias, '@storybook/react': path.dirname( require.resolve(path.join('@storybook/react', 'package.json')) ), diff --git a/frameworks/react-webpack5/tsconfig.json b/frameworks/react-webpack5/tsconfig.json index 16d169c4e222..793c36aa00d8 100644 --- a/frameworks/react-webpack5/tsconfig.json +++ b/frameworks/react-webpack5/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["node"], + "strict": true, "resolveJsonModule": true }, "include": [ diff --git a/frameworks/server-webpack5/tsconfig.json b/frameworks/server-webpack5/tsconfig.json index 1ede6a814dd4..bdea127e87fa 100644 --- a/frameworks/server-webpack5/tsconfig.json +++ b/frameworks/server-webpack5/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["node"] + "strict": true }, "include": [ "src/**/*" diff --git a/frameworks/svelte-webpack5/tsconfig.json b/frameworks/svelte-webpack5/tsconfig.json index 68d3d8a53952..d41628347c9b 100644 --- a/frameworks/svelte-webpack5/tsconfig.json +++ b/frameworks/svelte-webpack5/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["node"], + "strict": true, "resolveJsonModule": true }, "include": [ diff --git a/frameworks/vue-webpack5/tsconfig.json b/frameworks/vue-webpack5/tsconfig.json index 68d3d8a53952..d41628347c9b 100644 --- a/frameworks/vue-webpack5/tsconfig.json +++ b/frameworks/vue-webpack5/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["node"], + "strict": true, "resolveJsonModule": true }, "include": [ diff --git a/frameworks/vue3-webpack5/tsconfig.json b/frameworks/vue3-webpack5/tsconfig.json index 4888676bb105..c8d0213c17d2 100644 --- a/frameworks/vue3-webpack5/tsconfig.json +++ b/frameworks/vue3-webpack5/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["node"], "resolveJsonModule": true, "skipLibCheck": true }, diff --git a/frameworks/web-components-webpack5/tsconfig.json b/frameworks/web-components-webpack5/tsconfig.json index 6de485f52855..83939a26978e 100644 --- a/frameworks/web-components-webpack5/tsconfig.json +++ b/frameworks/web-components-webpack5/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["node"] + "strict": true }, "include": [ "src/**/*" diff --git a/lib/addons/src/main.ts b/lib/addons/src/main.ts index ff0923848613..ec2198191bd5 100644 --- a/lib/addons/src/main.ts +++ b/lib/addons/src/main.ts @@ -21,7 +21,7 @@ export interface Addon { id?: string; route?: (routeOptions: RouterData) => string; match?: (matchOptions: RouterData) => boolean; - render: (renderOptions: RenderOptions) => ReactElement; + render: (renderOptions: RenderOptions) => ReactElement | null; paramKey?: string; disabled?: boolean; hidden?: boolean; diff --git a/lib/api/tsconfig.json b/lib/api/tsconfig.json index 255d3fd20010..5960cccb79a2 100644 --- a/lib/api/tsconfig.json +++ b/lib/api/tsconfig.json @@ -1,5 +1,7 @@ { "extends": "../../tsconfig.json", + "compilerOptions": { + }, "include": [ "src/**/*" ], @@ -10,11 +12,5 @@ "src/**/*.stories.*", "src/**/*.mockdata.*", "src/**/__testfixtures__/**" - ], - "compilerOptions": { - "lib": [ - "es2017", - "dom" - ] - } + ] } \ No newline at end of file diff --git a/lib/builder-webpack5/src/index.ts b/lib/builder-webpack5/src/index.ts index 6b93e1d8244d..2d33a372308c 100644 --- a/lib/builder-webpack5/src/index.ts +++ b/lib/builder-webpack5/src/index.ts @@ -14,17 +14,17 @@ let reject: (reason?: any) => void; type WebpackBuilder = Builder; type Unpromise> = T extends Promise ? U : never; -type BuilderStartOptions = Partial['0']>; +type BuilderStartOptions = Parameters['0']; type BuilderStartResult = Unpromise>; type StarterFunction = ( options: BuilderStartOptions ) => AsyncGenerator; -type BuilderBuildOptions = Partial['0']>; +type BuilderBuildOptions = Parameters['0']; type BuilderBuildResult = Unpromise>; type BuilderFunction = ( options: BuilderBuildOptions -) => AsyncGenerator; +) => AsyncGenerator; export const executor = { get: async (options: Options) => { @@ -72,6 +72,7 @@ export const bail: WebpackBuilder['bail'] = async () => { } // we wait for the compiler to finish it's work, so it's command-line output doesn't interfere return new Promise((res, rej) => { + // @ts-ignore if (process && compilation) { try { compilation.close(() => res()); @@ -218,7 +219,10 @@ const builder: BuilderFunction = async function* builderGeneratorFn({ startTime, logger.trace({ message: '=> Preview built', time: process.hrtime(startTime) }); if (stats && stats.hasWarnings()) { - stats.toJson({ warnings: true }).warnings.forEach((e) => logger.warn(e.message)); + // @ts-ignore + stats + .toJson({ warnings: true } as StatsOptions) + .warnings.forEach((e) => logger.warn(e.message)); } // https://webpack.js.org/api/node/#run @@ -228,7 +232,7 @@ const builder: BuilderFunction = async function* builderGeneratorFn({ startTime, return fail(closeErr); } - return succeed(stats); + return succeed(stats as Stats); }); }); }); diff --git a/lib/builder-webpack5/src/preview/base-webpack.config.ts b/lib/builder-webpack5/src/preview/base-webpack.config.ts index 757a8dd86b78..6a85c2a67112 100644 --- a/lib/builder-webpack5/src/preview/base-webpack.config.ts +++ b/lib/builder-webpack5/src/preview/base-webpack.config.ts @@ -7,7 +7,7 @@ export async function createDefaultWebpackConfig( options: Options ): Promise { if ( - options.presetsList.some((preset) => + options.presetsList?.some((preset) => /@storybook(\/|\\)preset-create-react-app/.test( typeof preset === 'string' ? preset : preset.name ) @@ -16,7 +16,7 @@ export async function createDefaultWebpackConfig( return storybookBaseConfig; } - const hasPostcssAddon = options.presetsList.some((preset) => + const hasPostcssAddon = options.presetsList?.some((preset) => /@storybook(\/|\\)addon-postcss/.test(typeof preset === 'string' ? preset : preset.name) ); @@ -55,7 +55,7 @@ export async function createDefaultWebpackConfig( module: { ...storybookBaseConfig.module, rules: [ - ...storybookBaseConfig.module.rules, + ...(storybookBaseConfig.module?.rules || []), cssLoaders, { test: /\.(svg|ico|jpg|jpeg|png|apng|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/, diff --git a/lib/builder-webpack5/tsconfig.json b/lib/builder-webpack5/tsconfig.json index 7d23c3e5c821..0df9a38cec4f 100644 --- a/lib/builder-webpack5/tsconfig.json +++ b/lib/builder-webpack5/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "skipLibCheck": true + "strict": true }, "include": [ "src/**/*", diff --git a/lib/cli/tsconfig.json b/lib/cli/tsconfig.json index ab8e97d07f7c..3bf65a73331d 100644 --- a/lib/cli/tsconfig.json +++ b/lib/cli/tsconfig.json @@ -7,11 +7,6 @@ ], "strict": false, "strictNullChecks": false, - "forceConsistentCasingInFileNames": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, "resolveJsonModule": true }, "include": [ diff --git a/lib/client-logger/src/index.ts b/lib/client-logger/src/index.ts index 036eb5135792..a1ee26103669 100644 --- a/lib/client-logger/src/index.ts +++ b/lib/client-logger/src/index.ts @@ -16,6 +16,8 @@ const levels: Record = { const currentLogLevelString: LogLevel = LOGLEVEL as LogLevel; const currentLogLevelNumber: number = levels[currentLogLevelString] || levels.info; +type LoggingFn = (message: any, ...args: any[]) => void; + export const logger = { trace: (message: any, ...rest: any[]): void => currentLogLevelNumber <= levels.trace && console.trace(message, ...rest), @@ -50,8 +52,8 @@ once.log = once('log'); export const pretty = (type: keyof typeof logger) => - (...args: string[]) => { - const argArray = []; + (...args: Parameters) => { + const argArray: Parameters = [] as any; if (args.length) { const startTagRe = //gi; diff --git a/lib/client-logger/tsconfig.json b/lib/client-logger/tsconfig.json index ce8231f1c1bf..4f9534826dd7 100644 --- a/lib/client-logger/tsconfig.json +++ b/lib/client-logger/tsconfig.json @@ -1,9 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": [ - "node" - ] + "strict": true }, "include": [ "src/**/*" diff --git a/lib/codemod/src/lib/utils.ts b/lib/codemod/src/lib/utils.ts index 1b605c946318..ffcd81e59900 100644 --- a/lib/codemod/src/lib/utils.ts +++ b/lib/codemod/src/lib/utils.ts @@ -22,5 +22,8 @@ export function jscodeshiftToPrettierParser(parser?: string) { tsx: 'typescript', }; + if (!parser) { + return 'babel'; + } return parserMap[parser] || 'babel'; } diff --git a/lib/codemod/src/transforms/csf-2-to-3.ts b/lib/codemod/src/transforms/csf-2-to-3.ts index 18e7e272171f..5b5717a77e7f 100644 --- a/lib/codemod/src/transforms/csf-2-to-3.ts +++ b/lib/codemod/src/transforms/csf-2-to-3.ts @@ -123,7 +123,9 @@ function transform({ source }: { source: string }, api: any, options: { parser?: // const Template = (args) => ; // export const A = Template.bind({}); let storyFn = template && csf._templates[template]; - if (!storyFn) storyFn = init; + if (!storyFn) { + storyFn = init; + } const keyId = t.identifier(key); // @ts-ignore diff --git a/lib/codemod/tsconfig.json b/lib/codemod/tsconfig.json index ce8231f1c1bf..5960cccb79a2 100644 --- a/lib/codemod/tsconfig.json +++ b/lib/codemod/tsconfig.json @@ -1,9 +1,6 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": [ - "node" - ] }, "include": [ "src/**/*" diff --git a/lib/components/src/Zoom/ZoomIFrame.tsx b/lib/components/src/Zoom/ZoomIFrame.tsx index 1c2f0735b5fa..d105a98f1808 100644 --- a/lib/components/src/Zoom/ZoomIFrame.tsx +++ b/lib/components/src/Zoom/ZoomIFrame.tsx @@ -1,10 +1,10 @@ -import { Component, MutableRefObject, ReactElement } from 'react'; +import { Component, RefObject, ReactElement } from 'react'; import { browserSupportsCssZoom } from './browserSupportsCssZoom'; export type IZoomIFrameProps = { scale: number; children: ReactElement; - iFrameRef: MutableRefObject; + iFrameRef: RefObject; active?: boolean; }; diff --git a/lib/components/tsconfig.json b/lib/components/tsconfig.json index 630596ac1ec9..5960cccb79a2 100644 --- a/lib/components/tsconfig.json +++ b/lib/components/tsconfig.json @@ -1,10 +1,6 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": [ - "jest", - "@testing-library/jest-dom" - ] }, "include": [ "src/**/*" diff --git a/lib/core-common/src/presets.ts b/lib/core-common/src/presets.ts index 92be3df32958..a55a91d82a81 100644 --- a/lib/core-common/src/presets.ts +++ b/lib/core-common/src/presets.ts @@ -69,22 +69,24 @@ export const resolveAddonName = ( configDir: string, name: string, options: any -): ResolvedAddonPreset | ResolvedAddonVirtual => { +): ResolvedAddonPreset | ResolvedAddonVirtual | undefined => { const r = name.startsWith('/') ? safeResolve : safeResolveFrom.bind(null, configDir); const resolved = r(name); - if (name.match(/\/(manager|register(-panel)?)(\.(js|ts|tsx|jsx))?$/)) { - return { - type: 'virtual', - name, - managerEntries: [resolved], - }; - } - if (name.match(/\/(preset)(\.(js|ts|tsx|jsx))?$/)) { - return { - type: 'presets', - name: resolved, - }; + if (resolved) { + if (name.match(/\/(manager|register(-panel)?)(\.(js|ts|tsx|jsx))?$/)) { + return { + type: 'virtual', + name, + managerEntries: [resolved], + }; + } + if (name.match(/\/(preset)(\.(js|ts|tsx|jsx))?$/)) { + return { + type: 'presets', + name: resolved, + }; + } } const path = name; @@ -122,10 +124,14 @@ export const resolveAddonName = ( }; } - return { - type: 'presets', - name: resolved, - }; + if (resolved) { + return { + type: 'presets', + name: resolved, + }; + } + + return undefined; }; const map = @@ -199,7 +205,7 @@ export function loadPreset( return [ ...loadPresets([...subPresets], level + 1, storybookOptions), ...loadPresets( - [...subAddons.map(map(storybookOptions))].filter(Boolean), + [...subAddons.map(map(storybookOptions))].filter(Boolean) as PresetConfig[], level + 1, storybookOptions ), @@ -214,7 +220,7 @@ export function loadPreset( throw new Error(dedent` ${input} is not a valid preset `); - } catch (e) { + } catch (e: any) { const warning = level > 0 ? ` Failed to load preset: ${JSON.stringify(input)} on level ${level}` @@ -236,7 +242,7 @@ function loadPresets( return []; } - return presets.reduce((acc, preset) => { + return presets.reduce((acc, preset) => { const loaded = loadPreset(preset, level, storybookOptions); return acc.concat(loaded); }, []); diff --git a/lib/core-common/src/utils/envs.ts b/lib/core-common/src/utils/envs.ts index 18ce66b5e8b4..bd4ecff92468 100644 --- a/lib/core-common/src/utils/envs.ts +++ b/lib/core-common/src/utils/envs.ts @@ -10,7 +10,7 @@ export function loadEnvs(options: { production?: boolean } = {}): { } { const defaultNodeEnv = options.production ? 'production' : 'development'; - const env: Record = { + const env: Record = { NODE_ENV: process.env.NODE_ENV || defaultNodeEnv, NODE_PATH: process.env.NODE_PATH || '', STORYBOOK: process.env.STORYBOOK || 'true', diff --git a/lib/core-common/src/utils/findDistEsm.ts b/lib/core-common/src/utils/findDistEsm.ts index e768dc0159ef..51a34e1669fb 100644 --- a/lib/core-common/src/utils/findDistEsm.ts +++ b/lib/core-common/src/utils/findDistEsm.ts @@ -2,6 +2,11 @@ import path from 'path'; import { sync as findUpSync } from 'find-up'; export const findDistEsm = (cwd: string, relativePath: string) => { - const packageDir = path.dirname(findUpSync('package.json', { cwd })); + const nearestPackageJson = findUpSync('package.json', { cwd }); + if (!nearestPackageJson) { + throw new Error(`Could not find package.json in: ${cwd}`); + } + const packageDir = path.dirname(nearestPackageJson); + return path.join(packageDir, 'dist', 'esm', relativePath); }; diff --git a/lib/core-common/src/utils/get-storybook-info.ts b/lib/core-common/src/utils/get-storybook-info.ts index 623bf7dc8a7d..e44e75f08a02 100644 --- a/lib/core-common/src/utils/get-storybook-info.ts +++ b/lib/core-common/src/utils/get-storybook-info.ts @@ -46,7 +46,7 @@ const getFrameworkInfo = (packageJson: PackageJson) => { // Pull the viewlayer from dependencies in package.json const [dep, devDep, peerDep] = findDependency(packageJson, ([key]) => viewLayers[key]); const [pkg, version] = dep || devDep || peerDep || []; - const framework = viewLayers[pkg]; + const framework = pkg ? viewLayers[pkg] : undefined; if (dep && devDep && dep[0] === devDep[0]) { logger.warn( diff --git a/lib/core-common/src/utils/load-custom-presets.ts b/lib/core-common/src/utils/load-custom-presets.ts index efa449924046..bfa59ac819ba 100644 --- a/lib/core-common/src/utils/load-custom-presets.ts +++ b/lib/core-common/src/utils/load-custom-presets.ts @@ -10,7 +10,10 @@ export function loadCustomPresets({ configDir }: { configDir: string }): PresetC const main = serverRequire(path.resolve(configDir, 'main')); if (main) { - return [serverResolve(path.resolve(configDir, 'main'))]; + const resolved = serverResolve(path.resolve(configDir, 'main')); + if (resolved) { + return [resolved]; + } } return presets || []; diff --git a/lib/core-common/src/utils/normalize-stories.ts b/lib/core-common/src/utils/normalize-stories.ts index 3f1e66b76862..e5fb1b1f4296 100644 --- a/lib/core-common/src/utils/normalize-stories.ts +++ b/lib/core-common/src/utils/normalize-stories.ts @@ -12,9 +12,10 @@ import { globToRegexp } from './glob-to-regexp'; const DEFAULT_TITLE_PREFIX = ''; const DEFAULT_FILES = '**/*.stories.@(mdx|tsx|ts|jsx|js)'; -// LEGACY support for bad glob patterns we had in SB 5 - remove in SB7 +// TODO: remove - LEGACY support for bad glob patterns we had in SB 5 - remove in SB7 const fixBadGlob = deprecate( (match: RegExpMatchArray) => { + // @ts-ignore this will get removed later anyway return match.input.replace(match[1], `@${match[1]}`); }, dedent` diff --git a/lib/core-common/src/utils/paths.ts b/lib/core-common/src/utils/paths.ts index 1059d94375e2..c56839ce252b 100644 --- a/lib/core-common/src/utils/paths.ts +++ b/lib/core-common/src/utils/paths.ts @@ -4,12 +4,18 @@ import findUp from 'find-up'; export const getProjectRoot = () => { let result; try { - result = result || path.join(findUp.sync('.git', { type: 'directory' }), '..'); + const found = findUp.sync('.git', { type: 'directory' }); + if (found) { + result = result || path.join(found, '..'); + } } catch (e) { // } try { - result = result || path.join(findUp.sync('.svn', { type: 'directory' }), '..'); + const found = findUp.sync('.svn', { type: 'directory' }); + if (found) { + result = result || path.join(found, '..'); + } } catch (e) { // } diff --git a/lib/core-common/tsconfig.json b/lib/core-common/tsconfig.json index 925da57ba3e9..fd8e8c5f303e 100644 --- a/lib/core-common/tsconfig.json +++ b/lib/core-common/tsconfig.json @@ -1,10 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": [ - "jest", - "node" - ] + "strict": true }, "include": [ "src/**/*" diff --git a/lib/core-server/src/build-static.ts b/lib/core-server/src/build-static.ts index dc4d2802025e..686a922516e8 100644 --- a/lib/core-server/src/build-static.ts +++ b/lib/core-server/src/build-static.ts @@ -33,7 +33,9 @@ import { extractStoriesJson } from './utils/stories-json'; import { extractStorybookMetadata } from './utils/metadata'; import { StoryIndexGenerator } from './utils/StoryIndexGenerator'; -export async function buildStaticStandalone(options: CLIOptions & LoadOptions & BuilderOptions) { +export async function buildStaticStandalone( + options: CLIOptions & LoadOptions & BuilderOptions & { outputDir: string } +) { /* eslint-disable no-param-reassign */ options.configType = 'PRODUCTION'; @@ -85,12 +87,12 @@ export async function buildStaticStandalone(options: CLIOptions & LoadOptions & presets = loadAllPresets({ corePresets: [ require.resolve('./presets/common-preset'), - ...managerBuilder.corePresets, - ...previewBuilder.corePresets, + ...(managerBuilder.corePresets || []), + ...(previewBuilder.corePresets || []), ...corePresets, require.resolve('./presets/babel-cache-preset'), ], - overridePresets: previewBuilder.overridePresets, + overridePresets: previewBuilder.overridePresets || [], ...options, }); @@ -132,7 +134,7 @@ export async function buildStaticStandalone(options: CLIOptions & LoadOptions & ...directories, storyIndexers, storiesV2Compatibility: !features?.breakingChangesV7 && !features?.storyStoreV7, - storyStoreV7: features?.storyStoreV7, + storyStoreV7: !!features?.storyStoreV7, }); initializedStoryIndexGenerator = generator.initialize().then(() => generator); diff --git a/lib/core-server/tsconfig.json b/lib/core-server/tsconfig.json index adf564ac91bd..4ce2d9a0f15f 100644 --- a/lib/core-server/tsconfig.json +++ b/lib/core-server/tsconfig.json @@ -1,10 +1,6 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": [ - "jest", - "node" - ] }, "include": [ "src/**/*", diff --git a/lib/core-webpack/src/merge-webpack-config.ts b/lib/core-webpack/src/merge-webpack-config.ts index b95f97b87aec..f7b13a78e28f 100644 --- a/lib/core-webpack/src/merge-webpack-config.ts +++ b/lib/core-webpack/src/merge-webpack-config.ts @@ -1,60 +1,62 @@ -import type { CommonWebpackConfiguration as Configuration } from './types'; +import type { + CommonWebpackConfiguration as Configuration, + ModuleConfig, + ResolveConfig, + RulesConfig, +} from './types'; -function plugins( - { plugins: defaultPlugins = [] }: Configuration, - { plugins: customPlugins = [] }: Configuration -): Configuration['plugins'] { +function mergePluginsField( + defaultPlugins: Required['plugins'] = [], + customPlugins: Required['plugins'] = [] +): Required['plugins'] { return [...defaultPlugins, ...customPlugins]; } -function rules( - { rules: defaultRules = [] }: Configuration['module'], - { rules: customRules = [] }: Configuration['module'] -): Configuration['module']['rules'] { +function mergeRulesField( + defaultRules: RulesConfig[] = [], + customRules: RulesConfig[] = [] +): ModuleConfig['rules'] { return [...defaultRules, ...customRules]; } -function extensions( - { extensions: defaultExtensions = [] }: Configuration['resolve'], - { extensions: customExtensions = [] }: Configuration['resolve'] -): Configuration['resolve']['extensions'] { +function mergeExtensionsField( + { extensions: defaultExtensions = [] }: ResolveConfig, + { extensions: customExtensions = [] }: ResolveConfig +): ResolveConfig['extensions'] { return [...defaultExtensions, ...customExtensions]; } -function alias( - { alias: defaultAlias = {} }: Configuration['resolve'], - { alias: customAlias = {} }: Configuration['resolve'] -): Configuration['resolve']['alias'] { +function mergeAliasField( + { alias: defaultAlias = {} }: ResolveConfig, + { alias: customAlias = {} }: ResolveConfig +): ResolveConfig['alias'] { return { ...defaultAlias, ...customAlias, }; } -function module( - { module: defaultModule = { rules: [] } }: Configuration, - { module: customModule = { rules: [] } }: Configuration -): Configuration['module'] { +function mergeModuleField(a: ModuleConfig, b: ModuleConfig): ModuleConfig { return { - ...defaultModule, - ...customModule, - rules: rules(defaultModule, customModule), + ...a, + ...b, + rules: mergeRulesField(a.rules || [], b.rules || []), }; } -function resolve( +function mergeResolveField( { resolve: defaultResolve = {} }: Configuration, { resolve: customResolve = {} }: Configuration -): Configuration['resolve'] { +): ResolveConfig { return { ...defaultResolve, ...customResolve, - alias: alias(defaultResolve, customResolve), - extensions: extensions(defaultResolve, customResolve), + alias: mergeAliasField(defaultResolve, customResolve), + extensions: mergeExtensionsField(defaultResolve, customResolve), }; } -function optimization( +function mergeOptimizationField( { optimization: defaultOptimization = {} }: Configuration, { optimization: customOptimization = {} }: Configuration ): Configuration['optimization'] { @@ -71,9 +73,9 @@ export function mergeConfigs(config: Configuration, customConfig: Configuration) ...customConfig, ...config, devtool: customConfig.devtool || config.devtool, - plugins: plugins(config, customConfig), - module: module(config, customConfig), - resolve: resolve(config, customConfig), - optimization: optimization(config, customConfig), + plugins: mergePluginsField(config.plugins, customConfig.plugins), + module: mergeModuleField(config.module || {}, customConfig.module || {}), + resolve: mergeResolveField(config, customConfig), + optimization: mergeOptimizationField(config, customConfig), }; } diff --git a/lib/core-webpack/src/types.ts b/lib/core-webpack/src/types.ts index 7ae50b020a76..825b49e93dc5 100644 --- a/lib/core-webpack/src/types.ts +++ b/lib/core-webpack/src/types.ts @@ -2,21 +2,27 @@ import type { Options, StorybookConfig as BaseStorybookConfig } from '@storybook export type { Options, Preset, BuilderResult, TypescriptOptions } from '@storybook/core-common'; +export type RulesConfig = any; + +export type ModuleConfig = { + rules?: RulesConfig[]; +}; + +export type ResolveConfig = { + extensions?: string[]; + mainFields?: string[] | string[][]; + alias?: any; +}; + export interface CommonWebpackConfiguration { plugins?: any[]; - module?: { - rules?: any[]; - }; - resolve?: { - extensions?: string[]; - mainFields?: string[] | string[][]; - alias?: any; - }; + module?: ModuleConfig; + resolve?: ResolveConfig; optimization?: any; devtool?: boolean | string; } -export interface StorybookWebpackConfig { +export interface StorybookWebpackConfig { /** * Modify or return a custom Webpack config after the Storybook's default configuration * has run (mostly used by addons). @@ -32,6 +38,5 @@ export interface StorybookWebpackConfig TConfiguration | Promise; } -export type StorybookConfig< - TWebpackConfiguration extends CommonWebpackConfiguration = CommonWebpackConfiguration -> = BaseStorybookConfig & StorybookWebpackConfig; +export type StorybookConfig = + BaseStorybookConfig & StorybookWebpackConfig; diff --git a/lib/core-webpack/tsconfig.json b/lib/core-webpack/tsconfig.json index 925da57ba3e9..fd8e8c5f303e 100644 --- a/lib/core-webpack/tsconfig.json +++ b/lib/core-webpack/tsconfig.json @@ -1,10 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": [ - "jest", - "node" - ] + "strict": true }, "include": [ "src/**/*" diff --git a/lib/csf-tools/src/ConfigFile.ts b/lib/csf-tools/src/ConfigFile.ts index 9e67096e307e..b50617fef4bf 100644 --- a/lib/csf-tools/src/ConfigFile.ts +++ b/lib/csf-tools/src/ConfigFile.ts @@ -28,8 +28,8 @@ const _getPath = (path: string[], node: t.Node): t.Node | undefined => { }; const _findVarInitialization = (identifier: string, program: t.Program) => { - let init: t.Expression = null; - let declarations: t.VariableDeclarator[] = null; + let init: t.Expression | null | undefined = null; + let declarations: t.VariableDeclarator[] | null = null; program.body.find((node: t.Node) => { if (t.isVariableDeclaration(node)) { declarations = node.declarations; diff --git a/lib/csf-tools/tsconfig.json b/lib/csf-tools/tsconfig.json index ce8231f1c1bf..5960cccb79a2 100644 --- a/lib/csf-tools/tsconfig.json +++ b/lib/csf-tools/tsconfig.json @@ -1,9 +1,6 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": [ - "node" - ] }, "include": [ "src/**/*" diff --git a/lib/docs-tools/src/argTypes/convert/flow/convert.ts b/lib/docs-tools/src/argTypes/convert/flow/convert.ts index 5eb262e75fbd..f8fa7cd69862 100644 --- a/lib/docs-tools/src/argTypes/convert/flow/convert.ts +++ b/lib/docs-tools/src/argTypes/convert/flow/convert.ts @@ -43,6 +43,7 @@ export const convert = (type: FlowType): SBType | void => { return { ...base, ...convertSig(type) }; case 'union': if (type.elements.every(isLiteral)) { + // @ts-ignore return { ...base, name: 'enum', value: type.elements.map(toEnumOption) }; } return { ...base, name, value: type.elements.map(convert) }; diff --git a/lib/docs-tools/tsconfig.json b/lib/docs-tools/tsconfig.json index ce8231f1c1bf..5960cccb79a2 100644 --- a/lib/docs-tools/tsconfig.json +++ b/lib/docs-tools/tsconfig.json @@ -1,9 +1,6 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": [ - "node" - ] }, "include": [ "src/**/*" diff --git a/lib/node-logger/src/index.ts b/lib/node-logger/src/index.ts index 2fabd9a871b7..e592d820d148 100644 --- a/lib/node-logger/src/index.ts +++ b/lib/node-logger/src/index.ts @@ -1,3 +1,5 @@ +/// + /* eslint-disable no-console */ import npmLog from 'npmlog'; import prettyTime from 'pretty-hrtime'; diff --git a/lib/node-logger/tsconfig.json b/lib/node-logger/tsconfig.json index ce8231f1c1bf..4f9534826dd7 100644 --- a/lib/node-logger/tsconfig.json +++ b/lib/node-logger/tsconfig.json @@ -1,9 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": [ - "node" - ] + "strict": true }, "include": [ "src/**/*" diff --git a/lib/preview-web/src/StoryRender.ts b/lib/preview-web/src/StoryRender.ts index d0ede7cc1223..d11b142a8f15 100644 --- a/lib/preview-web/src/StoryRender.ts +++ b/lib/preview-web/src/StoryRender.ts @@ -28,6 +28,7 @@ function createController(): AbortController { return { signal: { aborted: false }, abort() { + // @ts-ignore this.signal.aborted = true; }, } as AbortController; @@ -98,12 +99,12 @@ export class StoryRender implements Render { + await this.runPhase((this.abortController as AbortController).signal, 'preparing', async () => { this.story = await this.store.loadStory({ storyId: this.id }); }); - if (this.abortController.signal.aborted) { - this.store.cleanupStory(this.story); + if ((this.abortController as AbortController).signal.aborted) { + this.store.cleanupStory(this.story as Story); throw PREPARE_ABORTED; } } @@ -114,15 +115,15 @@ export class StoryRender implements Render); } async renderToElement(canvasElement: HTMLElement) { @@ -156,7 +157,7 @@ export class StoryRender implements Render; @@ -166,9 +167,12 @@ export class StoryRender implements Render); }); - if (abortSignal.aborted) return; + if (abortSignal.aborted) { + return; + } const renderStoryContext: StoryContext = { + // @ts-ignore ...loadedContext, // By this stage, it is possible that new args/globals have been received for this story // and we need to ensure we render it with the new values @@ -191,7 +195,7 @@ export class StoryRender implements Render - this.renderToScreen(renderContext, this.canvasElement) + this.renderToScreen(renderContext, this.canvasElement as HTMLElement) ); this.notYetRendered = false; if (abortSignal.aborted) return; @@ -210,7 +214,7 @@ export class StoryRender implements Render implements Render) => val != null && typeof val === 'object' && Array.isArray(val) === false; const getFirstString = (v: ValueOf): string | void => { + if (v === undefined) { + return undefined; + } if (typeof v === 'string') { return v; } diff --git a/lib/preview-web/tsconfig.json b/lib/preview-web/tsconfig.json index 1700582dd403..5960cccb79a2 100644 --- a/lib/preview-web/tsconfig.json +++ b/lib/preview-web/tsconfig.json @@ -1,9 +1,6 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": [ - "node" - ] }, "include": [ "src/**/*" @@ -15,9 +12,5 @@ "src/**/*.stories.*", "src/**/*.mockdata.*", "src/**/__testfixtures__/**" - ], - "lib": [ - "es2017", - "dom" ] } \ No newline at end of file diff --git a/lib/store/tsconfig.json b/lib/store/tsconfig.json index ce8231f1c1bf..5960cccb79a2 100644 --- a/lib/store/tsconfig.json +++ b/lib/store/tsconfig.json @@ -1,9 +1,6 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": [ - "node" - ] }, "include": [ "src/**/*" diff --git a/lib/telemetry/src/get-monorepo-type.ts b/lib/telemetry/src/get-monorepo-type.ts index e9c628c521dd..e9a5c08a78d2 100644 --- a/lib/telemetry/src/get-monorepo-type.ts +++ b/lib/telemetry/src/get-monorepo-type.ts @@ -17,18 +17,19 @@ export const getMonorepoType = (): MonorepoType => { const projectRootPath = getProjectRoot(); if (!projectRootPath) return undefined; - const monorepoType = Object.keys(monorepoConfigs).find( - (monorepo: keyof typeof monorepoConfigs) => { - const configFile = path.join(projectRootPath, monorepoConfigs[monorepo]); - return fs.existsSync(configFile); - } - ) as MonorepoType; + const keys = Object.keys(monorepoConfigs) as (keyof typeof monorepoConfigs)[]; + const monorepoType: MonorepoType = keys.find((monorepo) => { + const configFile = path.join(projectRootPath, monorepoConfigs[monorepo]); + return fs.existsSync(configFile); + }) as MonorepoType; if (monorepoType) { return monorepoType; } - if (!fs.existsSync(path.join(projectRootPath, 'package.json'))) return undefined; + if (!fs.existsSync(path.join(projectRootPath, 'package.json'))) { + return undefined; + } const packageJson = fs.readJsonSync(path.join(projectRootPath, 'package.json')) as PackageJson; diff --git a/lib/telemetry/src/index.ts b/lib/telemetry/src/index.ts index 864a66828577..f3a45b3d1570 100644 --- a/lib/telemetry/src/index.ts +++ b/lib/telemetry/src/index.ts @@ -10,7 +10,7 @@ export * from './storybook-metadata'; export const telemetry = async ( eventType: EventType, payload: Payload = {}, - options?: Partial + options: Partial = {} ) => { await notify(); const telemetryData: TelemetryData = { @@ -18,7 +18,7 @@ export const telemetry = async ( payload, }; try { - telemetryData.metadata = await getStorybookMetadata(options.configDir); + telemetryData.metadata = await getStorybookMetadata(options?.configDir); } catch (error) { if (!telemetryData.payload.error) telemetryData.payload.error = error; } finally { diff --git a/lib/telemetry/src/storybook-metadata.ts b/lib/telemetry/src/storybook-metadata.ts index dc0d0833c308..6e8647e3fcd0 100644 --- a/lib/telemetry/src/storybook-metadata.ts +++ b/lib/telemetry/src/storybook-metadata.ts @@ -190,15 +190,19 @@ export const computeStorybookMetadata = async ({ }; let cachedMetadata: StorybookMetadata; -export const getStorybookMetadata = async (_configDir: string) => { +export const getStorybookMetadata = async (_configDir?: string) => { if (cachedMetadata) { return cachedMetadata; } - const packageJson = readPkgUp.sync({ cwd: process.cwd() }).packageJson as PackageJson; + const { packageJson = {} as PackageJson } = readPkgUp.sync({ cwd: process.cwd() }) || {}; const configDir = (_configDir || - (getStorybookConfiguration(packageJson.scripts.storybook, '-c', '--config-dir') as string)) ?? + (getStorybookConfiguration( + packageJson?.scripts?.storybook || '', + '-c', + '--config-dir' + ) as string)) ?? '.storybook'; const mainConfig = loadMainConfig({ configDir }); cachedMetadata = await computeStorybookMetadata({ mainConfig, packageJson }); diff --git a/lib/telemetry/src/telemetry.ts b/lib/telemetry/src/telemetry.ts index 161794a4e703..47225436ec2b 100644 --- a/lib/telemetry/src/telemetry.ts +++ b/lib/telemetry/src/telemetry.ts @@ -40,7 +40,7 @@ export async function sendTelemetry( headers: { 'Content-Type': 'application/json' }, retries: 3, retryOn: [503, 504], - retryDelay: (attempt: number) => 2 ** attempt * options.retryDelay, + retryDelay: (attempt: number) => 2 ** attempt * (options.retryDelay || 1000), }); tasks.push(request); diff --git a/lib/telemetry/src/types.ts b/lib/telemetry/src/types.ts index 60bc575f1631..3014d3fa1f15 100644 --- a/lib/telemetry/src/types.ts +++ b/lib/telemetry/src/types.ts @@ -13,7 +13,7 @@ export type EventType = | 'error-metadata'; export interface Dependency { - version: string; + version: string | undefined; } export interface StorybookAddon extends Dependency { diff --git a/lib/telemetry/tsconfig.json b/lib/telemetry/tsconfig.json index ce8231f1c1bf..4f9534826dd7 100644 --- a/lib/telemetry/tsconfig.json +++ b/lib/telemetry/tsconfig.json @@ -1,9 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": [ - "node" - ] + "strict": true }, "include": [ "src/**/*" diff --git a/lib/ui/src/components/layout/container.tsx b/lib/ui/src/components/layout/container.tsx index 327f26b720f0..c9e103640159 100644 --- a/lib/ui/src/components/layout/container.tsx +++ b/lib/ui/src/components/layout/container.tsx @@ -1,4 +1,11 @@ -import React, { Component, Fragment, FunctionComponent, CSSProperties, ReactNode } from 'react'; +import React, { + Component, + Fragment, + FunctionComponent, + CSSProperties, + ReactNode, + GetDerivedStateFromProps, +} from 'react'; import { styled, withTheme } from '@storybook/theming'; import type { Theme } from '@storybook/theming'; import type { State } from '@storybook/api'; @@ -361,7 +368,7 @@ class Layout extends Component { }; } - static getDerivedStateFromProps(props: LayoutProps, state: LayoutState) { + static getDerivedStateFromProps(props: Readonly, state: LayoutState): LayoutState { const { bounds, options } = props; const { resizerPanel, resizerNav } = state; diff --git a/lib/ui/src/components/notifications/NotificationItem.tsx b/lib/ui/src/components/notifications/NotificationItem.tsx index 9362da68e38b..686b66e15786 100644 --- a/lib/ui/src/components/notifications/NotificationItem.tsx +++ b/lib/ui/src/components/notifications/NotificationItem.tsx @@ -128,7 +128,9 @@ const NotificationItem: FunctionComponent<{ }> = ({ notification: { content, link, onClear, id, icon }, onDismissNotification }) => { const dismissNotificationItem = () => { onDismissNotification(id); - onClear(); + if (onClear) { + onClear(); + } }; return link ? ( diff --git a/lib/ui/src/components/panel/panel.tsx b/lib/ui/src/components/panel/panel.tsx index 60b23b6c3fb4..2312c927bc0c 100644 --- a/lib/ui/src/components/panel/panel.tsx +++ b/lib/ui/src/components/panel/panel.tsx @@ -63,7 +63,7 @@ const AddonPanel = React.memo<{ }) => ( diff --git a/lib/ui/tsconfig.json b/lib/ui/tsconfig.json index 4bc732d30655..b0404cb09787 100644 --- a/lib/ui/tsconfig.json +++ b/lib/ui/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "lib": ["ESNext", "DOM", "DOM.Iterable"] }, "include": [ "src/**/*" diff --git a/presets/html-webpack/src/index.ts b/presets/html-webpack/src/index.ts index 91fcbec914c5..67a7f56f17e2 100644 --- a/presets/html-webpack/src/index.ts +++ b/presets/html-webpack/src/index.ts @@ -1,10 +1,18 @@ import type { StorybookConfig } from '@storybook/core-webpack'; export const webpack: StorybookConfig['webpack'] = (config) => { - config.module.rules.push({ - test: /\.html$/, - use: require.resolve('html-loader') as string, - }); + const rules = [ + ...(config.module?.rules || []), + { + test: /\.html$/, + use: require.resolve('html-loader') as string, + }, + ]; + + // eslint-disable-next-line no-param-reassign + config.module = config.module || {}; + // eslint-disable-next-line no-param-reassign + config.module.rules = rules; return config; }; diff --git a/presets/html-webpack/tsconfig.json b/presets/html-webpack/tsconfig.json index 6de485f52855..83939a26978e 100644 --- a/presets/html-webpack/tsconfig.json +++ b/presets/html-webpack/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["node"] + "strict": true }, "include": [ "src/**/*" diff --git a/presets/preact-webpack/src/index.ts b/presets/preact-webpack/src/index.ts index ecc8e618af88..feda087f1876 100644 --- a/presets/preact-webpack/src/index.ts +++ b/presets/preact-webpack/src/index.ts @@ -17,7 +17,7 @@ export const webpackFinal: StorybookConfig['webpackFinal'] = (config) => { resolve: { ...config.resolve, alias: { - ...(config.resolve.alias || {}), + ...(config.resolve?.alias || {}), react: path.dirname(require.resolve('preact/compat/package.json')), 'react-dom/test-utils': path.dirname(require.resolve('preact/test-utils/package.json')), 'react-dom': path.dirname(require.resolve('preact/compat/package.json')), diff --git a/presets/preact-webpack/tsconfig.json b/presets/preact-webpack/tsconfig.json index 68d3d8a53952..d41628347c9b 100644 --- a/presets/preact-webpack/tsconfig.json +++ b/presets/preact-webpack/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["node"], + "strict": true, "resolveJsonModule": true }, "include": [ diff --git a/presets/react-webpack/src/framework-preset-cra.ts b/presets/react-webpack/src/framework-preset-cra.ts index 63d47ac6df29..fe8dce90b4ab 100644 --- a/presets/react-webpack/src/framework-preset-cra.ts +++ b/presets/react-webpack/src/framework-preset-cra.ts @@ -21,7 +21,9 @@ const checkForNewPreset = (presetsList: Preset[]) => { export const webpackFinal: StorybookConfig['webpack'] = (config, { presetsList }) => { if (isReactScriptsInstalled()) { - checkForNewPreset(presetsList); + if (presetsList) { + checkForNewPreset(presetsList); + } } return config; }; diff --git a/presets/react-webpack/src/framework-preset-react-docs.ts b/presets/react-webpack/src/framework-preset-react-docs.ts index bc3f912adff9..4a322ae78c35 100644 --- a/presets/react-webpack/src/framework-preset-react-docs.ts +++ b/presets/react-webpack/src/framework-preset-react-docs.ts @@ -11,7 +11,7 @@ export const babel: StorybookConfig['babel'] = async (config, options) => { {} as any ); - const { reactDocgen } = typescriptOptions; + const { reactDocgen } = typescriptOptions || {}; if (typeof reactDocgen !== 'string') { return config; @@ -44,7 +44,7 @@ export const webpackFinal: StorybookConfig['webpackFinal'] = async (config, opti {} as any ); - const { reactDocgen, reactDocgenTypescriptOptions } = typescriptOptions; + const { reactDocgen, reactDocgenTypescriptOptions } = typescriptOptions || {}; if (reactDocgen !== 'react-docgen-typescript') { return config; @@ -53,7 +53,7 @@ export const webpackFinal: StorybookConfig['webpackFinal'] = async (config, opti return { ...config, plugins: [ - ...config.plugins, + ...(config.plugins || []), new ReactDocgenTypescriptPlugin({ ...reactDocgenTypescriptOptions, // We *need* this set so that RDT returns default values in the same format as react-docgen diff --git a/presets/react-webpack/src/framework-preset-react-dom-hack.ts b/presets/react-webpack/src/framework-preset-react-dom-hack.ts index 209e61a27a17..16ccf215b322 100644 --- a/presets/react-webpack/src/framework-preset-react-dom-hack.ts +++ b/presets/react-webpack/src/framework-preset-react-dom-hack.ts @@ -11,7 +11,7 @@ export const webpackFinal: StorybookConfig['webpackFinal'] = async (config) => { return { ...config, plugins: [ - ...config.plugins, + ...(config.plugins || []), reactDomPkg.version.startsWith('18') || reactDomPkg.version.startsWith('0.0.0') ? null : new IgnorePlugin({ diff --git a/presets/react-webpack/src/framework-preset-react.ts b/presets/react-webpack/src/framework-preset-react.ts index d644101af9a8..b49408eaf9a5 100644 --- a/presets/react-webpack/src/framework-preset-react.ts +++ b/presets/react-webpack/src/framework-preset-react.ts @@ -57,7 +57,9 @@ export const webpackFinal: StorybookConfig['webpackFinal'] = async (config, opti if (!(await useFastRefresh(options))) return config; // matches the name of the plugin in CRA. - const hasReactRefresh = config.plugins.find((p) => p.constructor.name === 'ReactRefreshPlugin'); + const hasReactRefresh = !!config.plugins?.find( + (p) => p.constructor.name === 'ReactRefreshPlugin' + ); if (hasReactRefresh) { logger.warn("=> React refresh is already set. You don't need to set the option"); @@ -69,7 +71,7 @@ export const webpackFinal: StorybookConfig['webpackFinal'] = async (config, opti return { ...config, plugins: [ - ...config.plugins, + ...(config.plugins || []), // Storybook uses webpack-hot-middleware https://github.com/storybookjs/storybook/issues/14114 new ReactRefreshWebpackPlugin({ diff --git a/presets/react-webpack/tsconfig.json b/presets/react-webpack/tsconfig.json index 16d169c4e222..793c36aa00d8 100644 --- a/presets/react-webpack/tsconfig.json +++ b/presets/react-webpack/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["node"], + "strict": true, "resolveJsonModule": true }, "include": [ diff --git a/presets/server-webpack/src/index.ts b/presets/server-webpack/src/index.ts index 230a4b5cd5fd..94cf6318259d 100644 --- a/presets/server-webpack/src/index.ts +++ b/presets/server-webpack/src/index.ts @@ -2,17 +2,25 @@ import path from 'path'; import type { StorybookConfig } from '@storybook/core-webpack'; export const webpack: StorybookConfig['webpack'] = (config) => { - config.module.rules.push({ - type: 'javascript/auto', - test: /\.stories\.json$/, - use: path.resolve(__dirname, './loader.js'), - }); + const rules = [ + ...(config.module?.rules || []), + { + type: 'javascript/auto', + test: /\.stories\.json$/, + use: path.resolve(__dirname, './loader.js'), + }, - config.module.rules.push({ - type: 'javascript/auto', - test: /\.stories\.ya?ml/, - use: [path.resolve(__dirname, './loader.js'), 'yaml-loader'], - }); + { + type: 'javascript/auto', + test: /\.stories\.ya?ml/, + use: [path.resolve(__dirname, './loader.js'), 'yaml-loader'], + }, + ]; + + // eslint-disable-next-line no-param-reassign + config.module = config.module || {}; + // eslint-disable-next-line no-param-reassign + config.module.rules = rules; return config; }; diff --git a/presets/server-webpack/src/lib/compiler/stringifier.ts b/presets/server-webpack/src/lib/compiler/stringifier.ts index 0dfec11b402a..48cbbd7e98e9 100644 --- a/presets/server-webpack/src/lib/compiler/stringifier.ts +++ b/presets/server-webpack/src/lib/compiler/stringifier.ts @@ -38,7 +38,7 @@ export function stringifyImports(imports: Record): string { .join(''); } -export function stringifyDecorators(decorators: string[]): string { +export function stringifyDecorators(decorators: string[] | undefined): string { return decorators && decorators.length > 0 ? `\n decorators: [\n ${decorators.join(',\n ')}\n ],` : ''; diff --git a/presets/server-webpack/tsconfig.json b/presets/server-webpack/tsconfig.json index 1ede6a814dd4..bdea127e87fa 100644 --- a/presets/server-webpack/tsconfig.json +++ b/presets/server-webpack/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["node"] + "strict": true }, "include": [ "src/**/*" diff --git a/presets/svelte-webpack/src/framework-preset-svelte-docs.ts b/presets/svelte-webpack/src/framework-preset-svelte-docs.ts index f582a611ec41..e1d3c2044665 100644 --- a/presets/svelte-webpack/src/framework-preset-svelte-docs.ts +++ b/presets/svelte-webpack/src/framework-preset-svelte-docs.ts @@ -4,12 +4,20 @@ import type { StorybookConfig } from '@storybook/core-webpack'; export const webpackFinal: StorybookConfig['webpackFinal'] = async (config, options) => { const svelteOptions = await options.presets.apply('svelteOptions', {} as any, options); - config.module.rules.push({ - test: /\.svelte$/, - loader: path.resolve(`${__dirname}/svelte-docgen-loader`), - enforce: 'post', - options: svelteOptions, - }); + const rules = [ + ...(config.module?.rules || []), + { + test: /\.svelte$/, + loader: path.resolve(`${__dirname}/svelte-docgen-loader`), + enforce: 'post', + options: svelteOptions, + }, + ]; + + // eslint-disable-next-line no-param-reassign + config.module = config.module || {}; + // eslint-disable-next-line no-param-reassign + config.module.rules = rules; return config; }; diff --git a/presets/svelte-webpack/src/framework-preset-svelte.ts b/presets/svelte-webpack/src/framework-preset-svelte.ts index eebb44c871e4..16a954e1445a 100644 --- a/presets/svelte-webpack/src/framework-preset-svelte.ts +++ b/presets/svelte-webpack/src/framework-preset-svelte.ts @@ -7,14 +7,14 @@ export const webpack: StorybookConfig['webpack'] = async (config, options) => { options ); - const mainFields = (config.resolve.mainFields as string[]) || ['browser', 'module', 'main']; + const mainFields = (config.resolve?.mainFields as string[]) || ['browser', 'module', 'main']; return { ...config, module: { ...config.module, rules: [ - ...config.module.rules, + ...(config.module?.rules || []), { test: /\.(svelte|html)$/, loader: require.resolve('svelte-loader'), @@ -24,8 +24,8 @@ export const webpack: StorybookConfig['webpack'] = async (config, options) => { }, resolve: { ...config.resolve, - extensions: [...config.resolve.extensions, '.svelte'], - alias: config.resolve.alias, + extensions: [...(config.resolve?.extensions || []), '.svelte'], + alias: config.resolve?.alias, mainFields: ['svelte', ...mainFields], }, }; diff --git a/presets/svelte-webpack/src/svelte-docgen-loader.ts b/presets/svelte-webpack/src/svelte-docgen-loader.ts index ddbaf1dcba45..ab738d7f1145 100644 --- a/presets/svelte-webpack/src/svelte-docgen-loader.ts +++ b/presets/svelte-webpack/src/svelte-docgen-loader.ts @@ -21,8 +21,13 @@ function getNameFromFilename(filename: string) { } } - const base = parts - .pop() + const value = parts.pop(); + + if (!value) { + throw new Error(`Could not derive component name from file ${filename}`); + } + + const base = value .replace(/%/g, 'u') .replace(/\.[^.]+$/, '') .replace(/[^a-zA-Z_$0-9]+/g, '_') @@ -41,7 +46,7 @@ function getNameFromFilename(filename: string) { * webpack loader for sveltedoc-parser * @param source raw svelte component */ -export default async function svelteDocgen(source: string) { +export default async function svelteDocgen(this: any, source: string) { // eslint-disable-next-line no-underscore-dangle const { resource } = this._module; // This is webpack5 only @@ -83,12 +88,11 @@ export default async function svelteDocgen(source: string) { const componentName = getNameFromFilename(resource); docgen = dedent` - - ${componentName}.__docgen = ${JSON.stringify(componentDoc)}; - `; + ${componentName}.__docgen = ${JSON.stringify(componentDoc)}; + `; } catch (error) { if (logDocgen) { - logger.error(error); + logger.error(error as any); } } // inject __docgen prop in svelte component diff --git a/presets/svelte-webpack/tsconfig.json b/presets/svelte-webpack/tsconfig.json index 68d3d8a53952..d41628347c9b 100644 --- a/presets/svelte-webpack/tsconfig.json +++ b/presets/svelte-webpack/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["node"], + "strict": true, "resolveJsonModule": true }, "include": [ diff --git a/presets/vue-webpack/tsconfig.json b/presets/vue-webpack/tsconfig.json index fecc79be2984..30b954047eee 100644 --- a/presets/vue-webpack/tsconfig.json +++ b/presets/vue-webpack/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["node"], "skipLibCheck": true, "resolveJsonModule": true }, diff --git a/presets/vue3-webpack/tsconfig.json b/presets/vue3-webpack/tsconfig.json index 4888676bb105..c8d0213c17d2 100644 --- a/presets/vue3-webpack/tsconfig.json +++ b/presets/vue3-webpack/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["node"], "resolveJsonModule": true, "skipLibCheck": true }, diff --git a/presets/web-components-webpack/src/index.ts b/presets/web-components-webpack/src/index.ts index de5c93ce41c5..aa6468b9c011 100644 --- a/presets/web-components-webpack/src/index.ts +++ b/presets/web-components-webpack/src/index.ts @@ -3,39 +3,47 @@ import type { StorybookConfig } from './types'; export * from './types'; export const webpack: StorybookConfig['webpack'] = (config) => { - config.module.rules.push({ - test: [ - new RegExp(`src(.*)\\.js$`), - new RegExp(`packages(\\/|\\\\)*(\\/|\\\\)src(\\/|\\\\)(.*)\\.js$`), - new RegExp(`node_modules(\\/|\\\\)lit-html(.*)\\.js$`), - new RegExp(`node_modules(\\/|\\\\)lit-element(.*)\\.js$`), - new RegExp(`node_modules(\\/|\\\\)@open-wc(.*)\\.js$`), - new RegExp(`node_modules(\\/|\\\\)@polymer(.*)\\.js$`), - new RegExp(`node_modules(\\/|\\\\)@vaadin(.*)\\.js$`), - ], - use: { - loader: require.resolve('babel-loader'), - options: { - compact: false, - presets: [ - [ - require.resolve('@babel/preset-env'), - { - useBuiltIns: 'entry', - corejs: 3, - targets: { chrome: '100', esmodules: true }, - }, + const rules = [ + ...(config.module?.rules || []), + { + test: [ + new RegExp(`src(.*)\\.js$`), + new RegExp(`packages(\\/|\\\\)*(\\/|\\\\)src(\\/|\\\\)(.*)\\.js$`), + new RegExp(`node_modules(\\/|\\\\)lit-html(.*)\\.js$`), + new RegExp(`node_modules(\\/|\\\\)lit-element(.*)\\.js$`), + new RegExp(`node_modules(\\/|\\\\)@open-wc(.*)\\.js$`), + new RegExp(`node_modules(\\/|\\\\)@polymer(.*)\\.js$`), + new RegExp(`node_modules(\\/|\\\\)@vaadin(.*)\\.js$`), + ], + use: { + loader: require.resolve('babel-loader'), + options: { + compact: false, + presets: [ + [ + require.resolve('@babel/preset-env'), + { + useBuiltIns: 'entry', + corejs: 3, + targets: { chrome: '100', esmodules: true }, + }, + ], ], - ], - plugins: [ - require.resolve('@babel/plugin-syntax-dynamic-import'), - require.resolve('@babel/plugin-syntax-import-meta'), - // webpack does not support import.meta.url yet, so we rewrite them in babel - [require.resolve('babel-plugin-bundled-import-meta'), { importStyle: 'baseURI' }], - ], + plugins: [ + require.resolve('@babel/plugin-syntax-dynamic-import'), + require.resolve('@babel/plugin-syntax-import-meta'), + // webpack does not support import.meta.url yet, so we rewrite them in babel + [require.resolve('babel-plugin-bundled-import-meta'), { importStyle: 'baseURI' }], + ], + }, }, }, - }); + ]; + + // eslint-disable-next-line no-param-reassign + config.module = config.module || {}; + // eslint-disable-next-line no-param-reassign + config.module.rules = rules; return config; }; diff --git a/presets/web-components-webpack/tsconfig.json b/presets/web-components-webpack/tsconfig.json index 6de485f52855..83939a26978e 100644 --- a/presets/web-components-webpack/tsconfig.json +++ b/presets/web-components-webpack/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["node"] + "strict": true }, "include": [ "src/**/*" diff --git a/renderers/html/src/docs/sourceDecorator.ts b/renderers/html/src/docs/sourceDecorator.ts index 86ac210c86b4..7862c9cf48e1 100644 --- a/renderers/html/src/docs/sourceDecorator.ts +++ b/renderers/html/src/docs/sourceDecorator.ts @@ -40,7 +40,7 @@ export function sourceDecorator( ? (context.originalStoryFn as ArgsStoryFn)(context.args, context) : storyFn(); - let source: string; + let source: string | undefined; if (!skipSourceRender(context)) { if (typeof story === 'string') { source = story; @@ -48,7 +48,9 @@ export function sourceDecorator( source = story.outerHTML; } - if (source) source = applyTransformSource(source, context); + if (source) { + source = applyTransformSource(source, context); + } } useEffect(() => { if (source) addons.getChannel().emit(SNIPPET_RENDERED, context.id, source); diff --git a/renderers/html/src/preview/render.ts b/renderers/html/src/preview/render.ts index f9a29aab5ebe..b7992976c7a8 100644 --- a/renderers/html/src/preview/render.ts +++ b/renderers/html/src/preview/render.ts @@ -2,14 +2,14 @@ import global from 'global'; import dedent from 'ts-dedent'; import { simulatePageLoad, simulateDOMContentLoaded } from '@storybook/preview-web'; -import { RenderContext } from '@storybook/store'; +import type { RenderContext } from '@storybook/store'; import { HtmlFramework } from './types-6-0'; const { Node } = global; export function renderToDOM( { storyFn, kind, name, showMain, showError, forceRemount }: RenderContext, - domElement: HTMLElement + domElement: Element ) { const element = storyFn(); showMain(); diff --git a/renderers/html/tsconfig.json b/renderers/html/tsconfig.json index 0915ebab6aa4..83939a26978e 100644 --- a/renderers/html/tsconfig.json +++ b/renderers/html/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": [] + "strict": true }, "include": [ "src/**/*" diff --git a/renderers/preact/src/preview/render.tsx b/renderers/preact/src/preview/render.tsx index d78cfe699c8b..22346aba38cb 100644 --- a/renderers/preact/src/preview/render.tsx +++ b/renderers/preact/src/preview/render.tsx @@ -6,7 +6,8 @@ import { PreactFramework } from './types-6-0'; let renderedStory: Element; -function preactRender(story: StoryFnPreactReturnType, domElement: HTMLElement): void { +function preactRender(story: StoryFnPreactReturnType | null, domElement: Element): void { + // @ts-ignore if (preact.Fragment) { // Preact 10 only: preact.render(story, domElement); @@ -20,7 +21,7 @@ const StoryHarness: preact.FunctionalComponent<{ title: string; showError: RenderContext['showError']; storyFn: () => any; - domElement: HTMLElement; + domElement: Element; }> = ({ showError, name, title, storyFn, domElement }) => { const content = preact.h(storyFn as any, null); if (!content) { @@ -38,7 +39,7 @@ const StoryHarness: preact.FunctionalComponent<{ export function renderToDOM( { storyFn, title, name, showMain, showError, forceRemount }: RenderContext, - domElement: HTMLElement + domElement: Element ) { if (forceRemount) { preactRender(null, domElement); diff --git a/renderers/preact/tsconfig.json b/renderers/preact/tsconfig.json index 98c14407bb41..d41628347c9b 100644 --- a/renderers/preact/tsconfig.json +++ b/renderers/preact/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "strict": true, "resolveJsonModule": true }, "include": [ diff --git a/renderers/react/src/docs/extractArgTypes.ts b/renderers/react/src/docs/extractArgTypes.ts index 333052be43e1..322cc85ae3a3 100644 --- a/renderers/react/src/docs/extractArgTypes.ts +++ b/renderers/react/src/docs/extractArgTypes.ts @@ -4,7 +4,11 @@ import { extractProps } from './extractProps'; export const extractArgTypes: ArgTypesExtractor = (component) => { if (component) { - const { rows } = extractProps(component); + const extracted = extractProps(component); + if (!extracted) { + return null; + } + const { rows } = extracted; if (rows) { return rows.reduce((acc: StrictArgTypes, row: PropDef) => { const { diff --git a/renderers/react/src/docs/jsxDecorator.tsx b/renderers/react/src/docs/jsxDecorator.tsx index 0e42878e2af5..fb667a359d36 100644 --- a/renderers/react/src/docs/jsxDecorator.tsx +++ b/renderers/react/src/docs/jsxDecorator.tsx @@ -69,6 +69,7 @@ export const renderJsx = (code: React.ReactElement, options: JSXOptions) => { let renderedJSX = code; const Type = renderedJSX.type; + // @ts-ignore for (let i = 0; i < options.skip; i += 1) { if (typeof renderedJSX === 'undefined') { logger.warn('Cannot skip undefined element'); diff --git a/renderers/react/src/docs/lib/defaultValues/createDefaultValue.ts b/renderers/react/src/docs/lib/defaultValues/createDefaultValue.ts index c2fb441d32c1..f74ef59c597c 100644 --- a/renderers/react/src/docs/lib/defaultValues/createDefaultValue.ts +++ b/renderers/react/src/docs/lib/defaultValues/createDefaultValue.ts @@ -60,7 +60,7 @@ function generateElement( : createSummaryValue(ELEMENT_CAPTION, defaultValue); } -export function createDefaultValue(defaultValue: string): PropDefaultValue { +export function createDefaultValue(defaultValue: string): PropDefaultValue | null { try { const inspectionResult = inspectValue(defaultValue); diff --git a/renderers/react/src/docs/lib/defaultValues/createFromRawDefaultProp.ts b/renderers/react/src/docs/lib/defaultValues/createFromRawDefaultProp.ts index f679c7b111a0..541df4b42cf6 100644 --- a/renderers/react/src/docs/lib/defaultValues/createFromRawDefaultProp.ts +++ b/renderers/react/src/docs/lib/defaultValues/createFromRawDefaultProp.ts @@ -31,7 +31,7 @@ function isReactElement(element: any): boolean { return element.$$typeof != null; } -export function extractFunctionName(func: Function, propName: string): string { +export function extractFunctionName(func: Function, propName: string): string | null { const { name } = func; // Comparison with the prop name is to discard inferred function names. @@ -138,6 +138,7 @@ const functionResolver: TypeResolver = (rawDefaultProp, propDef) => { inspectionResult = inspectValue(rawDefaultProp.toString()); } + // @ts-ignore const { hasParams } = inspectionResult.inferredType as InspectionFunction; return createSummaryValue(getPrettyFuncIdentifier(funcName, hasParams)); @@ -173,7 +174,7 @@ export function createDefaultValueFromRawDefaultProp( rawDefaultProp: any, propDef: PropDef, typeResolvers: TypeResolvers = DEFAULT_TYPE_RESOLVERS -): PropDefaultValue { +): PropDefaultValue | null { try { // Keep the extra () otherwise it will fail for functions. switch (typeof rawDefaultProp) { diff --git a/renderers/react/src/docs/lib/defaultValues/prettyIdentifier.ts b/renderers/react/src/docs/lib/defaultValues/prettyIdentifier.ts index 452a1c23ba01..58299e1f26df 100644 --- a/renderers/react/src/docs/lib/defaultValues/prettyIdentifier.ts +++ b/renderers/react/src/docs/lib/defaultValues/prettyIdentifier.ts @@ -17,8 +17,10 @@ export function getPrettyIdentifier(inferredType: InspectionIdentifiableInferedT switch (type) { case InspectionType.FUNCTION: + // @ts-ignore return getPrettyFuncIdentifier(identifier, (inferredType as InspectionFunction).hasParams); case InspectionType.ELEMENT: + // @ts-ignore return getPrettyElementIdentifier(identifier); default: return identifier; diff --git a/renderers/react/src/docs/lib/inspection/acornParser.ts b/renderers/react/src/docs/lib/inspection/acornParser.ts index 78290b9e616e..d309974a91b5 100644 --- a/renderers/react/src/docs/lib/inspection/acornParser.ts +++ b/renderers/react/src/docs/lib/inspection/acornParser.ts @@ -154,7 +154,7 @@ function parseJsxElement(jsxElementNode: any): ParsingResult }; } -function parseCall(callNode: estree.CallExpression): ParsingResult { +function parseCall(callNode: estree.CallExpression): ParsingResult | null { const identifierNode = callNode.callee.type === 'MemberExpression' ? callNode.callee.property : callNode.callee; @@ -181,7 +181,7 @@ function parseArray(arrayNode: estree.ArrayExpression): ParsingResult { +function parseExpression(expression: any): ParsingResult | null { switch (expression.type) { case 'Identifier': return parseIdentifier(expression); diff --git a/renderers/react/src/docs/propTypes/createType.ts b/renderers/react/src/docs/propTypes/createType.ts index cc3286dce0cc..058070e32c32 100644 --- a/renderers/react/src/docs/propTypes/createType.ts +++ b/renderers/react/src/docs/propTypes/createType.ts @@ -50,9 +50,9 @@ interface EnumValue { interface TypeDef { name: string; short: string; - compact: string; - full: string; - inferredType?: InspectionType; + compact: string | null; + full: string | null; + inferredType?: InspectionType | null; } function createTypeDef({ @@ -64,9 +64,9 @@ function createTypeDef({ }: { name: string; short: string; - compact: string; - full?: string; - inferredType?: InspectionType; + compact: string | null; + full?: string | null; + inferredType?: InspectionType | null; }): TypeDef { return { name, @@ -183,8 +183,10 @@ function generateFunc(extractedProp: ExtractedProp): TypeDef { if (jsDocTags.params != null || jsDocTags.returns != null) { return createTypeDef({ name: PropTypesType.FUNC, + // @ts-ignore short: generateShortFuncSignature(jsDocTags.params, jsDocTags.returns), compact: null, + // @ts-ignore full: generateFuncSignature(jsDocTags.params, jsDocTags.returns), }); } @@ -224,7 +226,7 @@ function generateObjectOf(type: DocgenPropType, extractedProp: ExtractedProp): T name: PropTypesType.OBJECTOF, short: objectOf(short), compact: compact != null ? objectOf(compact) : null, - full: objectOf(full), + full: full ? objectOf(full) : full, }); } @@ -294,12 +296,16 @@ function braceAround(of: string): string { return `[${of}]`; } -function createArrayOfObjectTypeDef(short: string, compact: string, full: string): TypeDef { +function createArrayOfObjectTypeDef( + short: string, + compact: string | null, + full: string | null +): TypeDef { return createTypeDef({ name: PropTypesType.ARRAYOF, short: braceAfter(short), compact: compact != null ? braceAround(compact) : null, - full: braceAround(full), + full: full ? braceAround(full) : full, }); } @@ -355,7 +361,7 @@ function generateType(type: DocgenPropType, extractedProp: ExtractedProp): TypeD return createTypeDef({ name: 'unknown', short: 'unknown', compact: 'unknown' }); } -export function createType(extractedProp: ExtractedProp): PropType { +export function createType(extractedProp: ExtractedProp): PropType | null { const { type } = extractedProp.docgenInfo; // A type could be null if a defaultProp has been provided without a type definition. @@ -380,7 +386,7 @@ export function createType(extractedProp: ExtractedProp): PropType { } } - return createSummaryValue(short, full); + return full ? createSummaryValue(short, full) : createSummaryValue(short); } case PropTypesType.FUNC: { const { short, full } = generateType(type, extractedProp); @@ -388,9 +394,9 @@ export function createType(extractedProp: ExtractedProp): PropType { let summary = short; let detail; - if (full.length < MAX_FUNC_LENGTH) { + if (full && full.length < MAX_FUNC_LENGTH) { summary = full; - } else { + } else if (full) { detail = toMultilineSignature(full); } diff --git a/renderers/react/src/docs/propTypes/sortProps.ts b/renderers/react/src/docs/propTypes/sortProps.ts index 4d5dbb19e143..311f478e35d5 100644 --- a/renderers/react/src/docs/propTypes/sortProps.ts +++ b/renderers/react/src/docs/propTypes/sortProps.ts @@ -14,7 +14,7 @@ export function keepOriginalDefinitionOrder( if (propTypes != null) { return Object.keys(propTypes) .map((x) => extractedProps.find((y) => y.name === x)) - .filter((x) => x); + .filter(Boolean) as PropDef[]; } return extractedProps; diff --git a/renderers/react/src/preview/render.tsx b/renderers/react/src/preview/render.tsx index 94db184a3b6b..fc921693d6d1 100644 --- a/renderers/react/src/preview/render.tsx +++ b/renderers/react/src/preview/render.tsx @@ -124,7 +124,7 @@ export async function renderToDOM( showException, forceRemount, }: RenderContext, - domElement: HTMLElement + domElement: Element ) { const Story = unboundStoryFn as FunctionComponent>; diff --git a/renderers/react/src/testing/index.ts b/renderers/react/src/testing/index.ts index 8099a10b9ff8..2575028335ee 100644 --- a/renderers/react/src/testing/index.ts +++ b/renderers/react/src/testing/index.ts @@ -120,6 +120,7 @@ export function composeStories>( csfExports: TModule, projectAnnotations?: ProjectAnnotations ) { + // @ts-ignore const composedStories = originalComposeStories(csfExports, projectAnnotations, composeStory); return composedStories as unknown as Omit< diff --git a/renderers/react/tsconfig.json b/renderers/react/tsconfig.json index 559ad26864b3..793c36aa00d8 100644 --- a/renderers/react/tsconfig.json +++ b/renderers/react/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "strict": true, "resolveJsonModule": true }, "include": [ diff --git a/renderers/server/src/preview/render.ts b/renderers/server/src/preview/render.ts index 6fc63d49da04..d5824007d10e 100644 --- a/renderers/server/src/preview/render.ts +++ b/renderers/server/src/preview/render.ts @@ -54,7 +54,7 @@ export async function renderToDOM( storyContext, storyContext: { parameters, args, argTypes }, }: RenderContext, - domElement: HTMLElement + domElement: Element ) { // Some addons wrap the storyFn so we need to call it even though Server doesn't need the answer storyFn(); diff --git a/renderers/svelte/src/docs/extractArgTypes.ts b/renderers/svelte/src/docs/extractArgTypes.ts index 91e28729c1af..2ca259c6f8d9 100644 --- a/renderers/svelte/src/docs/extractArgTypes.ts +++ b/renderers/svelte/src/docs/extractArgTypes.ts @@ -32,50 +32,56 @@ export const extractArgTypes: ArgTypesExtractor = (component: ComponentWithDocge export const createArgTypes = (docgen: SvelteComponentDoc) => { const results: StrictArgTypes = {}; - docgen.data.forEach((item) => { - results[item.name] = { - control: parseTypeToControl(item.type), - name: item.name, - description: item.description, - type: { - required: hasKeyword('required', item.keywords), - name: item.type?.text as SBScalarType['name'], - }, - table: { + if (docgen.data) { + docgen.data.forEach((item) => { + results[item.name] = { + control: parseTypeToControl(item.type), + name: item.name, + description: item.description || undefined, type: { - summary: item.type?.text, + required: hasKeyword('required', item.keywords || []), + name: item.type?.text as SBScalarType['name'], }, - defaultValue: { - summary: item.defaultValue, + table: { + type: { + summary: item.type?.text, + }, + defaultValue: { + summary: item.defaultValue, + }, + category: 'properties', }, - category: 'properties', - }, - }; - }); + }; + }); + } - docgen.events.forEach((item) => { - results[`event_${item.name}`] = { - name: item.name, - description: item.description, - type: { name: 'other', value: 'void' }, - table: { - category: 'events', - }, - }; - }); + if (docgen.events) { + docgen.events.forEach((item) => { + results[`event_${item.name}`] = { + name: item.name, + description: item.description || undefined, + type: { name: 'other', value: 'void' }, + table: { + category: 'events', + }, + }; + }); + } - docgen.slots.forEach((item) => { - results[`slot_${item.name}`] = { - name: item.name, - description: [item.description, item.params?.map((p) => `\`${p.name}\``).join(' ')] - .filter((p) => p) - .join('\n\n'), - type: { name: 'other', value: 'void' }, - table: { - category: 'slots', - }, - }; - }); + if (docgen.slots) { + docgen.slots.forEach((item) => { + results[`slot_${item.name}`] = { + name: item.name, + description: [item.description, item.params?.map((p) => `\`${p.name}\``).join(' ')] + .filter((p) => p) + .join('\n\n'), + type: { name: 'other', value: 'void' }, + table: { + category: 'slots', + }, + }; + }); + } return results; }; @@ -85,7 +91,7 @@ export const createArgTypes = (docgen: SvelteComponentDoc) => { * @param typeName * @returns string */ -const parseTypeToControl = (type: JSDocType): any => { +const parseTypeToControl = (type: JSDocType | undefined): any => { if (!type) { return null; } @@ -107,7 +113,9 @@ const parseTypeToControl = (type: JSDocType): any => { if (Array.isArray(type.type) && !type.type.find((t) => t.type !== 'string')) { return { type: 'radio', - options: type.type.filter((t) => t.kind === 'const').map((t: JSDocTypeConst) => t.value), + options: type.type + .filter((t) => t.kind === 'const') + .map((t) => (t as JSDocTypeConst).value), }; } } diff --git a/renderers/svelte/src/docs/extractComponentDescription.ts b/renderers/svelte/src/docs/extractComponentDescription.ts index d2213c8ee4a1..2bf6ca7ce734 100644 --- a/renderers/svelte/src/docs/extractComponentDescription.ts +++ b/renderers/svelte/src/docs/extractComponentDescription.ts @@ -2,7 +2,7 @@ type Component = any; export function extractComponentDescription(component?: Component): string { if (!component) { - return null; + return ''; } const { __docgen = {} } = component; diff --git a/renderers/svelte/src/docs/sourceDecorator.ts b/renderers/svelte/src/docs/sourceDecorator.ts index 68c131418977..d7b04f91c9df 100644 --- a/renderers/svelte/src/docs/sourceDecorator.ts +++ b/renderers/svelte/src/docs/sourceDecorator.ts @@ -33,7 +33,7 @@ const skipSourceRender = (context: StoryContext) => { * @param value Value * @param argTypes Component ArgTypes */ -function toSvelteProperty(key: string, value: any, argTypes: ArgTypes): string { +function toSvelteProperty(key: string, value: any, argTypes: ArgTypes): string | null { if (value === undefined || value === null) { return null; } @@ -59,7 +59,7 @@ function toSvelteProperty(key: string, value: any, argTypes: ArgTypes): string { * * @param component Component */ -function getComponentName(component: any): string { +function getComponentName(component: any): string | null { if (component == null) { return null; } @@ -89,8 +89,8 @@ export function generateSvelteSource( component: any, args: Args, argTypes: ArgTypes, - slotProperty: string -): string { + slotProperty?: string +): string | null { const name = getComponentName(component); if (!name) { @@ -174,7 +174,10 @@ export const sourceDecorator = (storyFn: any, context: StoryContext, - domElement: HTMLElement + domElement: Element ) { cleanUpPreviousStory(); diff --git a/renderers/svelte/tsconfig.json b/renderers/svelte/tsconfig.json index 68d3d8a53952..d41628347c9b 100644 --- a/renderers/svelte/tsconfig.json +++ b/renderers/svelte/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "types": ["node"], + "strict": true, "resolveJsonModule": true }, "include": [ diff --git a/renderers/vue/src/preview/render.ts b/renderers/vue/src/preview/render.ts index 83b62c809740..715073e7c65a 100644 --- a/renderers/vue/src/preview/render.ts +++ b/renderers/vue/src/preview/render.ts @@ -9,7 +9,7 @@ import type { VueFramework } from './types-6-0'; export const COMPONENT = 'STORYBOOK_COMPONENT'; export const VALUES = 'STORYBOOK_VALUES'; -const map = new Map(); +const map = new Map(); type Instance = CombinedVueInstance< Vue, { @@ -20,7 +20,7 @@ type Instance = CombinedVueInstance< object, Record >; -const getRoot = (domElement: HTMLElement): Instance => { +const getRoot = (domElement: Element): Instance => { if (map.has(domElement)) { return map.get(domElement); } @@ -90,7 +90,7 @@ export function renderToDOM( showException, forceRemount, }: RenderContext, - domElement: HTMLElement + domElement: Element ) { const root = getRoot(domElement); Vue.config.errorHandler = showException; diff --git a/renderers/vue3/src/preview/render.ts b/renderers/vue3/src/preview/render.ts index cc18d8407761..de0c849feea4 100644 --- a/renderers/vue3/src/preview/render.ts +++ b/renderers/vue3/src/preview/render.ts @@ -23,11 +23,11 @@ export const setup = (fn: (app: any) => void) => { setupFunction = fn; }; -const map = new Map>(); +const map = new Map>(); export function renderToDOM( { title, name, storyFn, showMain, showError, showException }: RenderContext, - domElement: HTMLElement + domElement: Element ) { // TODO: explain cyclical nature of these app => story => mount let element: StoryFnVueReturnType; diff --git a/renderers/web-components/src/preview/render.ts b/renderers/web-components/src/preview/render.ts index a99180f2b869..37627f5fb721 100644 --- a/renderers/web-components/src/preview/render.ts +++ b/renderers/web-components/src/preview/render.ts @@ -13,7 +13,7 @@ const { Node } = global; export function renderToDOM( { storyFn, kind, name, showMain, showError, forceRemount }: RenderContext, - domElement: HTMLElement + domElement: Element ) { const element = storyFn(); @@ -27,7 +27,7 @@ export function renderToDOM( } const renderTo = domElement.querySelector('[id="root-inner"]'); - render(element, renderTo as HTMLElement); + render(element, renderTo); simulatePageLoad(domElement); } else if (typeof element === 'string') { domElement.innerHTML = element; diff --git a/tsconfig.json b/tsconfig.json index 965c65d3bde1..f3b6eb306c7d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,7 @@ "baseUrl": ".", "incremental": false, "noImplicitAny": true, + "forceConsistentCasingInFileNames": true, "experimentalDecorators": true, "emitDecoratorMetadata": true, "jsx": "react", From 56e6812b9ccb38858508724d6fa512f5bfd8047d Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 16 Jun 2022 20:59:32 +0200 Subject: [PATCH 05/12] uhm... this worked locally.. why does it fail on CI? --- renderers/web-components/src/preview/render.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/renderers/web-components/src/preview/render.ts b/renderers/web-components/src/preview/render.ts index 37627f5fb721..7e151360c904 100644 --- a/renderers/web-components/src/preview/render.ts +++ b/renderers/web-components/src/preview/render.ts @@ -27,6 +27,7 @@ export function renderToDOM( } const renderTo = domElement.querySelector('[id="root-inner"]'); + // ! render(element, renderTo); simulatePageLoad(domElement); } else if (typeof element === 'string') { From 2e7abe59b080943c98ccebe6c87d7aa583da97e5 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 16 Jun 2022 21:03:56 +0200 Subject: [PATCH 06/12] fix --- renderers/web-components/src/preview/render.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/renderers/web-components/src/preview/render.ts b/renderers/web-components/src/preview/render.ts index 7e151360c904..b6fda6520950 100644 --- a/renderers/web-components/src/preview/render.ts +++ b/renderers/web-components/src/preview/render.ts @@ -25,9 +25,8 @@ export function renderToDOM( if (forceRemount || !domElement.querySelector('[id="root-inner"]')) { domElement.innerHTML = '
'; } - const renderTo = domElement.querySelector('[id="root-inner"]'); + const renderTo = domElement.querySelector('[id="root-inner"]'); - // ! render(element, renderTo); simulatePageLoad(domElement); } else if (typeof element === 'string') { From 562c48ade3c4f0431421b88574d8b228f025be95 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 17 Jun 2022 09:23:49 +0200 Subject: [PATCH 07/12] fix tests --- addons/links/src/utils.ts | 6 +++++- lib/telemetry/src/telemetry.ts | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/addons/links/src/utils.ts b/addons/links/src/utils.ts index 328e8442e2a8..8b4adef0bf38 100644 --- a/addons/links/src/utils.ts +++ b/addons/links/src/utils.ts @@ -61,8 +61,12 @@ export const linkTo = if (title?.match(/--/) && !name) { navigate({ storyId: title }); - } else if (name) { + } else if (name && title) { navigate({ kind: title, story: name }); + } else if (title) { + navigate({ kind: title }); + } else if (name) { + navigate({ story: name }); } }; diff --git a/lib/telemetry/src/telemetry.ts b/lib/telemetry/src/telemetry.ts index 47225436ec2b..2ecab470b4dd 100644 --- a/lib/telemetry/src/telemetry.ts +++ b/lib/telemetry/src/telemetry.ts @@ -40,7 +40,11 @@ export async function sendTelemetry( headers: { 'Content-Type': 'application/json' }, retries: 3, retryOn: [503, 504], - retryDelay: (attempt: number) => 2 ** attempt * (options.retryDelay || 1000), + retryDelay: (attempt: number) => + 2 ** attempt * + (typeof options?.retryDelay === 'number' && !Number.isNaN(options?.retryDelay) + ? options.retryDelay + : 1000), }); tasks.push(request); From c94b6f9f2573e0adba69a977bfe4099af3cac90b Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 17 Jun 2022 09:45:39 +0200 Subject: [PATCH 08/12] cleanup --- lib/ui/src/components/layout/container.tsx | 9 +-------- renderers/react/src/docs/extractArgTypes.ts | 6 +----- renderers/react/src/docs/extractProps.ts | 2 +- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/ui/src/components/layout/container.tsx b/lib/ui/src/components/layout/container.tsx index c9e103640159..e8442cee2ec3 100644 --- a/lib/ui/src/components/layout/container.tsx +++ b/lib/ui/src/components/layout/container.tsx @@ -1,11 +1,4 @@ -import React, { - Component, - Fragment, - FunctionComponent, - CSSProperties, - ReactNode, - GetDerivedStateFromProps, -} from 'react'; +import React, { Component, Fragment, FunctionComponent, CSSProperties, ReactNode } from 'react'; import { styled, withTheme } from '@storybook/theming'; import type { Theme } from '@storybook/theming'; import type { State } from '@storybook/api'; diff --git a/renderers/react/src/docs/extractArgTypes.ts b/renderers/react/src/docs/extractArgTypes.ts index 322cc85ae3a3..333052be43e1 100644 --- a/renderers/react/src/docs/extractArgTypes.ts +++ b/renderers/react/src/docs/extractArgTypes.ts @@ -4,11 +4,7 @@ import { extractProps } from './extractProps'; export const extractArgTypes: ArgTypesExtractor = (component) => { if (component) { - const extracted = extractProps(component); - if (!extracted) { - return null; - } - const { rows } = extracted; + const { rows } = extractProps(component); if (rows) { return rows.reduce((acc: StrictArgTypes, row: PropDef) => { const { diff --git a/renderers/react/src/docs/extractProps.ts b/renderers/react/src/docs/extractProps.ts index e763fd9e374f..fce5276f827e 100644 --- a/renderers/react/src/docs/extractProps.ts +++ b/renderers/react/src/docs/extractProps.ts @@ -50,6 +50,6 @@ function getPropDefs(component: Component, section: string): PropDef[] { } } -export const extractProps: PropsExtractor = (component) => ({ +export const extractProps = (component: Component) => ({ rows: getPropDefs(component, 'props'), }); From 8d8673f8157c7099cab3099c59a99731059f2d3f Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 17 Jun 2022 09:48:35 +0200 Subject: [PATCH 09/12] cleanup --- renderers/react/src/docs/extractProps.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/renderers/react/src/docs/extractProps.ts b/renderers/react/src/docs/extractProps.ts index fce5276f827e..c7d7a77e4a48 100644 --- a/renderers/react/src/docs/extractProps.ts +++ b/renderers/react/src/docs/extractProps.ts @@ -1,11 +1,5 @@ import PropTypes from 'prop-types'; -import { - PropDef, - hasDocgen, - extractComponentProps, - PropsExtractor, - TypeSystem, -} from '@storybook/docs-tools'; +import { PropDef, hasDocgen, extractComponentProps, TypeSystem } from '@storybook/docs-tools'; import { enhancePropTypesProps } from './propTypes/handleProp'; import { enhanceTypeScriptProps } from './typeScript/handleProp'; import { isMemo } from './lib'; From 6d3ce9506857330528ad7fe7d28a97b102314246 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 17 Jun 2022 10:01:29 +0200 Subject: [PATCH 10/12] add logFilters to yarn config, so it's not giving us warnings we don't care about --- .yarnrc.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.yarnrc.yml b/.yarnrc.yml index e9991e9f238f..485cfd3f6ab0 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -16,3 +16,15 @@ unsafeHttpWhitelist: - localhost yarnPath: .yarn/releases/yarn-3.1.1.cjs + +logFilters: + - code: "YN0005" + level: "discard" + - code: "YN0076" + level: "discard" + - pattern: "@workspace:examples" + level: "discard" + - pattern: "@storybook/root@workspace:." + level: "discard" + - pattern: "@workspace:addons/storyshots/" + level: "discard" \ No newline at end of file From b3df691dfab20b19d3dac893f891af459155837e Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 17 Jun 2022 10:02:44 +0200 Subject: [PATCH 11/12] add documentation link --- .yarnrc.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.yarnrc.yml b/.yarnrc.yml index 485cfd3f6ab0..55db1a13aeca 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -1,3 +1,5 @@ +# documentation: https://yarnpkg.com/configuration/yarnrc + compressionLevel: 0 enableGlobalCache: true From 2dbe6a8627e900c787835e3396fc6a63c20ab5f9 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Sat, 18 Jun 2022 20:54:45 +1000 Subject: [PATCH 12/12] Keep story `viewMode` when rendering docs entries. --- lib/api/src/modules/stories.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/api/src/modules/stories.ts b/lib/api/src/modules/stories.ts index 8df6f74ce0aa..78eb1a00f8db 100644 --- a/lib/api/src/modules/stories.ts +++ b/lib/api/src/modules/stories.ts @@ -275,10 +275,16 @@ export const init: ModuleFn = ({ if (desiredViewMode === 'docs') { viewMode = 'docs'; } + + // NOTE -- we currently still render docs entries in story view mode, + // (even though in the preview they will appear in docs mode) + // in order to maintain the viewMode as you browse around. + // This will change later. + // On the other hand, docs entries can *only* be rendered as docs - if (leafEntry.type === 'docs') { - viewMode = 'docs'; - } + // if (leafEntry.type === 'docs') { + // viewMode = 'docs'; + // } const fullId = leafEntry.refId ? `${leafEntry.refId}_${leafEntry.id}` : leafEntry.id; navigate(`/${viewMode}/${fullId}`);