From 88238a6ec7d72a4738c91263515bd814cdfcb93d Mon Sep 17 00:00:00 2001 From: Kasper Peulen Date: Wed, 15 Apr 2026 17:31:09 +0700 Subject: [PATCH] Build: Add FIX_ON_COMMIT env var to force autofix in pre-commit hook --- .lintstagedrc.mjs | 8 +++++--- AGENTS.md | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.lintstagedrc.mjs b/.lintstagedrc.mjs index 9f5654bdc2e8..dd381efdbce5 100644 --- a/.lintstagedrc.mjs +++ b/.lintstagedrc.mjs @@ -1,10 +1,12 @@ import { detectAgent } from 'std-env'; -const fmtCmd = detectAgent().name ? 'oxfmt' : 'oxfmt --check'; +const autofix = process.env.FIX_ON_COMMIT || detectAgent().name; +const fmtCmd = autofix ? 'oxfmt' : 'oxfmt --check'; +const lintSuffix = autofix ? ' --fix' : ''; export default { - 'code/**/*.{js,jsx,mjs,ts,tsx,html,json}': [fmtCmd, 'yarn --cwd code lint:js:cmd'], - 'scripts/**/*.{html,js,json,jsx,mjs,ts,tsx}': ['yarn --cwd scripts lint:js:cmd'], + 'code/**/*.{js,jsx,mjs,ts,tsx,html,json}': [fmtCmd, `yarn --cwd code lint:js:cmd${lintSuffix}`], + 'scripts/**/*.{html,js,json,jsx,mjs,ts,tsx}': [`yarn --cwd scripts lint:js:cmd${lintSuffix}`], 'docs/_snippets/**/*.{js,jsx,mjs,ts,tsx,html,json}': [fmtCmd], '**/*.ejs': ['yarn --cwd scripts exec ejslint'], '**/package.json': ['yarn --cwd scripts lint:package'], diff --git a/AGENTS.md b/AGENTS.md index 7c99c9041a9e..adee7198fcab 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -264,6 +264,7 @@ Avoid `console.log`, `console.warn`, and `console.error` unless the file is isol | `STORYBOOK_DISABLE_TELEMETRY` | Disable telemetry | | `STORYBOOK_TELEMETRY_DEBUG` | Log telemetry events | | `DEBUG` | Enable debug logging | +| `FIX_ON_COMMIT` | Force autofix for fmt & lint in pre-commit hook | ## Commands To Avoid