Share clippy lints across the workspace
Assisted-by: Claude Opus 5.5 via Claude Code
change lplzqxvrsspxovoyolwxommnxwswmklo
commit ba6da5563049deb6e9c8c8355b8bb15b118f6ee6
author Alpha Chen <alpha@kejadlen.dev>
date
parent sxkwtuxp
diff --git a/AGENTS.md b/AGENTS.md
index a5202df..1cb9c78 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -53,7 +53,7 @@ frork-lua/
 ```sh
 cargo check -p frork-cli    # Type-check the CLI (workspace has mlua feature conflict)
 cargo fmt --all             # Format all code
-cargo clippy -p frork-cli   # Lint
+cargo clippy -p frork-cli   # Lint the CLI; `just clippy` also lints frork-lib and frork-lua
 cargo test -p frork-cli     # Run tests
 ```
 
@@ -77,7 +77,7 @@ just install                # cargo install --locked --path frork-cli
 - Lua integration via `mlua` with vendored Lua 5.4. The Fennel compiler is vendored as a Lua source file.
 - Filesystem operations use `fs-err` instead of `std::fs`. The `.clippy.toml` disallows bare `std::fs` types and methods so this is enforced at lint time.
 - `.clippy.toml` also bans `Iterator::for_each` and `try_for_each` — use `for` loops for side effects, and `String::from_utf8_lossy`, which silently corrupts non-UTF-8 bytes from the OS.
-- `[lints.clippy]` in `frork-cli/Cargo.toml` warns on `unwrap`, `expect`, `panic!`, slice indexing, and unchecked arithmetic. Opt out per call site with `#[allow(...)]` and a comment explaining why the invariant holds. Test code is exempt via `#![cfg_attr(test, allow(...))]`.
+- `[workspace.lints.clippy]` in the root `Cargo.toml` warns on `unwrap`, `expect`, `panic!`, slice indexing, and unchecked arithmetic; every member crate opts in via `[lints] workspace = true`. Opt out per call site with `#[allow(...)]` and a comment explaining why the invariant holds. Test code is exempt via `#![cfg_attr(test, allow(...))]`.
 - All CI checks must pass: `cargo fmt --all --check`, `cargo clippy`, `cargo test`.
 
 ## Versioning and release
diff --git a/Cargo.toml b/Cargo.toml
index d9cffd0..c2eba83 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,3 +1,11 @@
 [workspace]
 resolver = "3"
 members = ["frork-cli", "frork-lib", "frork-lua"]
+
+[workspace.lints.clippy]
+self_named_module_files = "warn"
+unwrap_used = "warn"
+expect_used = "warn"
+panic = "warn"
+indexing_slicing = "warn"
+arithmetic_side_effects = "warn"
diff --git a/frork-cli/Cargo.toml b/frork-cli/Cargo.toml
index 94e44bc..12ca939 100644
--- a/frork-cli/Cargo.toml
+++ b/frork-cli/Cargo.toml
@@ -26,10 +26,5 @@ predicates = "*"
 hegeltest = "*"
 tempfile = "*"
 
-[lints.clippy]
-self_named_module_files = "warn"
-unwrap_used = "warn"
-expect_used = "warn"
-panic = "warn"
-indexing_slicing = "warn"
-arithmetic_side_effects = "warn"
+[lints]
+workspace = true
diff --git a/frork-lib/Cargo.toml b/frork-lib/Cargo.toml
index fe7c53e..a210aa8 100644
--- a/frork-lib/Cargo.toml
+++ b/frork-lib/Cargo.toml
@@ -3,3 +3,6 @@ name = "frork-lib"
 version = "0.1.0"
 edition = "2024"
 
+[lints]
+workspace = true
+
diff --git a/frork-lua/Cargo.toml b/frork-lua/Cargo.toml
index aa8f64e..b63dcc0 100644
--- a/frork-lua/Cargo.toml
+++ b/frork-lua/Cargo.toml
@@ -3,6 +3,9 @@ name = "frork"
 version = "0.1.0"
 edition = "2024"
 
+[lints]
+workspace = true
+
 [lib]
 crate-type = ["cdylib"]
 
diff --git a/justfile b/justfile
index b8b82cf..fa41495 100644
--- a/justfile
+++ b/justfile
@@ -9,6 +9,9 @@ check:
 
 clippy:
     cargo clippy -p frork-cli --all-targets -- -D warnings
+    # frork-lib and frork (frork-lua) can be linted together — neither pulls
+    # in mlua's vendored feature, which conflicts with frork-cli's.
+    cargo clippy -p frork-lib -p frork -- -D warnings
 
 coverage:
     ./bin/coverage