Lint
A versatile linting tool with multiple interfaces: CLI, MCP (Model Context Protocol), and library.
Features
- CLI Interface: Run linting from the command line
- MCP Server: Expose linting capabilities via MCP protocol
- Library API: Use linting functionality in your Rust projects
Installation
Usage
CLI
Lint files or directories:
# Lint current directory
# `check` is an alias for `lint`
# Lint specific files
# Use glob patterns
# Specify output format (text, json, markdown, github, sarif, junit, concise, gitlab)
# --output-format is an alias for --output
# Set maximum line length
# Enable specific rules
# Use a configuration file
# Config is auto-discovered: place .lint.json in your project root
# and run lint without --config
# .gitignore patterns are automatically respected when walking directories
# Auto-fix fixable issues
# Preview fixes without writing changes
# Apply fixes but don't report remaining violations
# Auto-add suppression comments to all violations
# Ignore all suppression comments (useful for auditing)
# Ignore all ignore patterns (lint everything including node_modules)
# Watch for changes and re-lint
# Use cache to skip unchanged files
# Use a custom cache file location
# Use content-based caching (more accurate, slower)
# Only show errors (suppress warnings and infos)
# Fail if more than 10 warnings
# Disable colored output
# Add a rule to the default set
# Remove a rule from the default set
# Enable the final-newline rule
# Enable the no-mixed-line-endings rule
# Enable all built-in rules
# Enable all rules in a category
# Ignore all rules in a category
# Only lint files that have uncommitted changes (fast pre-commit hook)
# Only lint staged files
# Load a plugin rule pack
# Load multiple plugins
# Don't respect .gitignore (lint generated files too)
# Force exclude ignored files even when explicitly passed
# Disable source context in output
# List files that would be linted (without linting)
# Write JSON results to a file
# Generate SARIF output for GitHub Advanced Security
# Generate JUnit XML for CI integration
# Generate GitLab Code Quality report
# Concise one-line-per-violation output
# Show progress bar while linting (useful for large repos)
# Show violations without failing the build
# Show effective configuration after merging all sources
# Enable specific rules
# Show per-rule violation statistics
# Exclude specific paths or patterns
# Don't fail when a glob pattern doesn't match any files
# Treat warnings as errors (exit 1 on any warning)
# Exit non-zero even if all violations were fixed
# Lint code from stdin (useful for editor integrations)
|
# Validate configuration file (catches unknown rules, plugins, etc.)
# Set maximum allowed nesting depth (default: 4)
# Set maximum function length in lines (default: 50)
# Detect out-of-order imports (supports Rust, JS/TS, Python, C/C++, Go)
# List available rules
# Explain what a specific rule does
# Show version
# Generate a default configuration file
Exit codes: 0 if no issues found, 1 if any errors detected or if warnings exceed --max-warnings.
Config Extends
Share a base configuration across projects:
Values in the local config override the base. Collections like ignore_patterns, per_file_ignores, and severity_overrides are merged.
Per-Directory Configuration
Place a .lint.toml or .lint.json in any subdirectory to override settings for files in that tree:
# src/.lint.toml — stricter rules for source code
= 80
= ["line-length", "trailing-whitespace", "no-todo", "no-tabs"]
# tests/.lint.toml — relaxed rules for tests
= 120
= ["test_data"]
Per-directory configs are merged with the base config. Supported overrides: max_line_length, enabled_rules, plugins, ignore_patterns, per_file_ignores, severity_overrides.
Unused Suppression Detection
Enable the unused-suppression rule to detect suppression comments that don't actually suppress any violations (useful for cleanup after refactoring):
This reports warnings like:
Unused suppression comment: `lint: ignore=line-length`
MCP Server
Run the MCP server:
The server exposes the following tools:
lint_files: Lint specified files and return issueslist_rules: List all available linting rules
LSP Server
Run the Language Server Protocol (LSP) server for real-time diagnostics in editors:
Or install and use with your editor:
# Then configure your editor to run `lint-lsp --stdio`
Supported LSP methods:
initialize/initializedtextDocument/didOpen— lint opened files and publish diagnosticstextDocument/didChange— re-lint on change and publish diagnosticstextDocument/didClose— clear diagnosticsshutdown/exit
Pre-commit Hook
Use lint with pre-commit:
repos:
- repo: https://github.com/yingkitw/lint
rev: v0.1.3
hooks:
- id: lint
To lint only changed files (faster for large repos):
repos:
- repo: https://github.com/yingkitw/lint
rev: v0.1.3
hooks:
- id: lint
args:
To lint only staged files:
repos:
- repo: https://github.com/yingkitw/lint
rev: v0.1.3
hooks:
- id: lint
args:
Library
Use as a library in your Rust project:
use ;
Available Rules
All violations include fix suggestions to help resolve issues. Use --output text to see → help: messages, or --output markdown for **Fix**: blocks.
Universal Rules
line-length: Lines exceeding max length → break line, extract variable, or use continuationtrailing-whitespace: Trailing spaces/tabs → removeno-todo: TODO/FIXME comments → address or create tracking issue
JavaScript/TypeScript Rules
no-console-log: console.log/warn/error → use loggerno-var: var usage → use let/constmissing-semicolon: Missing semicolons
Python Rules
no-print: print() → use logging modulepython-style: PEP 8 (PascalCase classes, snake_case functions)
Go Rules
go-style: Exported functions need documentation
Java Rules
java-style: PascalCase classes, no System.out → use SLF4Jmissing-semicolon: Missing semicolons
Rust Rules
no-unwrap: .unwrap() → use ? or matchno-expect: .expect() → use ? or matchmissing-semicolon: Missing semicolons
Ruby Rules
no-puts: puts → use Loggerruby-style: CamelCase classes, attr_writer for setters
PHP Rules
no-echo: echo → use error_log or return JSON
Swift Rules
no-swift-print: print() → use OSLog
Kotlin Rules
kotlin-style: PascalCase classes, println → use slf4j
Dart Rules
no-dart-print: print() → use debugPrint or logging package
C# Rules
no-csharp-console: Console.WriteLine → use ILoggercsharp-style: PascalCase classes
Shell Rules
shell-echo-quote: Unquoted variables in echo → quote with"$VAR"
SQL Rules
sql-no-select-star: SELECT * → list explicit columns
Lua Rules
no-lua-print: print() → use logging or remove
Scala Rules
no-scala-println: println() → use slf4j
R Rules
no-r-print: print() → use message() or cat()
Zig Rules
no-zig-debug-print: std.debug.print → remove or use std.log
HTML Rules
html-no-inline-style: Inline style= → move to CSS classhtml-img-alt: img without alt → add alt for accessibility
CSS Rules
css-avoid-important: !important → increase selector specificity
Configuration
Create a custom configuration:
let config = new
.paths
.ignore_patterns
.max_line_length
.enabled_rules
.custom_rules
.output_format
.build;
Custom Rules
Define your own rules in a JSON file:
name: Unique rule identifierpattern: Regular expression to matchmessage: Error/warning messageseverity:Error,Warning, orInfosuggestion: Optional fix hintextensions: Optional list of file extensions to apply the rule to
Suppressing Rules Inline
Suppress a rule on a specific line:
let x = 5; // lint: ignore=line-length
Suppress all rules on a line:
let x = 5; // lint: ignore
Block Suppressions
Disable a rule for a block of code:
// lint: disable=line-length
const LONG_CONFIG: &str = "some very long configuration string that exceeds normal limits";
// lint: enable=line-length
Disable all rules for a block:
// lint: disable
const GENERATED_DATA: &str = "...generated content...";
// lint: enable
File-Level Ignore
Ignore all rules for an entire file (must be on the first line):
// lint: ignore-file
// This file is auto-generated
const DATA: &str = "...";
Ignore a specific rule for the entire file:
// lint: ignore-file=line-length
// Test files often have long lines
Works in any language — the suppression comment is language-agnostic.
Per-File Ignore Patterns
Disable specific rules for files matching a glob pattern via config:
Rule Severity Override
Override the default severity of any rule in your config:
Valid severities: Error, Warning, Info.
Supported File Extensions
- Rust:
.rs - JavaScript/TypeScript:
.js,.ts,.jsx,.tsx - Python:
.py - Java:
.java - Go:
.go - C/C++:
.c,.cpp,.h,.hpp - Ruby:
.rb - PHP:
.php - Swift:
.swift - Kotlin:
.kt - Dart:
.dart - C#:
.cs - Shell:
.sh,.bash - SQL:
.sql - Lua:
.lua - Scala:
.scala - R:
.r - Zig:
.zig - HTML:
.html,.htm - CSS:
.css,.scss,.sass
Output Formats
- Text: Human-readable output (default)
- Json: Machine-readable JSON format
- Markdown: Markdown-formatted output
- GitHub: GitHub Actions workflow commands (
::error file=...::...)
Benchmarking
Run the built-in performance benchmark:
This generates 100 files (500 lines each) and measures linting throughput. The linter processes multiple files in parallel using rayon for better performance on multi-core machines.
Contributing
If you find this project helpful, please consider giving it a star ⭐️
Feedback, issues, and pull requests are welcome! Feel free to open an issue for bug reports, feature requests, or questions.
License
Apache-2.0