pub struct LintConfig {
pub rules: HashMap<String, RuleConfig>,
pub color: ColorConfig,
pub parser: ParserConfig,
pub include: IncludeConfig,
pub target_nginx_version: Option<String>,
}Expand description
Configuration for nginx-lint loaded from .nginx-lint.toml.
Use from_file to load from a specific path, or
find_and_load to search the directory tree upward.
A default LintConfig enables all rules except those listed in
DISABLED_BY_DEFAULT.
Fields§
§rules: HashMap<String, RuleConfig>Per-rule configuration keyed by rule name (e.g. "indent", "server-tokens-enabled").
color: ColorConfigColor output settings.
parser: ParserConfigParser-level settings (e.g. additional block directives for extension modules).
include: IncludeConfigInclude resolution settings (e.g. path mappings for include directives).
target_nginx_version: Option<String>Target nginx version (e.g. "1.31.0").
When set, rules whose declared version range does not include this version are automatically skipped. Stored as a raw string so an unparseable value does not fail config loading — the linter parses it lazily and emits a single warning if invalid.
Implementations§
Source§impl LintConfig
impl LintConfig
Sourcepub const DISABLED_BY_DEFAULT: &'static [&'static str]
pub const DISABLED_BY_DEFAULT: &'static [&'static str]
Rules that are disabled by default
Sourcepub const NATIVE_RULE_NAMES: &'static [&'static str]
pub const NATIVE_RULE_NAMES: &'static [&'static str]
Native lint rules implemented directly in the top-level crate
(i.e. not packaged as plugins under plugins/builtin/).
Exposed as a pub const so the drift-detection test in the top-level
crate (tests/known_rules_drift_test.rs) can distinguish “native rule”
from “stale builtin plugin entry” without duplicating this list.
Sourcepub const KNOWN_RULE_NAMES: &'static [&'static str]
pub const KNOWN_RULE_NAMES: &'static [&'static str]
All rule names recognised by nginx-lint config validate.
This is the union of NATIVE_RULE_NAMES and
the builtin plugin names. The builtin plugin list lives in the
top-level crate (nginx-lint) as BUILTIN_PLUGIN_NAMES; because this
module is a downstream dependency it cannot reference that symbol
directly, so the two lists are kept in sync by a drift-detection unit
test in the top-level crate (tests/known_rules_drift_test.rs).
Order: native rules first, then builtin plugins in the same order as
BUILTIN_PLUGIN_NAMES so review diffs against that file are obvious.
Sourcepub fn from_file(path: &Path) -> Result<Self, ConfigError>
pub fn from_file(path: &Path) -> Result<Self, ConfigError>
Load configuration from a file
Sourcepub fn find_and_load(dir: &Path) -> Option<(Self, PathBuf)>
pub fn find_and_load(dir: &Path) -> Option<(Self, PathBuf)>
Find and load .nginx-lint.toml from the given directory or its parents.
Returns the loaded config along with the path of the config file found.
Sourcepub fn is_rule_enabled(&self, name: &str) -> bool
pub fn is_rule_enabled(&self, name: &str) -> bool
Check if a rule is enabled
Sourcepub fn rule_explicitly_configured(&self, name: &str) -> bool
pub fn rule_explicitly_configured(&self, name: &str) -> bool
Whether the user explicitly wrote a [rules.<name>] section for this
rule (irrespective of which options it contains). Used to distinguish
“explicitly enabled” from “enabled by default” when warning about
rules that fall outside the configured nginx version range.
Sourcepub fn rule_skip_version_check(&self, name: &str) -> bool
pub fn rule_skip_version_check(&self, name: &str) -> bool
Whether a rule has skip_version_check = true in its configuration.
Sourcepub fn target_nginx_version(&self) -> Option<&str>
pub fn target_nginx_version(&self) -> Option<&str>
The configured target nginx version as a raw string, if any.
Sourcepub fn get_rule_config(&self, name: &str) -> Option<&RuleConfig>
pub fn get_rule_config(&self, name: &str) -> Option<&RuleConfig>
Get the configuration for a specific rule
Sourcepub fn color_mode(&self) -> ColorMode
pub fn color_mode(&self) -> ColorMode
Get the color mode setting
Sourcepub fn additional_block_directives(&self) -> &[String]
pub fn additional_block_directives(&self) -> &[String]
Get additional block directives from config
Sourcepub fn include_path_mappings(&self) -> &[PathMapping]
pub fn include_path_mappings(&self) -> &[PathMapping]
Get include path mappings (applied in order to include patterns before resolving)
Sourcepub fn json_schema() -> Value
pub fn json_schema() -> Value
Generate the JSON Schema for the configuration file.
The schema is derived from the Rust type definitions, so it automatically stays in sync with the actual configuration structure.
Sourcepub fn include_prefix(&self) -> Option<&str>
pub fn include_prefix(&self) -> Option<&str>
Get include prefix (base directory for resolving relative include paths)
Sourcepub fn additional_contexts(&self) -> Option<&HashMap<String, Vec<String>>>
pub fn additional_contexts(&self) -> Option<&HashMap<String, Vec<String>>>
Get additional contexts for invalid-directive-context rule
Sourcepub fn directive_inheritance_excluded(&self) -> Option<&[String]>
pub fn directive_inheritance_excluded(&self) -> Option<&[String]>
Get excluded directives for directive-inheritance rule
Sourcepub fn directive_inheritance_additional(&self) -> Option<&[AdditionalDirective]>
pub fn directive_inheritance_additional(&self) -> Option<&[AdditionalDirective]>
Get additional directives for directive-inheritance rule
Sourcepub fn validate_file(path: &Path) -> Result<Vec<ValidationError>, ConfigError>
pub fn validate_file(path: &Path) -> Result<Vec<ValidationError>, ConfigError>
Validate a configuration file and return any errors
Trait Implementations§
Source§impl Debug for LintConfig
impl Debug for LintConfig
Source§impl Default for LintConfig
impl Default for LintConfig
Source§fn default() -> LintConfig
fn default() -> LintConfig
Source§impl<'de> Deserialize<'de> for LintConfig
impl<'de> Deserialize<'de> for LintConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for LintConfig
impl JsonSchema for LintConfig
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more