Skip to content

Commit 3946992

Browse files
wan9chiclaude
andcommitted
chore(lint): enforce the session-env-snapshot rule for std::env::vars_os
Disallow fresh process-env snapshots in Vite task crates so planning, execution, IPC, and cache validation keep using the session's captured env map. Session::init remains the one sanctioned bootstrap reader. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 3259649 commit 3946992

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

.clippy.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ disallowed-methods = [
88
{ path = "str::replace", reason = "To avoid memory allocation, use `cow_utils::CowUtils::cow_replace` instead." },
99
{ path = "str::replacen", reason = "To avoid memory allocation, use `cow_utils::CowUtils::cow_replacen` instead." },
1010
{ path = "std::env::current_dir", reason = "To get an `AbsolutePathBuf`, Use `vite_path::current_dir` instead." },
11+
{ path = "std::env::vars_os", reason = "Read process env only in `Session::init`, then use the session env snapshot downstream." },
1112
{ path = "std::thread::sleep", reason = "Use proper synchronization (channels, condvars, etc.) instead of sleeping. Sleep is only acceptable for intentional user-facing delays (e.g. animations, debouncing)." },
1213
{ path = "tokio::time::sleep", reason = "Use proper synchronization (channels, signals, etc.) instead of sleeping. Sleep is only acceptable for intentional user-facing delays (e.g. animations, debouncing)." },
1314
]

crates/vite_task/src/session/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ impl<'a> Session<'a> {
196196
/// if workspace initialization fails.
197197
#[tracing::instrument(level = "debug", skip_all)]
198198
pub fn init(config: SessionConfig<'a>) -> anyhow::Result<Self> {
199+
#[expect(
200+
clippy::disallowed_methods,
201+
reason = "Session::init is the only place that bootstraps the session env snapshot"
202+
)]
199203
let envs = std::env::vars_os()
200204
.map(|(k, v)| (Arc::<OsStr>::from(k.as_os_str()), Arc::<OsStr>::from(v.as_os_str())))
201205
.collect();

0 commit comments

Comments
 (0)