Skip to content

Core: Ignore empty files when indexing#33782

Merged
JReinhold merged 1 commit into
nextfrom
jeppe/ignore-empty-story-files
Feb 5, 2026
Merged

Core: Ignore empty files when indexing#33782
JReinhold merged 1 commit into
nextfrom
jeppe/ignore-empty-story-files

Conversation

@JReinhold
Copy link
Copy Markdown
Contributor

@JReinhold JReinhold commented Feb 5, 2026

Closes #

What I did

Ignored empty and almost-empty files (whitespace only) during indexing. Previously, the terminal would show an error as soon as you created a Card.stories.tsx file, and then you'd have to fill it in afterwards. Now that error goes away.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

Create an empty stories file while Storybook is running. Observe no errors, and that adding stories to the file still works.

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of empty or whitespace-only story files to prevent unnecessary processing.
  • Tests

    • Updated test infrastructure and added validation for empty story file scenarios.
  • Chores

    • Updated linting configuration to ignore additional story files.

@valentinpalkovic valentinpalkovic added the ci:normal Run our default set of CI jobs (choose this for most PRs). label Feb 5, 2026
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Feb 5, 2026

View your CI Pipeline Execution ↗ for commit fc65414

Command Status Duration Result
nx run-many -t compile,check,knip,test,pretty-d... ❌ Failed 10m View ↗

☁️ Nx Cloud last updated this comment at 2026-02-05 14:16:41 UTC

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

The changes migrate CSF parsing from readCsf to loadCsf API across the codebase, including implementation and test files. Added empty file handling to return early for whitespace-only story files. Updated corresponding test mocks and assertions, plus new test coverage for empty file scenarios.

Changes

Cohort / File(s) Summary
ESLint Configuration
.eslintignore
Added ignore rule for empty mock data story file to exclude from linting.
CSF Parsing Migration
core/src/core-server/presets/common-preset.ts, core/src/core-server/utils/StoryIndexGenerator.test.ts
Replaced readCsf with loadCsf API. Added guard for empty/whitespace-only files to return early with empty index. Updated test mocks, imports, and assertions to use new loadCsf API. Added new test case for empty file handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@JReinhold JReinhold merged commit 6af360f into next Feb 5, 2026
131 of 140 checks passed
@JReinhold JReinhold deleted the jeppe/ignore-empty-story-files branch February 5, 2026 14:43
@Sidnioulz
Copy link
Copy Markdown
Contributor

QA Ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug ci:normal Run our default set of CI jobs (choose this for most PRs). core story index

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants