Skip to main content

Crate linthis

Crate linthis 

Source
Expand description

§linthis

A fast, cross-platform multi-language linting aggregator that unifies various language-specific linters under a single configuration.

§Quick Start

# Run linting and formatting on current directory
linthis

# Check specific files (lint only)
linthis -c src/main.rs

# Format only
linthis -f src/

# Output as JSON
linthis --output json

# Skip cache for fresh results
linthis --no-cache

§Features

  • Multi-language support: Rust, Python, TypeScript, JavaScript, Go, Java, C++, Objective-C, Swift, Kotlin, Lua, Dart, Shell, Ruby, PHP, Scala, C#
  • Unified configuration: Single .linthis/config.toml for all languages
  • Custom regex rules: Define project-specific lint rules
  • Plugin system: Extend with community or custom plugins
  • Git hooks integration: Pre-commit and pre-push hooks
  • Intelligent caching: Skip unchanged files for faster runs
  • Parallel processing: Leverage multiple cores for speed

§Library Usage

use linthis::{run, RunOptions, RunMode, Language};
use std::path::PathBuf;

// Run with default options (current directory)
let options = RunOptions::default();
let result = run(&options).expect("Lint run failed");

println!("Found {} issues in {} files", result.issues.len(), result.total_files);

// Custom options
let options = RunOptions {
    paths: vec![PathBuf::from("src/")],
    mode: RunMode::CheckOnly,
    languages: vec![Language::Rust],
    verbose: true,
    ..Default::default()
};
let result = run(&options).expect("Lint run failed");

§Configuration

Configuration files are loaded with the following precedence:

  1. CLI arguments (highest)
  2. Project config (.linthis/config.toml)
  3. User config (~/.linthis/config.toml)
  4. Built-in defaults (lowest)

Example configuration:

# .linthis/config.toml
excludes = ["vendor/**", "*.generated.*"]
max_complexity = 20

[rules]
disable = ["E501", "whitespace/*"]

[[rules.custom]]
code = "custom/no-todo"
pattern = "TODO|FIXME"
message = "Found TODO comment"
severity = "warning"

[rust]
max_complexity = 15

§Modules

  • config: Configuration loading and merging
  • checkers: Language-specific lint checkers
  • formatters: Language-specific code formatters
  • rules: Custom rules and rule filtering
  • plugin: Plugin system for extensions
  • cache: Result caching for performance
  • reports: Output formatting (text, JSON, SARIF)

§Error Handling

The library uses LintisError for all error types, which includes:

  • I/O errors (file access)
  • Configuration errors (invalid TOML/YAML)
  • Checker errors (tool execution failures)
  • Tool availability errors (missing linters)

Re-exports§

pub use rules::CustomRule;
pub use rules::RulesConfig;
pub use rules::SeverityOverride;
pub use utils::types::FormatResult;
pub use utils::types::LintIssue;
pub use utils::types::Severity;

Modules§

ai
AI-assisted fix suggestions module.
benchmark
Benchmark module for comparing linter/formatter performance.
cache
File-level caching for incremental checking.
checkers
Language-specific linter implementations.
cli
Thin re-export of CLI command types for use in tests and downstream crates.
complexity
Code complexity analysis module.
config
Configuration system for linthis with hierarchical precedence.
fixers
Auto-fixers for various linting issues.
formatters
Language-specific formatter implementations.
hooks
Hook and agent-plugin source resolution.
interactive
Interactive mode for reviewing lint issues one by one.
license
License compliance checking module.
lsp
LSP (Language Server Protocol) server for linthis.
plugin
Plugin system for linthis configuration management.
presets
Format presets for different coding standards.
reports
Reports and analysis module for linthis.
review
AI-powered code review module.
rules
Custom rules, rule filtering, and severity overrides.
security
Security scanning module for dependency vulnerability detection.
self_update
Self-update functionality for linthis itself.
templates
Template generation module for linthis plugins and configurations.
tui
Terminal User Interface for watch mode.
utils
Utility modules for linthis.
watch
Watch mode for file system monitoring and auto-linting.

Structs§

Progress
Progress information for callbacks
RunOptions
Options for running linthis

Enums§

Language
Supported programming languages
LintisError
RunMode
Run mode for linthis
ToolInstallMode
Controls how missing tools are auto-installed during linting

Functions§

get_checker
Get the checker for a given language.
get_formatter_availability
Check if the formatter for a given language is available.
run
Main entry point for running linthis.

Type Aliases§

Result