Skip to content

Build: Add FIX_ON_COMMIT env var to force autofix in pre-commit hook#34547

Merged
kasperpeulen merged 1 commit into
nextfrom
kasper/fix-on-commit-env
Apr 15, 2026
Merged

Build: Add FIX_ON_COMMIT env var to force autofix in pre-commit hook#34547
kasperpeulen merged 1 commit into
nextfrom
kasper/fix-on-commit-env

Conversation

@kasperpeulen
Copy link
Copy Markdown
Member

@kasperpeulen kasperpeulen commented Apr 15, 2026

Closes #

What I did

Added a FIX_ON_COMMIT environment variable that, when set, forces the pre-commit hook to run formatting (oxfmt) and linting (eslint --fix) in autofix mode — regardless of whether the committer is an AI agent or a human.

Previously, autofix was only enabled when std-env detected a package manager agent. Now you can set FIX_ON_COMMIT=1 to get the same behavior manually.

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

Test by running:

  1. FIX_ON_COMMIT=1 git commit — formatting and lint should autofix staged files
  2. git commit (without the env var, outside an agent context) — should run in check-only mode as before

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

  • New Features

    • Formatting and linting can now be automatically fixed during pre-commit hooks when enabled via environment variable.
  • Documentation

    • Added documentation for the new environment variable controlling autofix behavior on commit.

@kasperpeulen kasperpeulen added build Internal-facing build tooling & test updates ci:normal labels Apr 15, 2026
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Apr 15, 2026

View your CI Pipeline Execution ↗ for commit 88238a6

Command Status Duration Result
nx run-many -t compile,check,knip,test,lint,fmt... ✅ Succeeded 1m 21s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-15 10:49:34 UTC

@kasperpeulen kasperpeulen requested a review from yannbf April 15, 2026 10:33
@storybook-app-bot
Copy link
Copy Markdown

Package Benchmarks

Commit: 88238a6, ran on 15 April 2026 at 10:43:53 UTC

The following packages have significant changes to their size or dependencies:

storybook

Before After Difference
Dependency count 50 50 0
Self size 20.53 MB 20.47 MB 🎉 -59 KB 🎉
Dependency size 16.56 MB 16.56 MB 🎉 -93 B 🎉
Bundle Size Analyzer Link Link

@storybook/nextjs-vite

Before After Difference
Dependency count 93 93 0
Self size 1.12 MB 1.12 MB 🚨 +281 B 🚨
Dependency size 23.77 MB 23.75 MB 🎉 -12 KB 🎉
Bundle Size Analyzer Link Link

@storybook/react-native-web-vite

Before After Difference
Dependency count 122 122 0
Self size 30 KB 30 KB 0 B
Dependency size 24.84 MB 24.82 MB 🎉 -12 KB 🎉
Bundle Size Analyzer Link Link

@storybook/react-vite

Before After Difference
Dependency count 83 83 0
Self size 36 KB 35 KB 🎉 -311 B 🎉
Dependency size 21.55 MB 21.54 MB 🎉 -12 KB 🎉
Bundle Size Analyzer Link Link

@storybook/cli

Before After Difference
Dependency count 184 184 0
Self size 782 KB 782 KB 🎉 -86 B 🎉
Dependency size 68.17 MB 68.11 MB 🎉 -58 KB 🎉
Bundle Size Analyzer Link Link

@storybook/codemod

Before After Difference
Dependency count 177 177 0
Self size 32 KB 32 KB 0 B
Dependency size 66.70 MB 66.64 MB 🎉 -59 KB 🎉
Bundle Size Analyzer Link Link

create-storybook

Before After Difference
Dependency count 51 51 0
Self size 1.04 MB 1.04 MB 🚨 +1 KB 🚨
Dependency size 37.09 MB 37.03 MB 🎉 -59 KB 🎉
Bundle Size Analyzer node node

@kasperpeulen kasperpeulen marked this pull request as ready for review April 15, 2026 10:45
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d2994972-820b-46c0-9b23-9d25029c82da

📥 Commits

Reviewing files that changed from the base of the PR and between a168d41 and 88238a6.

📒 Files selected for processing (2)
  • .lintstagedrc.mjs
  • AGENTS.md

📝 Walkthrough

Walkthrough

The changes add optional autofix functionality to the lint-staged configuration, controlled via a new FIX_ON_COMMIT environment variable. The configuration now conditionally applies autofix flags to formatting and linting commands, with corresponding documentation added.

Changes

Cohort / File(s) Summary
Lint-staged Configuration
.lintstagedrc.mjs
Added conditional autofix support controlled by FIX_ON_COMMIT environment variable. When enabled, oxfmt runs without --check flag and linting commands receive --fix suffix; otherwise, check-only modes are used.
Environment Documentation
AGENTS.md
Documented the new FIX_ON_COMMIT environment variable for forcing autofix behavior in pre-commit hooks.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

@kasperpeulen kasperpeulen merged commit a79f398 into next Apr 15, 2026
126 of 132 checks passed
@kasperpeulen kasperpeulen deleted the kasper/fix-on-commit-env branch April 15, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Internal-facing build tooling & test updates ci:normal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants