快速开始¶
本指南将帮助您在几分钟内开始使用 linthis。
初始化配置(可选)¶
# 创建项目配置文件
linthis init
# 创建全局配置文件
linthis init -g
# 安装 pre-commit hooks
linthis hook install --type git
基本用法¶
检查和格式化¶
# 检查和格式化当前目录(默认行为)
linthis
# 检查和格式化指定目录
linthis -i src/
linthis --include src/ --include lib/
仅检查¶
# 仅检查,不格式化
linthis -c
linthis --check-only
仅格式化¶
# 仅格式化,不检查
linthis -f
linthis --format-only
Git 暂存文件¶
# 检查 Git 暂存文件(适用于 pre-commit hook)
linthis -s
linthis --staged
指定语言¶
# 检查特定语言
linthis -l python
linthis --lang rust
# 检查多种语言
linthis -l python,rust,cpp
linthis --lang "python,javascript,go"
排除文件¶
# 排除特定模式
linthis -e "*.test.js" -e "dist/**"
linthis --exclude "target/**" --exclude "node_modules/**"
输出格式¶
# 人类可读输出(默认)
linthis
# JSON 输出
linthis -o json
# GitHub Actions 格式
linthis -o github-actions
常见工作流¶
Pre-commit Hook¶
# 安装 git hook
linthis hook install --type git
# 或与 pre-commit 框架一起使用
linthis hook install --type pre-commit
CI/CD¶
# 在 CI 中,使用仅检查模式,错误时非零退出
linthis --check-only --output github-actions
观看演示¶
观看快速开始视频教程,20 秒了解基本用法。