nginx_lint_common/lib.rs
1//! Core types shared between the nginx-lint CLI and WASM plugins.
2//!
3//! This crate provides the foundational types used throughout the nginx-lint
4//! ecosystem: lint rule definitions, error reporting, configuration management,
5//! and ignore comment support.
6//!
7//! # Modules
8//!
9//! - [`linter`] — Core lint types: [`LintRule`] trait, [`LintError`], [`Severity`], [`Fix`]
10//! - [`config`] — Configuration loaded from `.nginx-lint.toml` ([`LintConfig`], [`ValidationError`])
11//! - [`ignore`] — `# nginx-lint-ignore` comment parsing and error filtering
12//! - [`docs`] — Rule documentation extraction ([`RuleDoc`])
13//!
14//! # Quick reference
15//!
16//! | Type | Purpose |
17//! |------|---------|
18//! | [`LintRule`] | Trait that every lint rule (native or WASM) implements |
19//! | [`LintError`] | A single lint diagnostic with location, severity, and optional fixes |
20//! | [`Severity`] | `Error` or `Warning` |
21//! | [`Fix`] | An auto-fix action (replace, delete, insert) |
22//! | [`LintConfig`] | Settings loaded from `.nginx-lint.toml` |
23//! | [`Linter`] | Container that holds rules and runs them against a parsed config |
24//!
25//! # Re-exports
26//!
27//! The [`parser`] module re-exports the entire [`nginx_lint_parser`] crate,
28//! giving access to [`parse_config`], [`parse_string`], and the AST types.
29
30pub mod config;
31pub mod docs;
32pub mod ignore;
33pub mod linter;
34pub mod nginx_version;
35
36// Re-export parser crate
37pub use nginx_lint_parser as parser;
38
39// Re-export commonly used types
40pub use config::{
41 Color, ColorConfig, ColorMode, IncludeConfig, LintConfig, PathMapping, ValidationError,
42};
43pub use docs::{RuleDoc, RuleDocOwned};
44pub use ignore::{
45 FilterResult, IgnoreTracker, IgnoreWarning, filter_errors, parse_context_comment,
46};
47pub use linter::{
48 Fix, LintError, LintRule, Linter, RULE_CATEGORIES, Severity, apply_fixes_to_content,
49 compute_line_starts, normalize_line_fix,
50};
51pub use nginx_lint_parser::{parse_config, parse_string, parse_string_with_errors};
52pub use nginx_version::{NginxVersion, NginxVersionParseError, format_range, is_in_range};