1 unstable release
0.1.0 | Jan 12, 2023 |
---|
#519 in Cargo plugins
5KB
60 lines
cargo-nag: experimental toolkit for writing custom Rust linters
How to write lints?
Use nag-toolkit library, call declare_lints!()
macro and export resulting ::register()
function: see example-nag-linter/src/lints.rs as an example.
You can provide a crate with lints for the users of your library or just write them in the same crate as your linter.
nightly-rustc documentation, especially part about LateLintPass is extremely useful when writing lints.
How to write a linter?
Use nag-driver library, call nag_driver::run()
or nag_driver::Driver::with_callback()
and then .run()
: see example-nag-linter/src/main.rs as an example.
How to use a linter?
Install cargo-nag
binary. Set CARGO_NAG_LINTER_DIR
environment variable to the absolute path to your linter source code, then run cargo nag
.
It will compile and run a linter for you.
Dependencies
~4–10MB
~104K SLoC