From 0bb91a4aeae69d5bc6c0276536db2e023a0bcda9 Mon Sep 17 00:00:00 2001 From: MK Date: Sat, 12 Sep 2026 00:13:05 +0800 Subject: [PATCH] fix(cli): remove oxlint and oxfmt bin wrappers --- .../fixtures/bin_oxfmt_wrapper/package.json | 5 - .../fixtures/bin_oxfmt_wrapper/snapshots.toml | 12 -- .../snapshots/bin_oxfmt_wrapper.md | 113 --------------- .../fixtures/bin_oxlint_wrapper/package.json | 5 - .../bin_oxlint_wrapper/snapshots.toml | 11 -- .../snapshots/bin_oxlint_wrapper.md | 136 ------------------ .../tests/cli_snapshots/main.rs | 2 +- packages/cli/bin/oxfmt | 33 ----- packages/cli/bin/oxlint | 38 ----- packages/cli/package.json | 2 - packages/cli/src/utils/constants.ts | 4 +- packages/cli/tsdown.config.ts | 1 - 12 files changed, 3 insertions(+), 359 deletions(-) delete mode 100644 crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/package.json delete mode 100644 crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/snapshots.toml delete mode 100644 crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/snapshots/bin_oxfmt_wrapper.md delete mode 100644 crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/package.json delete mode 100644 crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/snapshots.toml delete mode 100644 crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/snapshots/bin_oxlint_wrapper.md delete mode 100755 packages/cli/bin/oxfmt delete mode 100755 packages/cli/bin/oxlint diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/package.json b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/package.json deleted file mode 100644 index ccad93acb1..0000000000 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "bin-oxfmt-wrapper", - "version": "0.0.0", - "private": true -} diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/snapshots.toml b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/snapshots.toml deleted file mode 100644 index 8570017ff5..0000000000 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/snapshots.toml +++ /dev/null @@ -1,12 +0,0 @@ -[[case]] -name = "bin_oxfmt_wrapper" -vp = "local" -# The wrapper is addressed by path through the workspace parent, the legacy -# runner's layout. -link-node-modules = true -steps = [ - { argv = ["node", "../node_modules/vite-plus/bin/oxfmt"], comment = "should reject non-LSP usage", continue-on-failure = true }, - { argv = ["node", "../node_modules/vite-plus/bin/oxfmt", "--help"], comment = "should reject non-LSP usage", continue-on-failure = true }, - { argv = ["node", "../node_modules/vite-plus/bin/oxfmt", "--lsp", "--help"], comment = "should allow LSP mode" }, - { argv = ["node", "../node_modules/vite-plus/bin/oxfmt", "--stdin-filepath=a.ts", "--help"], comment = "should allow Stdin mode" }, -] diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/snapshots/bin_oxfmt_wrapper.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/snapshots/bin_oxfmt_wrapper.md deleted file mode 100644 index 798d243a1f..0000000000 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/snapshots/bin_oxfmt_wrapper.md +++ /dev/null @@ -1,113 +0,0 @@ -# bin_oxfmt_wrapper - -## `node ../node_modules/vite-plus/bin/oxfmt` - -should reject non-LSP usage - -**Exit code:** 1 - -``` -This oxfmt wrapper is for IDE extension use only (lsp or stdin mode). -To format your code, run: vp fmt -``` - -## `node ../node_modules/vite-plus/bin/oxfmt --help` - -should reject non-LSP usage - -**Exit code:** 1 - -``` -This oxfmt wrapper is for IDE extension use only (lsp or stdin mode). -To format your code, run: vp fmt -``` - -## `node ../node_modules/vite-plus/bin/oxfmt --lsp --help` - -should allow LSP mode - -``` -Usage: [-c=PATH] [PATH]... - -Mode Options: - --init Initialize `.oxfmtrc.json` with default values - --migrate=SOURCE Migrate configuration to `.oxfmtrc.json` from specified source - Available sources: prettier, biome - --lsp Start language server protocol (LSP) server - --stdin-filepath=PATH Specify the file name to use to infer which parser to use - -Output Options: - --write Format and write files in place (default) - --check Check if files are formatted, also show statistics - --list-different List files that would be changed - -Config Options - -c, --config=PATH Path to the configuration file (.json, .jsonc, .ts, .mts, .cts, .js, - .mjs, .cjs) - --disable-nested-config Do not search for configuration files in subdirectories - -Ignore Options - --ignore-path=PATH Path to ignore file(s). Can be specified multiple times. If not - specified, .gitignore and .prettierignore in the current directory are - used. - --with-node-modules Format code in node_modules directory (skipped by default) - -Runtime Options - --no-error-on-unmatched-pattern Do not exit with error when pattern is unmatched - --threads=INT Number of threads to use. Set to 1 for using only 1 CPU core. - -Available positional items: - PATH Single file, path or list of paths. Glob patterns are also supported. - (Be sure to quote them, otherwise your shell may expand them before - passing.) Exclude patterns with `!` prefix like `'!**/fixtures/*.js'` - are also supported. If not provided, current working directory is used. - -Available options: - -h, --help Prints help information - -V, --version Prints version information -``` - -## `node ../node_modules/vite-plus/bin/oxfmt --stdin-filepath=a.ts --help` - -should allow Stdin mode - -``` -Usage: [-c=PATH] [PATH]... - -Mode Options: - --init Initialize `.oxfmtrc.json` with default values - --migrate=SOURCE Migrate configuration to `.oxfmtrc.json` from specified source - Available sources: prettier, biome - --lsp Start language server protocol (LSP) server - --stdin-filepath=PATH Specify the file name to use to infer which parser to use - -Output Options: - --write Format and write files in place (default) - --check Check if files are formatted, also show statistics - --list-different List files that would be changed - -Config Options - -c, --config=PATH Path to the configuration file (.json, .jsonc, .ts, .mts, .cts, .js, - .mjs, .cjs) - --disable-nested-config Do not search for configuration files in subdirectories - -Ignore Options - --ignore-path=PATH Path to ignore file(s). Can be specified multiple times. If not - specified, .gitignore and .prettierignore in the current directory are - used. - --with-node-modules Format code in node_modules directory (skipped by default) - -Runtime Options - --no-error-on-unmatched-pattern Do not exit with error when pattern is unmatched - --threads=INT Number of threads to use. Set to 1 for using only 1 CPU core. - -Available positional items: - PATH Single file, path or list of paths. Glob patterns are also supported. - (Be sure to quote them, otherwise your shell may expand them before - passing.) Exclude patterns with `!` prefix like `'!**/fixtures/*.js'` - are also supported. If not provided, current working directory is used. - -Available options: - -h, --help Prints help information - -V, --version Prints version information -``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/package.json b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/package.json deleted file mode 100644 index 91f59c6b67..0000000000 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "bin-oxlint-wrapper", - "version": "0.0.0", - "private": true -} diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/snapshots.toml b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/snapshots.toml deleted file mode 100644 index 2ca5c6de91..0000000000 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/snapshots.toml +++ /dev/null @@ -1,11 +0,0 @@ -[[case]] -name = "bin_oxlint_wrapper" -vp = "local" -# The wrapper is addressed by path through the workspace parent, the legacy -# runner's layout. -link-node-modules = true -steps = [ - { argv = ["node", "../node_modules/vite-plus/bin/oxlint"], comment = "should reject non-LSP usage", continue-on-failure = true }, - { argv = ["node", "../node_modules/vite-plus/bin/oxlint", "--help"], comment = "should reject non-LSP usage", continue-on-failure = true }, - { argv = ["node", "../node_modules/vite-plus/bin/oxlint", "--lsp", "--help"], comment = "should exercise import path" }, -] diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/snapshots/bin_oxlint_wrapper.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/snapshots/bin_oxlint_wrapper.md deleted file mode 100644 index e05760c05b..0000000000 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/snapshots/bin_oxlint_wrapper.md +++ /dev/null @@ -1,136 +0,0 @@ -# bin_oxlint_wrapper - -## `node ../node_modules/vite-plus/bin/oxlint` - -should reject non-LSP usage - -**Exit code:** 1 - -``` -This oxlint wrapper is for IDE extension use only (--lsp mode). -To lint your code, run: vp lint -``` - -## `node ../node_modules/vite-plus/bin/oxlint --help` - -should reject non-LSP usage - -**Exit code:** 1 - -``` -This oxlint wrapper is for IDE extension use only (--lsp mode). -To lint your code, run: vp lint -``` - -## `node ../node_modules/vite-plus/bin/oxlint --lsp --help` - -should exercise import path - -``` -Usage: [-c=<./.oxlintrc.json>] [PATH]... - -Basic Configuration - -c, --config=<./.oxlintrc.json> Oxlint configuration file - * `.json` and `.jsonc` config files are supported in all runtimes - * JavaScript/TypeScript config files are experimental and require - running via Node.js - * you can use comments in configuration files. - * tries to be compatible with ESLint v8's format - --tsconfig=<./tsconfig.json> Override the TypeScript config used for import resolution. - Oxlint automatically discovers the relevant `tsconfig.json` for each - file. Use this only when your project uses a non-standard tsconfig - name or location. - --init Initialize oxlint configuration with default values - -Allowing / Denying Multiple Lints - Accumulate rules and categories from left to right on the command-line. - For example `-D correctness -A no-debugger` or `-A all -D no-debugger`. - The categories are: - * `correctness` - Code that is outright wrong or useless (default) - * `suspicious` - Code that is most likely wrong or useless - * `pedantic` - Lints which are rather strict or have occasional false positives - * `perf` - Code that could be written in a more performant way - * `style` - Code that should be written in a more idiomatic way - * `restriction` - Lints which prevent the use of language and library features - * `nursery` - New lints that are still under development - * `all` - All categories listed above except `nursery`. Does not enable plugins - automatically. - -A, --allow=NAME Allow the rule or category (suppress the lint) - -W, --warn=NAME Warn on the rule or category (emit a warning) - -D, --deny=NAME Deny the rule or category (emit an error) - -Enable/Disable Plugins - --disable-unicorn-plugin Disable unicorn plugin, which is turned on by default - --disable-oxc-plugin Disable oxc unique rules, which is turned on by default - --disable-typescript-plugin Disable TypeScript plugin, which is turned on by default - --import-plugin Enable import plugin and detect ESM problems. - --react-plugin Enable react plugin, which is turned off by default - --jsdoc-plugin Enable jsdoc plugin and detect JSDoc problems - --jest-plugin Enable the Jest plugin and detect test problems - --vitest-plugin Enable the Vitest plugin and detect test problems - --jsx-a11y-plugin Enable the JSX-a11y plugin and detect accessibility problems - --nextjs-plugin Enable the Next.js plugin and detect Next.js problems - --react-perf-plugin Enable the React performance plugin and detect rendering performance - problems - --promise-plugin Enable the promise plugin and detect promise usage problems - --node-plugin Enable the node plugin and detect node usage problems - --vue-plugin Enable the vue plugin and detect vue usage problems - -Fix Problems - --fix Fix as many issues as possible. Only unfixed issues are reported in - the output. - --fix-suggestions Apply auto-fixable suggestions. May change program behavior. - --fix-dangerously Apply dangerous fixes and suggestions - -Ignore Files - --ignore-path=PATH Specify the file to use as your `.eslintignore` - --ignore-pattern=PAT Specify patterns of files to ignore (in addition to those in - `.eslintignore`) - --no-ignore Disable excluding files from `.eslintignore` files, --ignore-path - flags and --ignore-pattern flags - -Handle Warnings - --quiet Disable reporting on warnings, only errors are reported - --deny-warnings Ensure warnings produce a non-zero exit code - --max-warnings=INT Specify a warning threshold, which can be used to force exit with an - error status if there are too many warning-level rule violations in - your project - -Output - -f, --format=ARG Use a specific output format. Possible values: `checkstyle`, - `default`, `agent`, `github`, `gitlab`, `json`, `junit`, `sarif`, - `stylish`, `unix` - --debug=OPTIONS Enable debug output options. Options are comma-separated. Possible - values: - * `files` - Print the list of files that will be linted, then exit. - * `timings` - Enable per-rule timing information. - -Miscellaneous - --silent Do not display any diagnostics - --no-error-on-unmatched-pattern Do not exit with an error when no files are selected for - linting (for example, after applying ignore patterns) - --threads=INT Number of threads to use. Set to 1 for using only 1 CPU core. - --print-config This option outputs the configuration to be used. When present, no - linting is performed and only config-related options are valid. - -Inline Configuration Comments - --report-unused-disable-directives Report directive comments like `// oxlint-disable-line`, - when no errors would have been reported on that line anyway - --report-unused-disable-directives-severity=SEVERITY Same as - `--report-unused-disable-directives`, but allows you to specify the - severity level of the reported errors. Only one of these two options - can be used at a time. - -Available positional items: - PATH Single file, single path or list of paths - -Available options: - --rules List all the rules that are currently registered - --lsp Start the language server - --disable-nested-config Disable the automatic loading of nested configuration files - --type-aware Enable rules that require type information - --type-check Enable experimental type checking (includes TypeScript compiler - diagnostics) - -h, --help Prints help information - -V, --version Prints version information -``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/main.rs b/crates/vp_cli_snapshots/tests/cli_snapshots/main.rs index 4c6a920385..34bb1df5f8 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/main.rs +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/main.rs @@ -387,7 +387,7 @@ struct Case { seed_runtime: bool, /// Expose the run-root node_modules as the workspace's parent-dir /// node_modules for fixtures that address the linked checkout packages by path (`node - /// ../node_modules/vite-plus/bin/oxlint`) rather than by specifier + /// ../node_modules/vite-plus/bin/vp`) rather than by specifier /// through Node's upward walk. #[serde(default, rename = "link-node-modules")] link_node_modules: bool, diff --git a/packages/cli/bin/oxfmt b/packages/cli/bin/oxfmt deleted file mode 100755 index db9da6b699..0000000000 --- a/packages/cli/bin/oxfmt +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env node - -// LSP-only wrapper for oxfmt. -// This enables IDE extensions (e.g., oxc-vscode) to discover and start the LSP server. -// Binary resolution follows the same approach as `src/resolve-fmt.ts`. - -const isLSP = process.argv.includes('--lsp'); -const isStdin = process.argv.some((arg) => arg.startsWith('--stdin-filepath')); -if (!isLSP && !isStdin) { - console.error('This oxfmt wrapper is for IDE extension use only (lsp or stdin mode).'); - console.error('To format your code, run: vp fmt'); - process.exit(1); -} - -import { createRequire } from 'node:module'; -import { dirname, join } from 'node:path'; -import { pathToFileURL } from 'node:url'; -import pkg from '../package.json' with { type: 'json' }; - -const require = createRequire(import.meta.url); -const oxfmtMainPath = require.resolve('oxfmt'); -const oxfmtBin = join(dirname(dirname(oxfmtMainPath)), 'bin', 'oxfmt'); - -// This allows oxfmt to load vite.config.ts. -// For `vp check` and `vp fmt`, VP_VERSION is injected by -// `merge_resolved_envs_with_version()` in `cli.rs`. -process.env.VP_VERSION = pkg.version; -// oxfmt reads vite.config.ts only for the `fmt` block, so skip the user's -// Vite plugin factory (lazyPlugins) while the config evaluates. -// Literal kept in sync with CONFIG_METADATA_ENV in src/utils/constants.ts -// (this plain-JS bin can't import the bundled constant). -process.env.VP_RESOLVING_CONFIG_METADATA ??= '1'; -await import(pathToFileURL(oxfmtBin).href); diff --git a/packages/cli/bin/oxlint b/packages/cli/bin/oxlint deleted file mode 100755 index 6b08f5afef..0000000000 --- a/packages/cli/bin/oxlint +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env node - -// LSP-only wrapper for oxlint. -// This enables IDE extensions (e.g., oxc-vscode) to discover and start the LSP server. -// Binary resolution follows the same approach as `src/resolve-lint.ts`. - -if (!process.argv.includes('--lsp')) { - console.error('This oxlint wrapper is for IDE extension use only (--lsp mode).'); - console.error('To lint your code, run: vp lint'); - process.exit(1); -} - -import { createRequire } from 'node:module'; -import { dirname, join } from 'node:path'; -import { pathToFileURL } from 'node:url'; -import { resolveTsgolintExecutable } from '../dist/tsgolint-path.js'; -import pkg from '../package.json' with { type: 'json' }; - -const require = createRequire(import.meta.url); -const oxlintMainPath = require.resolve('oxlint'); -const oxlintBin = join(dirname(dirname(oxlintMainPath)), 'bin', 'oxlint'); -const tsgolintPackageJsonPath = require.resolve('oxlint-tsgolint/package.json'); -const tsgolintBin = resolveTsgolintExecutable( - join(dirname(tsgolintPackageJsonPath), 'bin', 'tsgolint.js'), - import.meta.url, -); - -// This allows oxlint to load vite.config.ts. -// For `vp check` and `vp lint`, VP_VERSION is injected by -// `merge_resolved_envs_with_version()` in `cli.rs`. -process.env.VP_VERSION = pkg.version; -// oxlint reads vite.config.ts only for the `lint` block, so skip the user's -// Vite plugin factory (lazyPlugins) while the config evaluates. -// Literal kept in sync with CONFIG_METADATA_ENV in src/utils/constants.ts -// (this plain-JS bin can't import the bundled constant). -process.env.VP_RESOLVING_CONFIG_METADATA ??= '1'; -process.env.OXLINT_TSGOLINT_PATH ??= tsgolintBin; -await import(pathToFileURL(oxlintBin).href); diff --git a/packages/cli/package.json b/packages/cli/package.json index 54a0760e1d..79b07b7287 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -14,8 +14,6 @@ "directory": "packages/cli" }, "bin": { - "oxfmt": "./bin/oxfmt", - "oxlint": "./bin/oxlint", "vp": "./bin/vp", "vpr": "./bin/vpr" }, diff --git a/packages/cli/src/utils/constants.ts b/packages/cli/src/utils/constants.ts index 2cecc402dd..29d46d3215 100644 --- a/packages/cli/src/utils/constants.ts +++ b/packages/cli/src/utils/constants.ts @@ -116,6 +116,6 @@ export const DEFAULT_ENVS = { // Env var set while `vite.config.ts` is loaded only to read a config block, not // to run the Vite pipeline. `lazyPlugins` skips the user's plugin factory while // it is `'1'`. Single source of truth shared by `withConfigMetadataResolution` -// (in-process) and the oxlint/oxfmt resolvers + bins (which load the config in -// a subprocess). Keep the `bin/oxlint`/`bin/oxfmt` literals in sync with this. +// (in-process) and the oxlint/oxfmt resolvers (which load the config in +// a subprocess). export const CONFIG_METADATA_ENV = 'VP_RESOLVING_CONFIG_METADATA'; diff --git a/packages/cli/tsdown.config.ts b/packages/cli/tsdown.config.ts index f68e7ad32e..8a27711e6a 100644 --- a/packages/cli/tsdown.config.ts +++ b/packages/cli/tsdown.config.ts @@ -52,7 +52,6 @@ export default defineConfig([ 'lint-plugins': './src/lint-plugins.ts', 'lint-plugins-dev': './src/lint-plugins-dev.ts', 'oxlint-plugin': './src/oxlint-plugin.ts', - 'tsgolint-path': './src/utils/tsgolint-path.ts', pack: './src/pack.ts', 'pack-bin': './src/pack-bin.ts', // Global commands — explicit entries ensure lazy loading via dynamic import in bin.ts.