Skip to content

Commit bd0685e

Browse files
wan9chiclaude
andcommitted
chore: configure clippy rules for non-vite crates via .non-vite.clippy.toml
Non-vite crates previously used blanket `#![allow(clippy::disallowed_types, disallowed_methods, disallowed_macros)]` to opt out of vite_str/vite_path rules, but this also silenced generic rules like HashMap→FxHashMap and cow_utils. Replace the blanket allows with a dedicated `.non-vite.clippy.toml` that keeps generic rules but omits vite-specific ones. Each non-vite crate gets a symlinked `.clippy.toml` pointing to the shared config. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 846885e commit bd0685e

41 files changed

Lines changed: 64 additions & 164 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.non-vite.clippy.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Clippy configuration for non-vite crates (fspy_*, subprocess_test, vite_pty, etc.)
2+
# that don't depend on vite_str/vite_path.
3+
#
4+
# This is a subset of the root .clippy.toml, with rules recommending vite_str/vite_path
5+
# alternatives removed. Generic rules (cow_utils, rustc-hash) still apply.
6+
#
7+
# To use: symlink as `.clippy.toml` in the crate's directory:
8+
# ln -s ../../.non-vite.clippy.toml .clippy.toml
9+
10+
avoid-breaking-exported-api = false
11+
12+
disallowed-methods = [
13+
{ path = "str::to_ascii_lowercase", reason = "To avoid memory allocation, use `cow_utils::CowUtils::cow_to_ascii_lowercase` instead." },
14+
{ path = "str::to_ascii_uppercase", reason = "To avoid memory allocation, use `cow_utils::CowUtils::cow_to_ascii_uppercase` instead." },
15+
{ path = "str::to_lowercase", reason = "To avoid memory allocation, use `cow_utils::CowUtils::cow_to_lowercase` instead." },
16+
{ path = "str::to_uppercase", reason = "To avoid memory allocation, use `cow_utils::CowUtils::cow_to_uppercase` instead." },
17+
{ path = "str::replace", reason = "To avoid memory allocation, use `cow_utils::CowUtils::cow_replace` instead." },
18+
{ path = "str::replacen", reason = "To avoid memory allocation, use `cow_utils::CowUtils::cow_replacen` instead." },
19+
]
20+
21+
disallowed-types = [
22+
{ path = "std::collections::HashMap", reason = "Use `rustc_hash::FxHashMap` instead, which is typically faster." },
23+
{ path = "std::collections::HashSet", reason = "Use `rustc_hash::FxHashSet` instead, which is typically faster." },
24+
]

Cargo.lock

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/fspy/.clippy.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.non-vite.clippy.toml

crates/fspy/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ futures-util = { workspace = true }
1616
libc = { workspace = true }
1717
ouroboros = { workspace = true }
1818
rand = { workspace = true }
19+
rustc-hash = { workspace = true }
1920
tempfile = { workspace = true }
2021
thiserror = { workspace = true }
2122
tokio = { workspace = true, features = ["net", "process", "io-util", "sync", "rt"] }

crates/fspy/build.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
#![allow(
2-
clippy::disallowed_types,
3-
clippy::disallowed_methods,
4-
clippy::disallowed_macros,
5-
reason = "non-vite crate"
6-
)]
7-
81
use std::{
92
env::{self, current_dir},
103
fs,

crates/fspy/examples/cli.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
#![allow(
2-
clippy::disallowed_types,
3-
clippy::disallowed_methods,
4-
clippy::disallowed_macros,
5-
reason = "non-vite crate"
6-
)]
7-
81
use std::{env::args_os, ffi::OsStr, path::PathBuf, pin::Pin};
92

103
use tokio::{

crates/fspy/src/command.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use std::{
2-
collections::HashMap,
32
ffi::{OsStr, OsString},
43
path::{Path, PathBuf},
54
process::Stdio,
65
};
76

87
#[cfg(unix)]
98
use fspy_shared_unix::exec::Exec;
9+
use rustc_hash::FxHashMap;
1010
use tokio::process::Command as TokioCommand;
1111

1212
use crate::{SPY_IMPL, TrackedChild, error::SpawnError};
@@ -15,7 +15,7 @@ use crate::{SPY_IMPL, TrackedChild, error::SpawnError};
1515
pub struct Command {
1616
program: OsString,
1717
args: Vec<OsString>,
18-
envs: HashMap<OsString, OsString>,
18+
envs: FxHashMap<OsString, OsString>,
1919
cwd: Option<PathBuf>,
2020
#[cfg(unix)]
2121
arg0: Option<OsString>,
@@ -37,7 +37,7 @@ impl Command {
3737
Self {
3838
program: program.as_ref().to_os_string(),
3939
args: Vec::new(),
40-
envs: HashMap::new(),
40+
envs: FxHashMap::default(),
4141
cwd: None,
4242
#[cfg(unix)]
4343
arg0: None,

crates/fspy/src/lib.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
#![cfg_attr(target_os = "windows", feature(windows_process_extensions_main_thread_handle))]
22
#![feature(once_cell_try)]
3-
#![allow(
4-
clippy::disallowed_types,
5-
clippy::disallowed_methods,
6-
clippy::disallowed_macros,
7-
reason = "non-vite crate"
8-
)]
93

104
// Persist the injected DLL/shared library somewhere in the filesystem.
115
mod artifact;

crates/fspy/tests/node_fs.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
#![allow(
2-
clippy::disallowed_types,
3-
clippy::disallowed_methods,
4-
clippy::disallowed_macros,
5-
reason = "non-vite crate"
6-
)]
7-
81
mod test_utils;
92

103
use std::{

crates/fspy/tests/oxlint.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
#![allow(
2-
clippy::disallowed_types,
3-
clippy::disallowed_methods,
4-
clippy::disallowed_macros,
5-
reason = "non-vite crate"
6-
)]
7-
81
mod test_utils;
92

103
use std::{env::vars_os, ffi::OsString};

0 commit comments

Comments
 (0)