-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Csf-tools: Prevent false positive ObjectExpression warning on valid default exports #34993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -221,7 +221,12 @@ export class ConfigFile { | |
|
|
||
| if (t.isObjectExpression(decl)) { | ||
| self._parseExportsObject(decl); | ||
| } else { | ||
| } else if ( | ||
| decl && | ||
| !t.isIdentifier(decl) && | ||
| !t.isCallExpression(decl) && | ||
| !t.isMemberExpression(decl) | ||
| ) { | ||
| logger.warn( | ||
| getCsfParsingErrorMessage({ | ||
| expectedType: 'ObjectExpression', | ||
|
|
@@ -304,7 +309,12 @@ export class ConfigFile { | |
| self._exports[exportName] = exportVal as t.Expression; | ||
| } | ||
| }); | ||
| } else { | ||
| } else if ( | ||
| exportObject && | ||
| !t.isIdentifier(exportObject) && | ||
| !t.isCallExpression(exportObject) && | ||
| !t.isMemberExpression(exportObject) | ||
| ) { | ||
|
Comment on lines
+312
to
+317
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add regression coverage for This guard changed behavior for 🤖 Prompt for AI Agents |
||
| logger.warn( | ||
| getCsfParsingErrorMessage({ | ||
| expectedType: 'ObjectExpression', | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: storybookjs/storybook
Length of output: 7744
Align
ConfigFile.test.tslogger warning suppression with Vitest spy-mocking rules.In
code/core/src/csf-tools/ConfigFile.test.ts(around lines 257-279),logger.warnis spied andmockImplementationis set inline inside the test body, which violates.cursor/rules/spy-mocking.mdc(mock implementations must be inbeforeEach, and inline mock implementations in test cases should be avoided). It also doesn’t use thevi.mock(..., { spy: true })+vi.mocked()pattern for module mocking.Suggested update
🤖 Prompt for AI Agents