Skip to content

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

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

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

Conversation

@fengmk2

@fengmk2fengmk2 commented Nov 26, 2025

Copy link
Copy Markdown
Member

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.

@fengmk2Graphite App

fengmk2 commented Nov 26, 2025

Copy link
Copy Markdown
MemberAuthor

@fengmk2fengmk2 changed the title feat: merge oxlint configfeat: add json config migration to vite.config.tsNov 26, 2025
@fengmk2
fengmk2force-pushed the 11-21-feat_add_vite_migration_command branch from 18f0f17 to 82824acCompareNovember 26, 2025 10:04
@fengmk2
fengmk2force-pushed the 11-26-feat_merge_oxlint_config branch from ac4966d to 8cadba2CompareNovember 26, 2025 10:04
@fengmk2
fengmk2force-pushed the 11-21-feat_add_vite_migration_command branch from 82824ac to 74d2fe0CompareNovember 26, 2025 11:53
@fengmk2
fengmk2force-pushed the 11-26-feat_merge_oxlint_config branch from 8cadba2 to 6022743CompareNovember 26, 2025 11:53
@fengmk2
fengmk2force-pushed the 11-21-feat_add_vite_migration_command branch from 74d2fe0 to e032c42CompareNovember 26, 2025 14:53
@fengmk2
fengmk2force-pushed the 11-26-feat_merge_oxlint_config branch 2 times, most recently from b757f07 to 3725f63CompareNovember 27, 2025 05:34
@fengmk2
fengmk2force-pushed the 11-21-feat_add_vite_migration_command branch from e032c42 to 2794070CompareNovember 27, 2025 05:34
@fengmk2
fengmk2force-pushed the 11-26-feat_merge_oxlint_config branch from 3725f63 to 65b55b8CompareNovember 27, 2025 09:19
@fengmk2
fengmk2force-pushed the 11-21-feat_add_vite_migration_command branch 2 times, most recently from 9fffc2c to a0e7d4aCompareNovember 27, 2025 09:26
@fengmk2
fengmk2force-pushed the 11-26-feat_merge_oxlint_config branch 2 times, most recently from ef7c83f to 3e10518CompareNovember 27, 2025 09:29
@fengmk2
fengmk2force-pushed the 11-21-feat_add_vite_migration_command branch 2 times, most recently from 801cce1 to ff0a31bCompareNovember 27, 2025 09:34
@fengmk2
fengmk2force-pushed the 11-26-feat_merge_oxlint_config branch 2 times, most recently from 60fc265 to 72ca8efCompareNovember 27, 2025 09:41
@fengmk2
fengmk2force-pushed the 11-21-feat_add_vite_migration_command branch from ff0a31b to 1ba133dCompareNovember 27, 2025 09:41
@fengmk2fengmk2 self-assigned this Nov 27, 2025
@fengmk2
fengmk2force-pushed the 11-21-feat_add_vite_migration_command branch from 1ba133d to fea670aCompareNovember 27, 2025 12:36
@fengmk2
fengmk2force-pushed the 11-26-feat_merge_oxlint_config branch from 72ca8ef to e68937dCompareNovember 27, 2025 12:36
@fengmk2
fengmk2force-pushed the 11-26-feat_merge_oxlint_config branch 2 times, most recently from 9852dbe to f7679e6CompareNovember 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 wan9chiNovember 27, 2025 12:38

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
rfcs/migration-command.mdCorrects config key from "format" to "fmt" in documentation examples
packages/global/src/migration/migrator.tsAdds 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.rsExports mergeJsonConfig function to the JavaScript binding layer
packages/cli/binding/src/lib.rsAdds merge_json_config to exported bindings
packages/cli/binding/index.jsExports mergeJsonConfig from native binding
packages/cli/binding/index.d.tsAdds TypeScript definitions for mergeJsonConfig and MergeJsonConfigResult
crates/vite_migration/src/vite_config.rsCore implementation of JSON-to-TypeScript conversion and AST-based merging with comprehensive test coverage
crates/vite_migration/src/lib.rsExports merge_json_config and MergeResult from vite_config module
crates/vite_migration/rules/*.yamlReference AST-grep rule templates for config merging (not used programmatically)
Cargo.tomlEnables TypeScript language support in ast-grep-language dependency
Cargo.lockAdds 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.

Comment threadcrates/vite_migration/src/vite_config.rs Outdated
Comment threadpackages/global/src/migration/migrator.ts
Comment threadpackages/cli/binding/src/migration.rs Outdated
Comment threadcrates/vite_migration/src/vite_config.rs Outdated
Comment threadcrates/vite_migration/src/vite_config.rs Outdated
@fengmk2
fengmk2force-pushed the 11-26-feat_merge_oxlint_config branch from fc227b6 to dc4626eCompareDecember 1, 2025 09:31
CopilotAI review requested due to automatic review settings December 2, 2025 02:18
@fengmk2
fengmk2force-pushed the 11-26-feat_merge_oxlint_config branch from dc4626e to 8b9e67dCompareDecember 2, 2025 02:18

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadcrates/vite_migration/rules/rewrite-import.yaml Outdated
Comment threadcrates/vite_migration/rules/rewrite-import.yaml Outdated
Comment threadpackages/global/src/migration/detector.ts Outdated
Comment threadpackages/global/src/migration/migrator.ts
Comment threadpackages/global/src/migration/migrator.ts Outdated
Comment threadrfcs/migration-command.md
Comment threadrfcs/migration-command.md
Comment threadpackages/global/src/migration/migrator.ts Outdated

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadpackages/global/src/migration/migrator.ts Outdated
Comment threadpackages/global/src/migration/migrator.ts Outdated
Comment threadpackages/cli/binding/src/migration.rs Outdated
Comment threadcrates/vite_migration/src/vite_config.rs Outdated
Comment threadcrates/vite_migration/src/vite_config.rs Outdated
@Brooooooklyn

Copy link
Copy Markdown
Member

cursor review

Comment threadpackages/global/src/migration/detector.ts
Comment threadpackages/global/src/migration/detector.ts
Comment threadcrates/vite_migration/src/vite_config.rs

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadpackages/global/src/migration/bin.ts Outdated
Comment threadpackages/global/src/migration/migrator.ts
Comment threadpackages/global/src/migration/migrator.ts
Comment threadrfcs/migration-command.md

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadrfcs/migration-command.md
Comment threadpackages/global/src/migration/detector.ts
@Brooooooklyn

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

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".

Comment threadcrates/vite_migration/src/vite_config.rs

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadrfcs/migration-command.md
Comment threadrfcs/migration-command.md
Comment threadrfcs/migration-command.md
Comment threadpackages/global/src/migration/migrator.ts
Comment threadcrates/vite_migration/src/vite_config.rs
Comment threadpackages/global/src/migration/migrator.ts Outdated
Comment threadrfcs/migration-command.md
Comment threadrfcs/migration-command.md
Comment threadrfcs/migration-command.md
Comment threadrfcs/migration-command.md Outdated

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadcrates/vite_migration/src/vite_config.rs Outdated
Comment threadpackages/global/snap-tests/migration-monorepo-pnpm/snap.txt
Comment threadpackages/global/src/migration/migrator.ts Outdated
Comment threadcrates/vite_migration/src/vite_config.rs
Comment threadpackages/global/src/migration/migrator.ts Outdated
Comment threadpackages/global/src/migration/migrator.ts

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadpackages/global/src/migration/migrator.ts
Comment threadpackages/global/src/migration/migrator.ts
Comment threadpackages/global/src/migration/migrator.ts
Comment threadpackages/global/src/migration/migrator.ts
Comment threadpackages/global/src/migration/migrator.ts Outdated
Comment threadpackages/global/src/migration/migrator.ts
Comment threadpackages/global/src/migration/migrator.ts
Comment threadcrates/vite_migration/src/vite_config.rs

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadpackages/global/src/migration/migrator.ts
Comment threadpackages/global/src/migration/migrator.ts
Comment threadpackages/global/src/migration/migrator.ts
Comment threadpackages/global/src/migration/bin.ts
Comment threadpackages/global/src/migration/detector.ts
Comment threadcrates/vite_migration/src/vite_config.rs
Comment threadrfcs/migration-command.md

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadpackages/global/src/migration/migrator.ts
Comment threadpackages/global/src/migration/migrator.ts
Comment threadpackages/global/src/migration/migrator.ts
Comment threadcrates/vite_migration/src/vite_config.rs
Comment threadpackages/global/src/utils/path.ts

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadpackages/global/src/migration/migrator.ts
Comment threadpackages/global/src/migration/migrator.ts
Comment threadcrates/vite_migration/src/vite_config.rs
@fengmk2Graphite App

Copy link
Copy Markdown
MemberAuthor

Merge activity

Sign up for freeto 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

@fengmk2@Brooooooklyn@wan9chi