Skip to content

fix(cli): suppress VITE+ header for lint/fmt LSP and stdin flows#1619

Draft
fengmk2 wants to merge 1 commit into
mainfrom
fix/suppress-header-lsp
Draft

fix(cli): suppress VITE+ header for lint/fmt LSP and stdin flows#1619
fengmk2 wants to merge 1 commit into
mainfrom
fix/suppress-header-lsp

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented May 18, 2026

Summary

The cosmetic VITE+ - The Unified Toolchain for the Web banner is printed to stdout before vp lint / vp fmt delegate to oxlint/oxfmt. For IDE-launched subprocesses (--lsp, --stdin-filepath) the editor parses stdout as the LSP protocol or as formatted source, so the banner corrupts the stream.

Skip the banner exactly when:

  • vp lint --lsp
  • vp fmt --lsp
  • vp fmt --stdin-filepath (also --stdin-filepath=<path>)

All other invocations of vp lint / vp fmt are unchanged and remain subject to the existing TTY / GIT_INDEX_FILE suppressions in vite_shared::header::should_print_header().

Implementation lives in crates/vite_global_cli/src/cli.rs:

  • New should_suppress_header_for_subcommand("lint"|"fmt", &args) predicate, mirroring the existing should_force_global_delegate shape and reusing has_flag_before_terminator (so --lsp=..., --stdin-filepath=..., and the -- option terminator are all handled correctly).
  • New maybe_print_runtime_header(command, args, show_header) wrapper around print_runtime_header, used at the two call sites.

Refs #1557 (first checkbox; the bin-wrapper deprecation and editor-extension updates remain).

Test plan

  • cargo test -p vite_global_cli suppresses_header — 2 positive tests pass
  • cargo test -p vite_global_cli does_not_suppress — 4 negative tests pass (incl. -- option terminator, unknown subcommand, fmt --check)
  • cargo fmt -p vite_global_cli -- --check clean
  • cargo clippy -p vite_global_cli --tests clean
  • Manual smoke (in a Vite+ project, attached TTY):
    • vp lint → banner printed
    • vp lint --lsp → no banner; stdout is pure LSP protocol
    • vp fmt → banner printed
    • vp fmt --lsp → no banner
    • echo 'const a=1' | vp fmt --stdin-filepath foo.ts → no banner; stdout is just formatted source
    • echo 'const a=1' | vp fmt --stdin-filepath=foo.ts → same
    • vp check (composite) → unaffected

The cosmetic "VITE+ - The Unified Toolchain for the Web" banner is
printed before delegating to oxlint/oxfmt, which corrupts the stdout
stream that IDE extensions parse as LSP protocol or formatted source.

Skip the banner for:
- `vp lint --lsp`
- `vp fmt --lsp`
- `vp fmt --stdin-filepath` (also `--stdin-filepath=<path>`)

All other invocations of `vp lint` / `vp fmt` remain subject to the
existing TTY / `GIT_INDEX_FILE` suppressions in
`vite_shared::header::should_print_header()`.

Refs #1557
@fengmk2 fengmk2 self-assigned this May 18, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented May 18, 2026

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit 92f706d
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a0b1aa2ee81540008c39f53

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.

1 participant