Expand description
Opt-in lint rules, schema checks and verified fixes for adotenv documents.
The linter is deliberately separate from the parser. A lint finding is
policy, not a parse error, and every suggested fix is applied through
adotenv’s verified edit or format APIs.
The default rule set reports duplicate keys only. Enable ordering, key
case, quoting, whitespace, or Schema / .env.example rules explicitly
through LintOptions, lint_with_schema, and lint_with_options.
use adotenv_lint::{lint, LintOptions};
let doc = adotenv::parse_strict("B=2\nA=1\n").unwrap();
let defaults = lint(&doc, LintOptions::default());
assert!(defaults.is_empty());
let findings = lint(
&doc,
LintOptions::default().with_key_order(true),
);
assert_eq!(findings.len(), 1);
assert_eq!(findings[0].rule(), adotenv_lint::Rule::KeyOrder);Re-exports§
pub use config::discover_config;pub use config::load_effective_config;pub use config::parse_dialect;pub use config::parse_equals_spacing;pub use config::parse_key_case;pub use config::parse_output_format;pub use config::parse_quote_style;pub use config::ConfigError;pub use config::ConfigExplicit;pub use config::IgnoredPaths;pub use config::KeySchemaConfig;pub use config::LintConfig;pub use config::LintPolicy;pub use config::OutputFormat;pub use config::RuleSeverity;pub use config::SchemaConfig;pub use schema::KeySchema;pub use schema::Schema;pub use schema::ValueShape;
Modules§
- config
- Shared
.adotenv-lint.tomlloading, validation and policy resolution. - schema
- Opt-in schema and
.env.examplepresence-and-shape policies.
Structs§
- Batch
Result - The result of applying compatible fixes in stages.
- Edit
Options - Optional bounds for verified edits, formatting and sorting.
- Finding
- A structured lint finding.
- Lint
Options - Linter policy.
Enums§
- Fix
- A fix request for an
adotenvdocument. - FixResult
- A successfully applied fix.
- KeyCase
- The desired ASCII case for keys.
- Lint
Error - An error while applying a lint fix.
- Rule
- The policy rules understood by the linter.
Functions§
- apply_
batch - Applies renames, sorting and formatting in compatible stages.
- apply_
batch_ with_ options - Applies renames, sorting and formatting in compatible stages while
enforcing
EditOptionsoutput, reference-scan and verification limits. - apply_
fix - Applies one fix request through the document’s verified APIs.
- apply_
fix_ with_ options - Applies one fix request through the document’s bounded verified APIs.
- apply_
fixes - Applies a batch of compatible fixes in one verified operation.
- apply_
fixes_ with_ options - Applies a batch of compatible fixes in one bounded verified operation.
- lint
- Runs the configured lint rules over
document. - lint_
with_ options - Runs the configured lint rules and optional
Schemapolicy overdocument, usingedit_optionsto bound sortability verification forRule::KeyOrder. - lint_
with_ schema - Runs the configured lint rules and an opt-in
Schemapolicy overdocument.