Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .lintstagedrc.mjs
Original file line number Diff line number Diff line change
@@ -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'],
Expand Down
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading