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
43 changes: 43 additions & 0 deletions .clippy.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
too-many-lines-threshold = 200

# We don't have any downstream users, we don't care about external API changes,
# and this makes the codebase cleaner
avoid-breaking-exported-api = false

disallowed-methods = [
Expand Down Expand Up @@ -25,3 +29,42 @@ disallowed-macros = [
{ path = "std::eprintln", reason = "Use `vite_shared::output` functions (`warn`, `error`) instead." },
{ path = "std::eprint", reason = "Use `vite_shared::output` functions (`warn`, `error`) instead." },
]

### await-holding-invalid-types
## we can remove these if https://github.com/xacrimon/dashmap/issues/348 lands

[[await-holding-invalid-types]]
path = "dashmap::mapref::one::Ref"
reason = "holding dashmap references will cause deadlocks, if the same thread tries to acquire a reference"

[[await-holding-invalid-types]]
path = "dashmap::mapref::one::RefMut"
reason = "holding dashmap references will cause deadlocks, if the same thread tries to acquire a reference"

[[await-holding-invalid-types]]
path = "dashmap::mapref::one::MappedRef"
reason = "holding dashmap references will cause deadlocks, if the same thread tries to acquire a reference"

[[await-holding-invalid-types]]
path = "dashmap::mapref::entry::Entry"
reason = "holding dashmap references will cause deadlocks, if the same thread tries to acquire a reference"

[[await-holding-invalid-types]]
path = "dashmap::mapref::multiple::RefMulti"
reason = "holding dashmap references will cause deadlocks, if the same thread tries to acquire a reference"

[[await-holding-invalid-types]]
path = "dashmap::mapref::multiple::RefMutMulti"
reason = "holding dashmap references will cause deadlocks, if the same thread tries to acquire a reference"

[[await-holding-invalid-types]]
path = "dashmap::iter::Iter"
reason = "holding dashmap references will cause deadlocks, if the same thread tries to acquire a reference"

[[await-holding-invalid-types]]
path = "dashmap::iter::IterMut"
reason = "holding dashmap references will cause deadlocks, if the same thread tries to acquire a reference"

[[await-holding-invalid-types]]
path = "dashmap::iter::OwningIter"
reason = "holding dashmap references will cause deadlocks, if the same thread tries to acquire a reference"
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ jobs:
- run: |
cargo shear
cargo fmt --check
# cargo clippy --all-targets --all-features -- -D warnings
cargo clippy --all-targets --all-features -- -D warnings
# RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --document-private-items
- uses: crate-ci/typos@5374cbf686e897b15713110e233094e2874de7ef # v1.46.1
Expand Down
101 changes: 98 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,115 @@ unit-bindings = "warn"
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage)', 'cfg(coverage_nightly)'] }
unsafe_op_in_unsafe_fn = "warn"
unused_unsafe = "warn"
unused_must_use = "allow"
Comment thread
Boshen marked this conversation as resolved.

[workspace.lints.clippy]
all = { level = "warn", priority = -1 }
# restriction
dbg_macro = "warn"
todo = "warn"
unimplemented = "warn"
todo = "allow"
unimplemented = "allow"
Comment thread
fengmk2 marked this conversation as resolved.
print_stdout = "warn"
print_stderr = "warn"
print_stderr = "allow"
allow_attributes = "warn"
pedantic = { level = "warn", priority = -1 }
nursery = { level = "warn", priority = -1 }
cargo = { level = "warn", priority = -1 }
cargo_common_metadata = "allow"
# Allow lints that currently fire across the workspace (vite-plus + rolldown).
# Re-enable selectively as code is cleaned up.
assertions_on_constants = "allow"
assigning_clones = "allow"
bool_to_int_with_if = "allow"
borrow_deref_ref = "allow"
branches_sharing_code = "allow"
case_sensitive_file_extension_comparisons = "allow"
cast_possible_truncation = "allow"
cast_precision_loss = "allow"
cast_sign_loss = "allow"
collapsible_if = "allow"
default_trait_access = "allow"
derivable_impls = "allow"
doc_link_with_quotes = "allow"
doc_markdown = "allow"
double_ended_iterator_last = "allow"
double_must_use = "allow"
empty_line_after_doc_comments = "allow"
enum_variant_names = "allow"
equatable_if_let = "allow"
fallible_impl_from = "allow"
fn_params_excessive_bools = "allow"
format_push_string = "allow"
future_not_send = "allow"
if_not_else = "allow"
ignore_without_reason = "allow"
implicit_clone = "allow"
implicit_hasher = "allow"
items_after_statements = "allow"
iter_with_drain = "allow"
let_and_return = "allow"
literal_string_with_formatting_args = "allow"
manual_contains = "allow"
manual_let_else = "allow"
manual_string_new = "allow"
manual_strip = "allow"
map_unwrap_or = "allow"
match_same_arms = "allow"
match_wildcard_for_single_variants = "allow"
missing_const_for_fn = "allow"
missing_errors_doc = "allow"
missing_panics_doc = "allow"
module_inception = "allow"
multiple_crate_versions = "allow"
must_use_candidate = "allow"
needless_borrow = "allow"
needless_collect = "allow"
needless_continue = "allow"
needless_for_each = "allow"
needless_lifetimes = "allow"
needless_pass_by_value = "allow"
needless_raw_string_hashes = "allow"
needless_return = "allow"
new_without_default = "allow"
non_send_fields_in_send_ty = "allow"
option_if_let_else = "allow"
or_fun_call = "allow"
overly_complex_bool_expr = "allow"
print_literal = "allow"
ptr_arg = "allow"
redundant_clone = "allow"
redundant_closure = "allow"
redundant_closure_for_method_calls = "allow"
redundant_pub_crate = "allow"
ref_option = "allow"
semicolon_if_nothing_returned = "allow"
significant_drop_tightening = "allow"
similar_names = "allow"
single_char_pattern = "allow"
single_match = "allow"
single_match_else = "allow"
single_option_map = "allow"
struct_excessive_bools = "allow"
struct_field_names = "allow"
too_long_first_doc_paragraph = "allow"
too_many_arguments = "allow"
too_many_lines = "allow"
trailing_empty_array = "allow"
trivially_copy_pass_by_ref = "allow"
type_complexity = "allow"
uninlined_format_args = "allow"
unnecessary_struct_initialization = "allow"
unnecessary_wraps = "allow"
unnested_or_patterns = "allow"
unused_async = "allow"
unused_self = "allow"
use_self = "allow"
used_underscore_binding = "allow"
useless_conversion = "allow"
useless_format = "allow"
useless_let_if_seq = "allow"
useless_vec = "allow"
wrong_self_convention = "allow"

[workspace.dependencies]
anyhow = "1.0.98"
Expand Down
3 changes: 3 additions & 0 deletions bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ vite_task = { workspace = true }
[[bench]]
name = "workspace_load"
harness = false

[lints]
workspace = true
2 changes: 2 additions & 0 deletions bench/benches/workspace_load.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::allow_attributes, clippy::disallowed_types)]

use std::{ffi::OsStr, hint::black_box, path::PathBuf, sync::Arc};

use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
Expand Down
27 changes: 18 additions & 9 deletions crates/vite_command/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#![allow(
clippy::allow_attributes,
clippy::disallowed_macros,
clippy::disallowed_types,
clippy::print_stderr
)]

#[cfg(unix)]
use std::os::fd::{BorrowedFd, RawFd};
use std::{
Expand Down Expand Up @@ -33,19 +40,18 @@ pub fn resolve_bin(
cwd: impl AsRef<AbsolutePath>,
) -> Result<AbsolutePathBuf, Error> {
let current_path;
let path_env = match path_env {
Some(p) => p,
None => {
current_path = std::env::var_os("PATH").unwrap_or_default();
&current_path
}
let path_env = if let Some(p) = path_env {
p
} else {
current_path = std::env::var_os("PATH").unwrap_or_default();
&current_path
};
let path = which::which_in(bin_name, Some(path_env), cwd.as_ref())
.map_err(|_| Error::CannotFindBinaryPath(bin_name.into()))?;
AbsolutePathBuf::new(path).ok_or_else(|| Error::CannotFindBinaryPath(bin_name.into()))
}

/// Resolve `bin_name` to a path and apply the Windows `.cmd` → PowerShell
/// Resolve `bin_name` to a path and apply the Windows `.cmd` → `PowerShell`
/// rewrite. Returns the program to spawn and the arg prefix to prepend
/// before the user args (empty when no rewrite applies).
fn resolve_program(
Expand All @@ -62,8 +68,9 @@ fn resolve_program(
}

/// Build a `tokio::process::Command` for a pre-resolved binary path.
/// Sets inherited stdio and `fix_stdio_streams` (Unix pre_exec).
/// Sets inherited stdio and `fix_stdio_streams` (Unix `pre_exec`).
/// Callers can further customize (add args, envs, override stdio, etc.).
#[must_use]
pub fn build_command(bin_path: &AbsolutePath, cwd: &AbsolutePath) -> Command {
let mut cmd = Command::new(bin_path.as_path());
cmd.current_dir(cwd).stdin(Stdio::inherit()).stdout(Stdio::inherit()).stderr(Stdio::inherit());
Expand All @@ -80,6 +87,7 @@ pub fn build_command(bin_path: &AbsolutePath, cwd: &AbsolutePath) -> Command {
}

/// Execute a command while preserving terminal state.
///
/// This prevents escape sequences from appearing in the prompt when the child process
/// is interrupted (e.g., via Ctrl+C) while the terminal is in a non-standard state.
///
Expand Down Expand Up @@ -107,6 +115,7 @@ pub async fn execute_with_terminal_guard(mut cmd: Command) -> Result<ExitStatus,

/// Build a `tokio::process::Command` for shell execution.
/// Uses `/bin/sh -c` on Unix, `cmd.exe /C` on Windows.
#[must_use]
pub fn build_shell_command(shell_cmd: &str, cwd: &AbsolutePath) -> Command {
#[cfg(unix)]
let mut cmd = {
Expand Down Expand Up @@ -185,7 +194,7 @@ where
///
/// # Returns
///
/// Returns a FspyCommandResult containing the exit status and path accesses.
/// Returns a `FspyCommandResult` containing the exit status and path accesses.
pub async fn run_command_with_fspy<I, S>(
bin_name: &str,
args: I,
Expand Down
4 changes: 2 additions & 2 deletions crates/vite_command/src/ps1_shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use std::ffi::OsString;
use vite_path::{AbsolutePath, AbsolutePathBuf};
use vite_powershell::{POWERSHELL_PREFIX, find_ps1_sibling, powershell_host};

/// Rewrite a vp-managed `.cmd` invocation to go through PowerShell.
/// Rewrite a vp-managed `.cmd` invocation to go through `PowerShell`.
///
/// Returns `Some((powershell_host, prefix_args))` when the rewrite applies.
/// `prefix_args` is `["-NoProfile", "-NoLogo", "-ExecutionPolicy", "Bypass",
Expand All @@ -43,7 +43,7 @@ use vite_powershell::{POWERSHELL_PREFIX, find_ps1_sibling, powershell_host};
///
/// Returns `None` when:
/// - not on Windows,
/// - no PowerShell host (`pwsh.exe` or `powershell.exe`) is on PATH,
/// - no `PowerShell` host (`pwsh.exe` or `powershell.exe`) is on PATH,
/// - stdin is not a terminal (the `.ps1` wrappers hang on piped/null
/// stdin and the Ctrl+C concern doesn't apply without a TTY),
/// - the resolved path is outside `$VP_HOME` (or `$VP_HOME` is
Expand Down
3 changes: 3 additions & 0 deletions crates/vite_error/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ reqwest = { workspace = true, features = ["stream", "rustls-no-provider", "json"
[lib]
test = false
doctest = false

[lints]
workspace = true
2 changes: 2 additions & 0 deletions crates/vite_error/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::allow_attributes, clippy::disallowed_types)]

use std::{ffi::OsString, path::Path, sync::Arc};

use thiserror::Error;
Expand Down
4 changes: 2 additions & 2 deletions crates/vite_global_cli/src/commands/vpx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ async fn execute_global_binary(bin: GlobalBinary, args: &[String], cwd: &Absolut

// Prepend Node.js bin dir to PATH
let node_bin_dir = node_path.parent().expect("Node has no parent directory");
prepend_to_path_env(node_bin_dir, PrependOptions::default());
let _ = prepend_to_path_env(node_bin_dir, PrependOptions::default());

// Prepend local node_modules/.bin dirs to PATH
prepend_node_modules_bin_to_path(cwd);
Expand Down Expand Up @@ -231,7 +231,7 @@ fn prepend_node_modules_bin_to_path(cwd: &AbsolutePath) {

// Prepend in reverse order so the nearest (deepest) directory ends up first
for dir in bin_dirs.iter().rev() {
prepend_to_path_env(dir, PrependOptions { dedupe_anywhere: true });
let _ = prepend_to_path_env(dir, PrependOptions { dedupe_anywhere: true });
}
}

Expand Down
10 changes: 8 additions & 2 deletions crates/vite_global_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
//! pre-installed Node.js. Uses managed Node.js from `vite_js_runtime` for
//! package manager commands and JS script execution.

// Allow printing to stderr for CLI error messages
#![allow(clippy::print_stderr)]
#![allow(
clippy::allow_attributes,
clippy::disallowed_macros,
clippy::disallowed_methods,
clippy::disallowed_types,
clippy::print_stderr,
clippy::print_stdout
)]

mod cli;
mod command_picker;
Expand Down
4 changes: 2 additions & 2 deletions crates/vite_global_cli/src/shim/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ pub async fn dispatch(tool: &str, args: &[String]) -> i32 {
// Prepend real node bin dir to PATH so child processes use the correct version
let node_bin_dir = tool_path.parent().expect("Tool has no parent directory");
// Use dedupe_anywhere=false to only check if it's first in PATH (original behavior)
prepend_to_path_env(node_bin_dir, PrependOptions::default());
let _ = prepend_to_path_env(node_bin_dir, PrependOptions::default());

// Optional debug env vars
if std::env::var(env_vars::VP_DEBUG_SHIM).is_ok() {
Expand Down Expand Up @@ -905,7 +905,7 @@ async fn dispatch_package_binary(tool: &str, args: &[String]) -> i32 {

// Prepare environment for recursive invocations
let node_bin_dir = node_path.parent().expect("Node has no parent directory");
prepend_to_path_env(node_bin_dir, PrependOptions::default());
let _ = prepend_to_path_env(node_bin_dir, PrependOptions::default());

// Check if the binary is a JavaScript file that needs Node.js
// This info was determined at install time and stored in metadata
Expand Down
12 changes: 6 additions & 6 deletions crates/vite_install/src/commands/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ impl PackageManager {
if save_catalog_name.is_empty() {
args.push("--save-catalog".into());
} else {
args.push(format!("--save-catalog-name={}", save_catalog_name));
args.push(format!("--save-catalog-name={save_catalog_name}"));
}
}

if let Some(allow_build) = options.allow_build {
args.push(format!("--allow-build={}", allow_build));
args.push(format!("--allow-build={allow_build}"));
}
}
PackageManagerType::Yarn => {
Expand Down Expand Up @@ -219,10 +219,10 @@ impl PackageManager {
if options.save_exact {
args.push("--exact".into());
}
if let Some(filters) = options.filters {
if !filters.is_empty() {
output::warn("bun add does not support --filter");
}
if let Some(filters) = options.filters
&& !filters.is_empty()
{
output::warn("bun add does not support --filter");
}
if options.workspace_root {
output::warn("bun add does not support --workspace-root");
Expand Down
2 changes: 1 addition & 1 deletion crates/vite_install/src/commands/audit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct AuditCommandOptions<'a> {

impl PackageManager {
/// Run the audit command with the package manager.
/// Returns ExitStatus with success (0) if the command is not supported.
/// Returns `ExitStatus` with success (0) if the command is not supported.
#[must_use]
pub async fn run_audit_command(
&self,
Expand Down
2 changes: 1 addition & 1 deletion crates/vite_install/src/commands/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct CacheCommandOptions<'a> {

impl PackageManager {
/// Run the cache command with the package manager.
/// Returns ExitStatus with success (0) if the command is not supported.
/// Returns `ExitStatus` with success (0) if the command is not supported.
#[must_use]
pub async fn run_cache_command(
&self,
Expand Down
Loading
Loading