Avoid specifying `lints.workspace = true` on every crate in a workspace

Using the new workspace-level [lints] table feature, it looks like I have to add this to the Cargo.toml of every crate in my workspace (and if I don't, it silently doesn't apply the workspace-level selections):

workspace = true

I work on a large codebase with many people independently adding crates, so I can't guarantee that no one else will accidentally add a crate without this bit and silently start dropping lints that are supposed to run.

Is there a way to get around this and apply to all members of the workspace automatically? Or failing that, is there a way to at least get a CI run to fail if it is removed?

1 Like

I couldn't find anything matching this while digging around, so I threw up a quick crate that checks that all crates have lints.workspace = true set, thus letting me at least fail a CI run if it's missing: https://crates.io/crates/cargo-workspace-lints

You could expand this to be a linter for a cargo workspace.

It's always annoying to have to set homepage.workspace = true and friends for every crate in a workspace. Maybe it could check the workspace Cargo.toml and ensure anything under the [workspace.package] table is either inherited or explicitly overridden by member crates.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.