Skip to content

feat: migration config to vite.config.ts#320

Merged
fengmk2 merged 6 commits intomainfrom
11-26-feat_merge_oxlint_config
Dec 5, 2025
Merged

feat: migration config to vite.config.ts#320
fengmk2 merged 6 commits intomainfrom
11-26-feat_merge_oxlint_config

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Nov 26, 2025

This PR adds functionality to migrate standalone configuration files (.oxlintrc, .oxfmtrc) into the unified vite.config.ts format. The implementation:

  • Adds TypeScript language support to ast-grep for parsing config files
  • Creates AST-based rules for merging JSON configs into vite.config.ts
  • Handles various config formats including object literals, function callbacks, and plain exports
  • Properly converts JSON to TypeScript object literals with correct formatting
  • Exposes a new mergeJsonConfig function in the binding API
  • Updates the migration process to automatically merge configs when detected

The implementation handles edge cases like trailing commas, function callbacks, and different export styles to ensure reliable migration.


Note

Adds AST-driven migration that merges .oxlintrc/.oxfmtrc into vite.config, rewrites vite/vitest imports to vite-plus, exposes merge/rewrite APIs in bindings, and updates CLI with version checks and new workflow with tests.

  • Migration Engine (Rust vite_migration):
    • Add TypeScript parsing support via ast-grep features.
    • Implement merge_json_config and rewrite_import with AST rules to:
      • Merge .oxlintrc/.oxfmtrc into defineConfig (supports object, function callbacks, plain exports, return vars, satisfies).
      • Rewrite import ... from 'vite' and 'vitest/config' to '@voidzero-dev/vite-plus'.
    • Include reusable rule files: rules/oxlint-*.yaml, rules/rewrite-import.yaml.
  • Bindings (NAPI + JS):
    • Expose mergeJsonConfig and rewriteImport in packages/cli/binding (TS defs and JS exports).
  • CLI Migration Flow (packages/global/src/migration):
    • Detect vite.config.*/vitest.config.* and rewrite imports.
    • Auto-create vite.config.ts when missing and merge oxlint/oxfmt configs; remove old files.
    • Enforce minimum versions (vite>=7, vitest>=4) with clear errors; upgrade Yarn <4.10 when needed.
    • Apply package manager overrides/resolutions and update scripts; handle monorepos and root workspace files.
  • Detection & Utilities:
    • Add package metadata/version detection; config file detection extended to Vitest.
  • Tests & Docs:
    • Add snapshot tests covering TS/JS, monorepo (pnpm/yarn), auto-create config, and unsupported versions.
    • Update RFC with import rewrite and merged config examples.
  • Deps:
    • Add tree-sitter-typescript via ast-grep-language feature; add tempfile for tests.

Written by Cursor Bugbot for commit 3d3af8c. This will update automatically on new commits. Configure here.

Copy link
Copy Markdown
Member Author

fengmk2 commented Nov 26, 2025

@fengmk2 fengmk2 changed the title feat: merge oxlint config feat: add json config migration to vite.config.ts Nov 26, 2025
@fengmk2 fengmk2 force-pushed the 11-21-feat_add_vite_migration_command branch from 18f0f17 to 82824ac Compare November 26, 2025 10:04
@fengmk2 fengmk2 force-pushed the 11-26-feat_merge_oxlint_config branch from ac4966d to 8cadba2 Compare November 26, 2025 10:04
@fengmk2 fengmk2 force-pushed the 11-21-feat_add_vite_migration_command branch from 82824ac to 74d2fe0 Compare November 26, 2025 11:53
@fengmk2 fengmk2 force-pushed the 11-26-feat_merge_oxlint_config branch from 8cadba2 to 6022743 Compare November 26, 2025 11:53
@fengmk2 fengmk2 force-pushed the 11-21-feat_add_vite_migration_command branch from 74d2fe0 to e032c42 Compare November 26, 2025 14:53
@fengmk2 fengmk2 force-pushed the 11-26-feat_merge_oxlint_config branch 2 times, most recently from b757f07 to 3725f63 Compare November 27, 2025 05:34
@fengmk2 fengmk2 force-pushed the 11-21-feat_add_vite_migration_command branch from e032c42 to 2794070 Compare November 27, 2025 05:34
@fengmk2 fengmk2 force-pushed the 11-26-feat_merge_oxlint_config branch from 3725f63 to 65b55b8 Compare November 27, 2025 09:19
@fengmk2 fengmk2 force-pushed the 11-21-feat_add_vite_migration_command branch 2 times, most recently from 9fffc2c to a0e7d4a Compare November 27, 2025 09:26
@fengmk2 fengmk2 force-pushed the 11-26-feat_merge_oxlint_config branch 2 times, most recently from ef7c83f to 3e10518 Compare November 27, 2025 09:29
@fengmk2 fengmk2 force-pushed the 11-21-feat_add_vite_migration_command branch 2 times, most recently from 801cce1 to ff0a31b Compare November 27, 2025 09:34
@fengmk2 fengmk2 force-pushed the 11-26-feat_merge_oxlint_config branch 2 times, most recently from 60fc265 to 72ca8ef Compare November 27, 2025 09:41
@fengmk2 fengmk2 force-pushed the 11-21-feat_add_vite_migration_command branch from ff0a31b to 1ba133d Compare November 27, 2025 09:41
@fengmk2 fengmk2 self-assigned this Nov 27, 2025
@fengmk2 fengmk2 force-pushed the 11-21-feat_add_vite_migration_command branch from 1ba133d to fea670a Compare November 27, 2025 12:36
@fengmk2 fengmk2 force-pushed the 11-26-feat_merge_oxlint_config branch from 72ca8ef to e68937d Compare November 27, 2025 12:36
@fengmk2 fengmk2 force-pushed the 11-26-feat_merge_oxlint_config branch 2 times, most recently from 9852dbe to f7679e6 Compare November 27, 2025 12:38
@fengmk2 fengmk2 marked this pull request as ready for review November 27, 2025 12:38
@fengmk2 fengmk2 requested a review from branchseer November 27, 2025 12:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds JSON configuration migration functionality to automatically merge standalone .oxlintrc and .oxfmtrc config files into the unified vite.config.ts format. The implementation uses AST-based transformation via ast-grep with TypeScript language support to handle various config patterns including object literals, function callbacks, and plain exports.

Key Changes:

  • Adds TypeScript parser support to ast-grep for parsing config files
  • Implements mergeJsonConfig native binding to merge JSON configs into vite.config.ts using AST manipulation
  • Updates migration process to automatically detect and merge standalone configs when present

Reviewed changes

Copilot reviewed 43 out of 45 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
rfcs/migration-command.md Corrects config key from "format" to "fmt" in documentation examples
packages/global/src/migration/migrator.ts Adds rewriteViteConfigFile function to detect configs, create vite.config.ts if needed, and merge JSON configs
packages/global/src/migration/detector.ts (Context) Provides config file detection functionality
packages/cli/binding/src/migration.rs Exports mergeJsonConfig function to the JavaScript binding layer
packages/cli/binding/src/lib.rs Adds merge_json_config to exported bindings
packages/cli/binding/index.js Exports mergeJsonConfig from native binding
packages/cli/binding/index.d.ts Adds TypeScript definitions for mergeJsonConfig and MergeJsonConfigResult
crates/vite_migration/src/vite_config.rs Core implementation of JSON-to-TypeScript conversion and AST-based merging with comprehensive test coverage
crates/vite_migration/src/lib.rs Exports merge_json_config and MergeResult from vite_config module
crates/vite_migration/rules/*.yaml Reference AST-grep rule templates for config merging (not used programmatically)
Cargo.toml Enables TypeScript language support in ast-grep-language dependency
Cargo.lock Adds tree-sitter-typescript dependency
packages/global/snap-tests/* Comprehensive snapshot tests covering various migration scenarios (monorepo, standalone, auto-create, different config formats)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fengmk2 fengmk2 force-pushed the 11-26-feat_merge_oxlint_config branch from fc227b6 to dc4626e Compare December 1, 2025 09:31
Copilot AI review requested due to automatic review settings December 2, 2025 02:18
@fengmk2 fengmk2 force-pushed the 11-26-feat_merge_oxlint_config branch from dc4626e to 8b9e67d Compare December 2, 2025 02:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 48 out of 50 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 54 out of 56 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Brooooooklyn
Copy link
Copy Markdown
Member

cursor review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 63 out of 65 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 60 out of 62 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Brooooooklyn
Copy link
Copy Markdown
Member

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 70 out of 74 changed files in this pull request and generated 10 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 74 out of 78 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 79 out of 83 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 83 out of 87 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 83 out of 87 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 84 out of 88 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member Author

fengmk2 commented Dec 5, 2025

Merge activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants