diff --git a/MIGRATION.md b/MIGRATION.md index db08a2f20009..fea68ecac821 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -39,6 +39,7 @@ - [Deprecated polymer](#deprecated-polymer) - [Deprecated immutable options parameters](#deprecated-immutable-options-parameters) - [Deprecated addParameters and addDecorator](#deprecated-addparameters-and-adddecorator) + - [Deprecated clearDecorators](#deprecated-cleardecorators) - [Deprecated configure](#deprecated-configure) - [From version 5.2.x to 5.3.x](#from-version-52x-to-53x) - [To main.js configuration](#to-mainjs-configuration) @@ -651,6 +652,10 @@ The `addParameters` and `addDecorator` APIs to add global decorators and paramet Instead, use `export const parameters = {};` and `export const decorators = [];` in your `.storybook/preview.js`. Addon authors similarly should use such an export in a `previewEntry` file. +#### Deprecated clearDecorators + +Similarly, `clearDecorators`, exported by the various frameworks (e.g. `@storybook/react`) is deprecated. + #### Deprecated configure The `configure` API to load stories from `preview.js`, exported by the various frameworks (e.g. `@storybook/react`) is now deprecated. diff --git a/lib/client-api/src/client_api.ts b/lib/client-api/src/client_api.ts index 6791d89b39a7..9f3a33e109fa 100644 --- a/lib/client-api/src/client_api.ts +++ b/lib/client-api/src/client_api.ts @@ -92,7 +92,7 @@ export default class ClientApi { }; }, dedent` - setAddon is deprecated and will be removed in Storybook 7.0 + \`setAddon\` is deprecated and will be removed in Storybook 7.0. https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-setaddon ` @@ -102,6 +102,17 @@ export default class ClientApi { this._storyStore.addGlobalMetadata({ decorators: [decorator], parameters: {} }); }; + clearDecorators = deprecate( + () => { + this._storyStore.clearGlobalDecorators(); + }, + dedent` + \`clearDecorators\` is deprecated and will be removed in Storybook 7.0. + + https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-cleardecorators + ` + ); + addParameters = (parameters: Parameters) => { this._storyStore.addGlobalMetadata({ decorators: [], parameters }); }; diff --git a/lib/client-api/src/story_store.ts b/lib/client-api/src/story_store.ts index cf679ccfd7de..4c8d01153373 100644 --- a/lib/client-api/src/story_store.ts +++ b/lib/client-api/src/story_store.ts @@ -246,6 +246,10 @@ export default class StoryStore { this._globalMetadata.decorators.push(...decorators); } + clearGlobalDecorators() { + this._globalMetadata.decorators = []; + } + ensureKind(kind: string) { if (!this._kinds[kind]) { this._kinds[kind] = {