支持的语言¶
linthis 支持 18 种编程语言,具有自动语言检测功能。
语言支持矩阵¶
| 语言 | 检查工具 | 格式化工具 | 扩展名 |
|---|---|---|---|
| Rust | clippy | rustfmt | .rs |
| Python | ruff, pylint, flake8 | ruff, black | .py, .pyi |
| TypeScript | eslint | prettier | .ts, .tsx |
| JavaScript | eslint | prettier | .js, .jsx, .mjs, .cjs |
| Go | golangci-lint | gofmt | .go |
| Java | checkstyle | clang-format | .java |
| C | clang-tidy, cppcheck | clang-format | .c, .h |
| C++ | clang-tidy, cpplint, cppcheck | clang-format | .cpp, .cc, .cxx, .hpp, .hh, .hxx |
| Objective-C | clang-tidy | clang-format | .m, .mm |
| Swift | swiftlint | swift-format | .swift |
| Kotlin | ktlint, detekt | ktlint | .kt, .kts |
| Lua | luacheck | stylua | .lua |
| Dart | dart analyze | dart format | .dart |
| Shell | shellcheck | shfmt | .sh, .bash, .zsh, .ksh |
| Ruby | rubocop | rubocop | .rb, .rake, .gemspec |
| PHP | phpcs | php-cs-fixer | .php, .phtml |
| Scala | scalafix | scalafmt | .scala, .sc |
| C# | dotnet format | dotnet format | .cs, .csx |
语言检测¶
linthis 根据文件扩展名自动检测语言。您也可以显式指定语言:
# 自动检测(默认)
linthis
# 指定单个语言
linthis --lang python
# 指定多种语言
linthis --lang python,rust,javascript
工具安装¶
每种语言都需要安装其底层工具。点击上面的语言名称查看具体安装说明。
快速安装命令¶
# Rust
rustup component add clippy rustfmt
# Python
pip install ruff
# JavaScript/TypeScript
npm install -g eslint prettier
# Go
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# Shell
brew install shellcheck shfmt # macOS
apt install shellcheck # Ubuntu/Debian
观看演示¶
观看多语言支持视频教程,15 秒了解多语言检查。
检查工具可用性¶
使用 doctor 命令检查哪些工具可用:
linthis doctor
这将显示每种语言所需工具的状态。