fix(oxlint,oxfmt): Skip vite.config.ts exports defineConfig(fn)#20260
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
vite.config.ts exports defineConfig(fn)
There was a problem hiding this comment.
Pull request overview
Updates oxlint/oxfmt JS config loading to tolerate vite.config.ts default exports that are functions (e.g. defineConfig(fn)) by skipping them during config discovery, and adds fixtures/tests to lock in the behavior.
Changes:
- oxlint: treat non-object
vite.config.tsdefault exports as “skip config” (config: null) instead of throwing. - oxfmt: treat non-object
vite.config.tsdefault exports as “skip config” (null) instead of throwing. - Add new fixtures + snapshot coverage for the function-export vite config case in both projects.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/oxlint/src-js/js_config.ts | Skip vite.config.ts when default export isn’t an object; reuse helper for object checks. |
| apps/oxlint/test/fixtures/vite_config_fn_export/vite.config.ts | Fixture vite config exporting defineConfig(fn). |
| apps/oxlint/test/fixtures/vite_config_fn_export/output.snap.md | Expected fixture output snapshot. |
| apps/oxlint/test/fixtures/vite_config_fn_export/options.json | Fixture options (single-threaded). |
| apps/oxlint/test/fixtures/vite_config_fn_export/files/test.js | Fixture input file triggering a warning. |
| apps/oxfmt/src-js/cli/js_config.ts | Skip vite.config.ts when default export isn’t an object; validate .fmt only on objects. |
| apps/oxfmt/test/cli/vite_config/vite_config.test.ts | Add test case for skipping function-export vite config during auto-discovery. |
| apps/oxfmt/test/cli/vite_config/fixtures/skip_fn_export/vite.config.ts | Fixture vite config exporting defineConfig(fn). |
| apps/oxfmt/test/cli/vite_config/fixtures/skip_fn_export/test.ts | Fixture input file for formatter check. |
| apps/oxfmt/test/cli/vite_config/snapshots/vite_config.test.ts.snap | Snapshot for the new oxfmt test case. |
You can also share your feedback on Copilot code review. Take the survey.
7caf1cc to
a50928d
Compare
Merge activity
|
a50928d to
9474e54
Compare
…20260) `vite.config.ts` may return function from `defineConfig(({ mode }) => ({ ... }))`, but we can't evaluate. Just skip it like no `.lint|fmt` config.
9474e54 to
4ea67de
Compare
# Oxlint ### 🐛 Bug Fixes - 4ea67de oxlint,oxfmt: Skip `vite.config.ts` exports `defineConfig(fn)` (#20260) (leaysgur) - cc89dbf oxlint: Skip `vite.config.ts` w/o `.lint` field in auto-discovery (#20255) (leaysgur) - 89b7ca9 linter/no-duplicate-imports: Only check aggregated exports (#20178) (kennytm) - 691f556 linter/explicit-module-boundary-types: Ignore constructor callbacks (#20221) (camc314) ### ⚡ Performance - d160dca linter/plugins: Reduce array lookups in visitor compilation (#20249) (overlookmotel) ### 📚 Documentation - 0c7da4f linter: Fix extra closing brace in example config. (#20253) (connorshea) - 13606c3 linter/plugins: Update conformance README (#20234) (overlookmotel) # Oxfmt ### 🐛 Bug Fixes - 4ea67de oxlint,oxfmt: Skip `vite.config.ts` exports `defineConfig(fn)` (#20260) (leaysgur) - 11a2b45 oxfmt: Skip `vite.config.ts` w/o `.fmt` field in auto-discovery (#20254) (leaysgur) Co-authored-by: leaysgur <6259812+leaysgur@users.noreply.github.com>

vite.config.tsmay return function fromdefineConfig(({ mode }) => ({ ... })), but we can't evaluate.Just skip it like no
.lint|fmtconfig.