name: "拼写检查器源代码
typos 是一个用于检查源代码中拼写错误的工具。它能够识别代码中的拼写问题,并提供修复建议。
安装方法:
cargo install typos-cli
使用方法:
typos
或者指定文件或目录:
typos src/
配置文件 .typos.toml 示例:
[files]
extend-exclude = ["node_modules", "target"]
[default]
extend-ignore-identifiers-re = [
".*",
]
支持的文件类型包括但不限于:
- Rust (.rs)
- Python (.py)
- JavaScript (.js, .jsx)
- TypeScript (.ts, .tsx)
- HTML (.html)
- CSS (.css)
- Markdown (.md)
更多详情请访问:https://github.com/crate-ci/typos
命令行选项:
- --help - 显示帮助信息
- --version - 显示版本信息
- --config - 指定配置文件路径
- --write-changes - 自动修复发现的错误
注意:typos 会忽略特定的标识符模式,可以通过配置文件进行自定义。
示例输出:
error: Found typo in src/main.rs:10
--> src/main.rs:10
|
10 | prinitf!("Hello, world!\n");
| ^^^^^^^^
|
= help: Did you mean `print!`?
该工具可以集成到 CI/CD 流水线中,确保代码质量。"
slug: "typos-source-code-spell-checker"
version: "1.0.0"
displayName: "拼写检查器源代码
typos 是一个用于检查源代码中拼写错误的工具。它能够识别代码中的拼写问题,并提供修复建议。
安装方法:
cargo install typos-cli
使用方法:
typos
或者指定文件或目录:
typos src/
配置文件 .typos.toml 示例:
[files]
extend-exclude = ["node_modules", "target"]
[default]
extend-ignore-identifiers-re = [
".*",
]
支持的文件类型包括但不限于:
- Rust (.rs)
- Python (.py)
- JavaScript (.js, .jsx)
- TypeScript (.ts, .tsx)
- HTML (.html)
- CSS (.css)
- Markdown (.md)
更多详情请访问:https://github.com/crate-ci/typos
命令行选项:
- --help - 显示帮助信息
- --version - 显示版本信息
- --config - 指定配置文件路径
- --write-changes - 自动修复发现的错误
- --no-ignore - 不使用 .gitignore 文件
注意:typos 会忽略以 .gitignore 中定义的模式匹配的文件。"
summary: "一个用 Rust 编写的超快速源代码拼写检查器,能够查找并纠正整个代码库中的打字错误。专为在单体仓库中运行而设计,具有最少的误报率。typos 可集成到 CI/CD 流水线、预提交钩子和编辑器工作流中。"
license: "MIT"
description: "一个用Rust编写的超快速源代码拼写检查器,能够查找并纠正整个代码库中的错别字。专为在单体仓库中运行而设计,具有最少的误报率。typos可以集成到CI/CD流水线、预提交钩子和编辑器工作流中。"
github_stars: 3864
verification: "security_reviewed"
source: "https://github.com/1991513ccie-png/skills"
category: "Code Quality & Review"
framework: "Claude Code"
tool_ecosystem:
github_repo: "1991513ccie-png/skills"
github_stars: 3864
拼写检查器源代码
typos 是一个用于检查源代码中拼写错误的工具。它能够识别代码中的拼写问题,并提供修复建议。
安装方法:
cargo install typos-cli
使用方法:
typos
或者指定文件或目录:
typos src/
配置文件示例:
[files]
extend-exclude = ["*.rs", "*.md"]
支持的语言包括:Rust, Python, JavaScript, TypeScript, Go, Java, C++, C, Objective-C, Swift, Ruby, PHP, Scala, Kotlin, Groovy, Haskell, Erlang, Elixir, Lua, Perl, R, MATLAB, SQL, HTML, CSS, JSON, YAML, TOML, XML, Shell, PowerShell, Batch, Assembly, Pascal, Ada, Fortran, COBOL, Lisp, Scheme, Clojure, F#, OCaml, D, Nim, Crystal, V, Zig, Go, Rust, Swift, Objective-C++, C#, VB.NET, Delphi, Turbo Pascal, Modula-2, Oberon, ALGOL, PL/I, APL, SNOBOL, Prolog, Mercury, Curry, Tcl, Awk, sed, grep, make, CMake, Gradle, Maven, npm, pip, gem, cargo, yarn, bower, composer, nuget, conan, vcpkg, bazel, meson, autotools, configure, Makefile, CMakeLists.txt, build.gradle, pom.xml, package.json, requirements.txt, Gemfile, Cargo.toml, pyproject.toml, go.mod, rust-toolchain.toml, .gitignore, .dockerignore, .editorconfig, .eslintrc, .prettierrc, .stylelintrc, .babelrc, .nycrc, .coveragerc, .travis.yml, .circleci/config.yml, .github/workflows/.yml, .gitlab-ci.yml, Jenkinsfile, .appveyor.yml, .codecov.yml, .codeclimate.yml, .hound.yml, .scrutinizer.yml, .codacy.yml, .lgtm.yml, .deepsource.yml, .semgrep.yml, .pre-commit-config.yaml, .commitlintrc, .lintstagedrc, .stylelintrc.js, .eslintrc.js, .prettierrc.js, .babelrc.js, .nycrc.js, .coveragerc.js, .travis.yml.js, .circleci/config.yml.js, .github/workflows/.yml.js, .gitlab-ci.yml.js, Jenkinsfile.js, .appveyor.yml.js, .codecov.yml.js, .codeclimate.yml.js, .hound.yml.js, .scrutinizer.yml.js, .codacy.yml.js, .lgtm.yml.js, .deepsource.yml.js, .semgrep.yml.js, .pre-commit-config.yaml.js, .commitlintrc.js, .lintstagedrc.js
更多详情请访问:https://github.com/crate-ci/typos
常见问题:
1. 如何忽略特定的拼写错误?
在配置文件中添加:
toml
[default.extend-words]
foo = "foo"
bar = "bar"
-
如何排除某些文件或目录?
在配置文件中添加:
toml [files] extend-exclude = ["*.rs", "*.md"] -
如何自动修复拼写错误?
使用--write-changes参数:
bash typos --write-changes -
如何在 CI 中使用?
在.github/workflows/ci.yml中添加:
yaml - name: Check spelling uses: crate-ci/typos@v1.0.0 -
如何自定义字典?
创建一个包含自定义单词的文件,并在配置中引用它:
toml [default.extend-words] custom-word = "custom-word" -
如何处理特定语言的拼写检查?
使用--language参数指定语言:
bash typos --language rust -
如何输出详细信息?
使用-v或--verbose参数:
bash typos -v -
如何只检查特定文件类型?
使用--file-types参数:
bash typos --file-types rs,py,js -
如何跳过某些目录?
使用--exclude参数:
bash typos --exclude target/ --exclude node_modules/ -
如何在 Git Hook 中使用?
创建一个 Git Hook 脚本:
bash #!/bin/sh typos
注意事项:
- 该工具会检查所有支持的语言文件
- 默认情况下,它不会修改任何文件
- 可以通过配置文件自定义行为
- 支持多种格式的配置文件(TOML, JSON, YAML)
- 可以与 CI/CD 工具集成使用
相关命令:
- typos --help - 显示帮助信息
- typos --version - 显示版本信息
- typos --write-changes - 自动修复拼写错误
- typos --ignore-words-list - 忽略特定单词列表
- typos --config - 指定配置文件路径
GitHub 仓库:https://github.com/crate-ci/typos
A blazing-fast source code spell checker written in Rust that finds and corrects typos across entire codebases. Designed to run on monorepos with minimal false positives, typos integrates into CI/CD pipelines, pre-commit hooks, and editor workflows.
Installation
Use the upstream install or setup path that matches your environment:
- $ cargo install typos-cli --locked
- $ brew install typos-cli
- $ conda install typos
Basic usage or getting-started notes:
- Fast enough to run on monorepos
- Low false positives so you can run on PRs
- Getting Started
- Source: https://github.com/1991513ccie-png/skills
- Extracted from upstream docs: https://raw.githubusercontent.com/crate-ci/typos/HEAD/README.md