Expand description
Lints for applications built with RavenRS.
The compiler and Clippy know Rust, not the rules an interface must follow to stay right in every
theme, for screen readers and across rebuilds. ravenrs-lint reads the syntax tree of an
application’s sources and reports those rules the way the compiler does:
error[ravenrs::raw_color]: literal color in the interface
--> src/ui.rs:12:21
|
12 | .background(Color::rgb(0.1, 0.2, 0.3))
| ^^^^^^^^^^
|
= help: use a `Semantic` role, such as `.background(Semantic::Control)`, so it stays right in every theme§Running it
From the command line, after cargo install ravenrs-lint:
cargo ravenrs-lint # every package of the workspace that depends on RavenRS
cargo ravenrs-lint --init # recommended rustc and Clippy lints, the test below and AGENTS.mdFrom cargo test, so nothing passes while a rule is broken, with ravenrs-lint as a
dev-dependency and a file such as tests/ravenrs_lint.rs:
#[test]
fn follows_the_ravenrs_rules() {
ravenrs_lint::assert_clean();
}§Configuring it
Levels follow Cargo’s [lints]: allow, warn or deny. They go in the package’s or the
workspace’s metadata, and the package wins:
[package.metadata.ravenrs-lint]
language = "pt-BR" # how button captions are checked: "en" (default) or "pt-BR"
extra-verbs = ["Ok"] # first words accepted as verbs besides the built-in ones
[package.metadata.ravenrs-lint.lints]
off_grid_spacing = "deny"A single place is excused with a comment that says why, on the same line or on its own line right above:
// ravenrs-lint: allow(raw_color) the church's logo keeps its brand color in every themeallow-file(...) excuses the whole file. Test code (#[test], #[cfg(test)]) is not checked.
The rules are listed in Lint.
Structs§
- Config
- The configuration of one package.
- Diagnostic
- One broken rule at one place in a source file.
- Init
Report - What
initdid. - Package
- One package of the workspace.
Enums§
- Error
- Why a check could not run.
- Language
- The language of the interface’s text, for the checks that read it.
- Level
- How a broken rule is reported, as in Cargo’s
[lints]. - Lint
- A rule
ravenrs-lintchecks. Every rule isdenyunless the configuration lowers it, and lowering one toallowneeds a reason.
Functions§
- assert_
clean - Checks the package whose tests are running and panics with every diagnostic, warnings
included, the way
cargo clippy -- -D warningsfails. Call it from a#[test]. - check_
dir - Checks every
.rsfile underdir, in a stable order. Paths in the diagnostics are relative tobasewhen they are inside it. - check_
package - Checks the sources of one package: the directories of its library and binaries.
- check_
source - Checks one source file.
fileis only used in the diagnostics. - init
- Prepares the package in
dirfor the strict rules. Running it again updates the agents’ block and leaves the rest as it is. - packages
- The packages of the workspace that
manifestbelongs to. - recommended_
clippy - The
clippy.tomlinitwrites. - recommended_
lints - The
[lints]tablesinitwrites. - render
- The diagnostics as the compiler would print them, followed by a summary line when
summary. - render_
json - One JSON object per line, for editors and agents.