Skip to content

Commit 1fe363c

Browse files
branchseerclaude
andauthored
chore: configure clippy rules for non-vite crates via .non-vite.clippy.toml (#151)
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 1fe363c

File tree

53 files changed

+752
-624
lines changed

Some content is hidden

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

53 files changed

+752
-624
lines changed

.clippy.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ 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::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)." },
12+
{ 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)." },
1113
]
1214

1315
disallowed-types = [

.github/workflows/ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ jobs:
6464
env:
6565
RUSTFLAGS: '-D warnings --cfg tokio_unstable' # also update .cargo/config.toml
6666

67-
- run: cargo clippy --all-targets --all-features -- -D warnings
67+
- name: Clippy
68+
id: clippy
69+
continue-on-error: true
70+
run: cargo clippy --all-targets --all-features -- -D warnings
6871

6972
# Set up node and pnpm for running tests
7073
# For x86_64-apple-darwin, use x64 node for fspy tests that verify Node.js fs accesses
@@ -87,6 +90,10 @@ jobs:
8790
- run: cargo-zigbuild test --target x86_64-unknown-linux-gnu.2.17
8891
if: ${{ matrix.os == 'ubuntu-latest' }}
8992

93+
- name: Check clippy result
94+
if: ${{ steps.clippy.outcome == 'failure' }}
95+
run: exit 1
96+
9097
fmt:
9198
name: Format and Check Deps
9299
runs-on: ubuntu-latest

.non-vite.clippy.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Clippy configuration for non-vite crates (fspy_*, subprocess_test, pty_terminal, 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+
{ 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)." },
20+
{ 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)." },
21+
]
22+
23+
disallowed-types = [
24+
{ path = "std::collections::HashMap", reason = "Use `rustc_hash::FxHashMap` instead, which is typically faster." },
25+
{ path = "std::collections::HashSet", reason = "Use `rustc_hash::FxHashSet` instead, which is typically faster." },
26+
]

CLAUDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ Test fixtures and snapshots:
5353
cargo xtest --builder cargo-xwin --target aarch64-pc-windows-msvc -p <package> --test <test>
5454

5555
# Examples:
56-
cargo xtest --builder cargo-xwin --target aarch64-pc-windows-msvc -p vite_pty --test terminal
57-
cargo xtest --builder cargo-xwin --target aarch64-pc-windows-msvc -p vite_pty --test terminal -- resize_terminal
56+
cargo xtest --builder cargo-xwin --target aarch64-pc-windows-msvc -p pty_terminal --test terminal
57+
cargo xtest --builder cargo-xwin --target aarch64-pc-windows-msvc -p pty_terminal --test terminal -- resize_terminal
5858
```
5959

6060
3. **Cross-Platform Test Design Patterns**:
@@ -64,7 +64,7 @@ Test fixtures and snapshots:
6464
- **Unix**: SIGWINCH signals, ioctl, /dev/null, etc.
6565
- **Windows**: ConPTY, GetConsoleScreenBufferInfo, NUL, etc.
6666

67-
4. **Example**: The `vite_pty::resize_terminal` test demonstrates proper cross-platform testing:
67+
4. **Example**: The `pty_terminal::resize_terminal` test demonstrates proper cross-platform testing:
6868
- Unix: Installs SIGWINCH handler to verify signal delivery
6969
- Windows: Acknowledges synchronous ConPTY resize behavior
7070
- Both: Query terminal size using cross-platform `terminal_size` crate

0 commit comments

Comments
 (0)