Skip to main content

Crate adotenv_lint

Crate adotenv_lint 

Source
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.toml loading, validation and policy resolution.
schema
Opt-in schema and .env.example presence-and-shape policies.

Structs§

BatchResult
The result of applying compatible fixes in stages.
EditOptions
Optional bounds for verified edits, formatting and sorting.
Finding
A structured lint finding.
LintOptions
Linter policy.

Enums§

Fix
A fix request for an adotenv document.
FixResult
A successfully applied fix.
KeyCase
The desired ASCII case for keys.
LintError
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 EditOptions output, 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 Schema policy over document, using edit_options to bound sortability verification for Rule::KeyOrder.
lint_with_schema
Runs the configured lint rules and an opt-in Schema policy over document.