Skip to content

Commit

Permalink
Merge pull request #16915 from storybookjs/16845-fix-hierarchy-separa…
Browse files Browse the repository at this point in the history
…tor-warning

Core: Add feature flag to disable legacy hierarchy separator warning
  • Loading branch information
shilman committed Dec 6, 2021
1 parent e7ab709 commit 0028a2b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/react-ts/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const config: StorybookConfig = {
storyStoreV7: !global.navigator?.userAgent?.match?.('jsdom'),
buildStoriesJson: true,
babelModeV7: true,
warnOnLegacyHierarchySeparator: false,
},
framework: '@storybook/react',
};
Expand Down
5 changes: 4 additions & 1 deletion lib/api/src/lib/stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import deprecate from 'util-deprecate';
import dedent from 'ts-dedent';
import mapValues from 'lodash/mapValues';
import countBy from 'lodash/countBy';
import global from 'global';
import {
StoryId,
ComponentTitle,
Expand All @@ -19,6 +20,8 @@ import merge from './merge';
import { Provider } from '../modules/provider';
import { ViewMode } from '../modules/addons';

const { FEATURES } = global;

export type { StoryId };

export interface Root {
Expand Down Expand Up @@ -207,7 +210,7 @@ export const transformStoriesRawToStoriesHash = (
}

const setShowRoots = typeof showRoots !== 'undefined';
if (usesOldHierarchySeparator && !setShowRoots) {
if (usesOldHierarchySeparator && !setShowRoots && FEATURES?.warnOnLegacyHierarchySeparator) {
warnChangedDefaultHierarchySeparators();
}

Expand Down
6 changes: 6 additions & 0 deletions lib/core-common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,12 @@ export interface StorybookConfig {
* Filter args with a "target" on the type from the render function (EXPERIMENTAL)
*/
argTypeTargetsV7?: boolean;

/**
* Warn when there is a pre-6.0 hierarchy separator ('.' / '|') in the story title.
* Will be removed in 7.0.
*/
warnOnLegacyHierarchySeparator?: boolean;
};

/**
Expand Down
1 change: 1 addition & 0 deletions lib/core-server/src/presets/common-preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ export const features = async (existing: Record<string, boolean>) => ({
...existing,
postcss: true,
emotionAlias: true,
warnOnLegacyHierarchySeparator: true,
});

0 comments on commit 0028a2b

Please sign in to comment.