Skip to content

CLI: Keep main and eslint config edits to the lines they change - #36546

Closed
valentinpalkovic wants to merge 3 commits into
nextfrom
fix/cli-minimal-config-edits
Closed

valentinpalkovic wants to merge 3 commits into
nextfrom
fix/cli-minimal-config-edits

Conversation

@valentinpalkovic

Copy link
Copy Markdown
Contributor

Closes #

What I did

storybook add and the eslint plugin setup restyle whole config files when they only add one entry.
This PR keeps each edit to the lines it changes.

  • storybook add wrote recast's output as is, which collapsed grommet's multi-line addons array into one line and indented spartan's tab-indented main.ts with 8 spaces. It now formats its edit with formatExistingFile, which uses the Prettier the project installed and the project's Prettier config, and leaves the edit as printed when the project has none.
  • The shared formatFileContent is not used here, because its fallback to Prettier's defaults for an .editorconfig restyled vue-dsfr's main.ts (79 lines, with default quotes and semicolons) and gutenberg's (66 lines lost wp-prettier's paren spacing).
  • The eslint plugin setup inserts its import and spread as text instead of reprinting the file with recast. grommet's eslint.config.mjs changes by 3 lines instead of 219.
-  await writeFile(fileName, await formatFileContent(fileName, formatConfig(mainConfigCSFFile)));
+  await writeFile(fileName, await formatExistingFile(fileName, formatConfig(mainConfigCSFFile)));

Split out of #36476, which collected the bugs that running storybook upgrade against ten open-source Storybook 10 monorepos turned up on next.

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

Caution

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

  1. Clone https://github.com/grommet/grommet and install dependencies.
  2. Run npx storybook@<canary> upgrade --yes --config-dir storybook.
  3. Confirm eslint.config.mjs gains only the plugin import and one spread.
  4. Confirm storybook/main.js keeps its multi-line addons array.
  5. In a tab-indented project with a Prettier config, run npx storybook@<canary> add @storybook/addon-a11y and confirm git diff on main.ts shows only the added addon.

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

  • Declare whether manual QA will be needed for this PR during the next release, through qa:needed or qa:skip

  • 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.

🤖 Generated with Claude Code

setupAddonInConfig wrote recast's output as is, so adding an addon printed
the new addons entry with recast's default indentation, for example 8 spaces
in a tab-indented file. Run the project's formatter before writing, as the
automigrations do.

(cherry picked from commit f0f6ae3)
configureFlatConfig reprinted the whole config with recast, so adding the
plugin re-indented every object in grommet's eslint.config.mjs (219 changed
lines) and wrote a double-quoted import into a single-quoted file. Insert the
import after the existing imports and the spread after the last array or
argument item as text, in the file's quote style and layout, and run the
project's formatter on the result.

(cherry picked from commit fa9cf6d)
storybook add's edit of vue-dsfr's main.ts (no Prettier config, only an
.editorconfig) rewrote 79 lines with Prettier's default quotes and
semicolons, and gutenberg's lost wp-prettier's paren spacing on 66 lines.

(cherry picked from commit d6f2573)
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor
Fails
🚫

PR is not labeled with one of: ["qa:needed","qa:skip","qa:success"]

🚫 This PR needs an approving review from a Storybook Core or Developer Experience team member before it can be merged. No approvals found.

Generated by 🚫 dangerJS against 308131f

@valentinpalkovic valentinpalkovic self-assigned this Oct 1, 2026
@valentinpalkovic valentinpalkovic added the ci:normal Run our default set of CI jobs (choose this for most PRs). label Oct 1, 2026
@valentinpalkovic
valentinpalkovic marked this pull request as ready for review October 1, 2026 14:19
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).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant