fix(cli): run lint fixes before the formatter in ultracite fix - #791
fix(cli): run lint fixes before the formatter in ultracite fix#791keyurgovrani wants to merge 1 commit into
ultracite fix#791Conversation
`fix` ran the formatter first (oxfmt before oxlint --fix, Prettier before ESLint --fix). A fixer can insert unformatted code, such as the braces `curly` adds or the imports `consistent-type-specifier-style` splits, so a single run left that code unformatted until the next run. Running the linter first and the formatter second makes one `fix` idempotent. Stylelint still runs last on the ESLint path; it only touches style files, which neither ESLint nor Prettier rewrite.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 13afb57 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe ChangesFix command ordering
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The command now applies lint fixes before formatting, improving one-run consistency and idempotence; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Description checkExplanation The description is detailed and relevant. It explains the problem, the implementation, the affected tests, the changeset, and the test results. It does not use the template headings exactly and does not provide a related issue number, but these omissions do not prevent review. Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
ultracite fixruns the formatter before the linter's fixes:oxfmt --writebeforeoxlint --fix, andprettier --writebeforeeslint --fix. A fixer can insert code that is not in the formatter's shape, for example the bracescurlyadds:The same happens with the imports
import/consistent-type-specifier-stylesplits and withswitch-case-braces. So onefixis not idempotent, and a lint-staged setup commits half-formatted code. This PR swaps the order so the linter runs first and the formatter second. Stylelint stays last on the ESLint path: it only touches style files, which neither ESLint nor Prettier rewrite.Changes
packages/cli/src/commands/fix.ts:runSteps([oxlint, oxfmt])andrunSteps([eslint, prettier, stylelint]).packages/cli/__tests__/fix.test.ts: order assertions and the spawn-failure tests follow the new order..changeset/lint-before-format.md: patch.How I found it
Adopting ultracite in a ~35k-file monorepo,
pnpm fixleft everycurlyfix on one line until the next run. Verified against the shipped bundle (ye([vs, Cs])indist/index.js, wherevsisoxfmt --write). We are running a trailingoxfmt --writein lint-staged as the workaround.Test plan
bun testinpackages/cli: 536 pass, 0 failbun ./packages/cli/src/index.ts checkon the repoturbo build+turbo typesSummary by CodeRabbit