mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 11:11:53 +08:00
Warn when storyName usage is detected in CSF3 stories
This commit is contained in:
parent
b2f4390c05
commit
084043e46f
@ -613,5 +613,24 @@ describe('CsfFile', () => {
|
||||
__id: foo-bar--a
|
||||
`);
|
||||
});
|
||||
|
||||
it('Object export with storyName', () => {
|
||||
const consoleWarnMock = jest.spyOn(console, 'warn').mockImplementation();
|
||||
|
||||
parse(
|
||||
dedent`
|
||||
export default { title: 'foo/bar' };
|
||||
export const A = {
|
||||
storyName: 'Apple'
|
||||
}
|
||||
`,
|
||||
true
|
||||
);
|
||||
|
||||
expect(consoleWarnMock).toHaveBeenCalledWith(
|
||||
'Unexpected usage of "storyName" in "A". Please use "name" instead.'
|
||||
);
|
||||
consoleWarnMock.mockRestore();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -268,6 +268,10 @@ export class CsfFile {
|
||||
__isArgsStory = isArgsStory(p.value as t.Expression, parent, self);
|
||||
} else if (p.key.name === 'name' && t.isStringLiteral(p.value)) {
|
||||
name = p.value.value;
|
||||
} else if (p.key.name === 'storyName' && t.isStringLiteral(p.value)) {
|
||||
logger.warn(
|
||||
`Unexpected usage of "storyName" in "${exportName}". Please use "name" instead.`
|
||||
);
|
||||
}
|
||||
self._storyAnnotations[exportName][p.key.name] = p.value;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user