Custom dylint lints for init4 Rust projects.
Each lint is a standalone crate under its own directory (e.g. instrument-fields/).
Each crate has its own Cargo.toml, rust-toolchain.toml, and [workspace] -
they are not members of a shared workspace.
All lint crates are pinned to nightly-2026-03-17 for compatibility with
dylint_linting 5.0.0. The .cargo/config.toml in each crate sets the
dylint-link linker. Both cargo-dylint (5.0.0) and dylint-link (5.0.0)
must be installed to build.
.github/workflows/ci.yml- builds and tests the lint crates themselves.- Consumer repos get linting automatically via the
dylintjob ininit4tech/actionsrust-base.yml. That workflow checks out this repo, builds the lint libraries, and runs them viaDYLINT_LIBRARY_PATH. - Repos opt out by adding
[workspace.metadata.dylint] skip = trueto theirCargo.toml.
- Create a new directory at the repo root (e.g.
my-lint/). - Copy the structure from
instrument-fields/-Cargo.toml,.cargo/config.toml,rust-toolchain.toml,src/lib.rs, andui/test directory. - Use
declare_pre_expansion_lint!for lints that inspect proc-macro attributes (like#[instrument]), ordeclare_early_lint!/declare_late_lint!otherwise. - Add a UI test under
ui/and runcargo testto generate the.stderrfile (copy it from the path shown in the test failure output). - Add the new crate to
.github/workflows/ci.yml. - Add the new lint name to the
RUSTFLAGSdeny list and aDYLINT_LIBRARY_PATHentry in thedylintjob ininit4tech/actionsrust-base.yml. - Update
CLAUDE.mdandREADME.mdto document the new lint.
When changing lint behaviour, diagnostic messages, or adding new cases:
- Update
src/lib.rswith the change. - Update or add UI test cases in
ui/bare_fields.rs(or equivalent). - Rebuild (
cargo build) and re-run tests (cargo test). - The test will fail and print the path to the actual stderr - copy it over the
existing
.stderrfile, then re-runcargo testto confirm it passes. - Update
CLAUDE.mdandREADME.mdif the change affects documented behaviour.