Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,10 @@ disallowed-types = [
{ path = "std::string::String", reason = "Use `vite_str::Str` for small strings. For large strings, prefer `Box/Rc/Arc<str>` if mutation is not needed." },
]

disallowed-macros = [{ path = "std::format", reason = "Use `vite_str::format` for small strings." }]
disallowed-macros = [
{ path = "std::format", reason = "Use `vite_str::format` for small strings." },
{ path = "std::println", reason = "Use `vite_shared::output` functions (`info`, `note`, `success`) instead." },
{ path = "std::print", reason = "Use `vite_shared::output` functions (`info`, `note`, `success`) instead." },
{ path = "std::eprintln", reason = "Use `vite_shared::output` functions (`warn`, `error`) instead." },
{ path = "std::eprint", reason = "Use `vite_shared::output` functions (`warn`, `error`) instead." },
]
11 changes: 11 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ vp run dev # runs dev script from package.json

- **Passing to std functions**: `AbsolutePath` implements `AsRef<Path>`, use `.as_path()` when explicit `&Path` is required

## Clippy Rules

All **new** Rust code must follow the custom clippy rules defined in `.clippy.toml` (disallowed types, macros, and methods). Existing code may not fully comply due to historical reasons.
Comment thread
fengmk2 marked this conversation as resolved.

## CLI Output

All user-facing output must go through shared output modules instead of raw print calls.

- **Rust**: Use `vite_shared::output` functions (`info`, `warn`, `error`, `note`, `success`) — never raw `println!`/`eprintln!` (enforced by clippy `disallowed-macros`)
- **TypeScript**: Use `packages/cli/src/utils/terminal.ts` functions (`infoMsg`, `warnMsg`, `errorMsg`, `noteMsg`, `log`) — never raw `console.log`/`console.error`

## Git Workflow

- Run `vp fmt` before committing to format code
Expand Down
10 changes: 5 additions & 5 deletions crates/vite_shared/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@ pub const WARN_SIGN: &str = "\u{26A0}";
pub const ARROW: &str = "\u{2192}";

/// Print an info message to stdout.
#[allow(clippy::print_stdout)]
#[allow(clippy::print_stdout, clippy::disallowed_macros)]
pub fn info(msg: &str) {
println!("{} {msg}", "info:".bright_blue().bold());
}

/// Print a warning message to stderr.
#[allow(clippy::print_stderr)]
#[allow(clippy::print_stderr, clippy::disallowed_macros)]
pub fn warn(msg: &str) {
eprintln!("{} {msg}", "warn:".yellow().bold());
}

/// Print an error message to stderr.
#[allow(clippy::print_stderr)]
#[allow(clippy::print_stderr, clippy::disallowed_macros)]
pub fn error(msg: &str) {
eprintln!("{} {msg}", "error:".red().bold());
}

/// Print a note message to stdout (supplementary info).
#[allow(clippy::print_stdout)]
#[allow(clippy::print_stdout, clippy::disallowed_macros)]
pub fn note(msg: &str) {
println!("{} {msg}", "note:".dimmed().bold());
}

/// Print a success line with checkmark to stdout.
#[allow(clippy::print_stdout)]
#[allow(clippy::print_stdout, clippy::disallowed_macros)]
pub fn success(msg: &str) {
println!("{} {msg}", CHECK.green());
}
Loading