Skip to content

typos

GitHub stars formatter sarif GitHub release (latest SemVer) GitHub last commit GitHub commit activity GitHub contributors

typos is a fast source-code spell checker written in Rust that catches low-false-positive spelling mistakes across codebases and monorepos.

Key Features:

  • Low False Positives: Targets unambiguous common misspellings in identifiers, comments, strings, and filenames
  • Opt-In Auto-Fix Support: Auto-fix (--write-changes) is disabled by default (APPLY_FIXES defaults to none), even when SPELL_TYPOS is active; when explicitly enabled via APPLY_FIXES, it corrects unambiguous typos in-place while reporting ambiguous cases (review identifier fixes carefully if code defines external API contracts)
  • Blazing Fast: Built in Rust for monorepo-scale repositories with negligible CI overhead
  • Flexible Configuration: Supports typos.toml, _typos.toml, .typos.toml, pyproject.toml, and Cargo.toml

To be active within MegaLinter, a configuration file (typos.toml, _typos.toml, or .typos.toml) must be present in your repository or in LINTER_RULES_PATH.

typos documentation

typos - GitHub

Configuration in MegaLinter

Variable Description Default value
SPELL_TYPOS_ARGUMENTS User custom arguments to add in linter CLI call
Ex: -s --foo "bar"
SPELL_TYPOS_COMMAND_REMOVE_ARGUMENTS User custom arguments to remove from command line before calling the linter
Ex: -s --foo "bar"
SPELL_TYPOS_FILTER_REGEX_INCLUDE Custom regex including filter
Ex: (src\|lib)
⚠️ Not available with SPELL_TYPOS_CLI_LINT_MODE = project
Exclude no file
SPELL_TYPOS_FILTER_REGEX_EXCLUDE Custom regex excluding filter
Ex: (test\|examples)
⚠️ Not available with SPELL_TYPOS_CLI_LINT_MODE = project
Exclude no file
SPELL_TYPOS_CLI_LINT_MODE Override default CLI lint mode
- file: Calls the linter for each file
- list_of_files: Call the linter with the list of files as argument
- project: Call the linter from the root of the project
list_of_files
SPELL_TYPOS_FORWARD_EXCLUDED_DIRECTORIES In project CLI lint mode, forward excluded directories (EXCLUDED_DIRECTORIES + ADDITIONAL_EXCLUDED_DIRECTORIES, and .gitignored directories when IGNORE_GITIGNORED_FILES is true) to the linter through its native exclusion arguments or generated ignore/config files true
SPELL_TYPOS_FILE_EXTENSIONS Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all files
Ex: [".py", ""]
Exclude every file
SPELL_TYPOS_FILE_NAMES_REGEX File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files
Ex: ["Dockerfile(-.+)?", "Jenkinsfile"]
Include every file
SPELL_TYPOS_PRE_COMMANDS List of bash commands to run before the linter None
SPELL_TYPOS_POST_COMMANDS List of bash commands to run after the linter None
SPELL_TYPOS_UNSECURED_ENV_VARIABLES List of env variables explicitly not filtered before calling SPELL_TYPOS and its pre/post commands None
SPELL_TYPOS_CONFIG_FILE typos configuration file name
Use LINTER_DEFAULT to let the linter find it
typos.toml
SPELL_TYPOS_RULES_PATH Path where to find linter configuration file Workspace folder, then MegaLinter default rules
SPELL_TYPOS_DISABLE_ERRORS Run linter but consider errors as warnings true
SPELL_TYPOS_DISABLE_ERRORS_IF_LESS_THAN Maximum number of errors allowed 0
SPELL_TYPOS_TIMEOUT_SECONDS Maximum duration in seconds of the linter run, after which the linter process and its child processes are killed and reported as an error (exit code 124). Overrides LINTER_TIMEOUT_SECONDS. 0 disables the timeout 300
SPELL_TYPOS_CLI_EXECUTABLE Override CLI executable ['typos']

IDE Integration

Use typos in your favorite IDE to catch errors before MegaLinter !

IDE Extension Name Install
Visual Studio Code Typos spell checker Install in VSCode

MegaLinter Flavors

This linter is available in the following flavors

Flavor Description Embedded linters Info
all Default MegaLinter Flavor 135 Docker Image Size (tag) Docker Pulls
c_cpp Optimized for pure C/C++ projects 60 Docker Image Size (tag) Docker Pulls
cupcake MegaLinter for the most commonly used languages 100 Docker Image Size (tag) Docker Pulls
documentation MegaLinter for documentation projects 53 Docker Image Size (tag) Docker Pulls
dotnet Optimized for C, C++, C# or VB based projects 67 Docker Image Size (tag) Docker Pulls
dotnetweb Optimized for C, C++, C# or VB based projects with JS/TS 82 Docker Image Size (tag) Docker Pulls
formatters Contains only formatters 21 Docker Image Size (tag) Docker Pulls
go Optimized for GO based projects 55 Docker Image Size (tag) Docker Pulls
java Optimized for JAVA based projects 58 Docker Image Size (tag) Docker Pulls
javascript Optimized for JAVASCRIPT or TYPESCRIPT based projects 69 Docker Image Size (tag) Docker Pulls
php Optimized for PHP based projects 58 Docker Image Size (tag) Docker Pulls
python Optimized for PYTHON based projects 71 Docker Image Size (tag) Docker Pulls
ruby Optimized for RUBY based projects 54 Docker Image Size (tag) Docker Pulls
rust Optimized for RUST based projects 54 Docker Image Size (tag) Docker Pulls
salesforce Optimized for Salesforce based projects 59 Docker Image Size (tag) Docker Pulls
swift Optimized for SWIFT based projects 54 Docker Image Size (tag) Docker Pulls
terraform Optimized for TERRAFORM based projects 58 Docker Image Size (tag) Docker Pulls

Behind the scenes

How are identified applicable files

  • Activated only if one of these files is found: typos.toml, _typos.toml, .typos.toml
  • If this linter is active, all files linted by all other active linters will be linted

How the linting is performed

typos is called once on the whole project directory (project CLI lint mode)

  • filtering can not be done using MegaLinter configuration variables,it must be done using typos configuration or ignore file (if existing)
  • VALIDATE_ALL_CODEBASE: false doesn't make typos analyze only updated files

Example calls

typos
typos --config typos.toml myfile.py
typos --write-changes myfile.md

Help content

Source Code Spelling Correction

Usage: typos [OPTIONS] [PATH]...

Arguments:
  [PATH]...  Paths to check (`-` to check stdin) [default: .]

Options:
      --file-list <FILE_LIST>  Read the list of newline separated paths from file or stdin (if `-`)
  -j, --threads <THREADS>      The approximate number of threads to use [default: 0]
      --sort                   Sort results
      --force-exclude          Respect excluded files even for paths passed explicitly
  -h, --help                   Print help
  -V, --version                Print version

Config:
  -c, --config <CUSTOM_CONFIG>  Custom config file
      --isolated                Ignore implicit configuration files
      --exclude <GLOB>          Ignore files & directories matching the glob
      --hidden                  Search hidden files and directories
      --no-ignore               Don't respect ignore files
      --no-ignore-dot           Don't respect .ignore files
      --no-ignore-global        Don't respect global ignore files
      --no-ignore-parent        Don't respect ignore files in parent directories
      --no-ignore-vcs           Don't respect ignore files in vcs directories
      --binary                  Search binary files
      --no-check-filenames      Skip verifying spelling in file names
      --no-check-files          Skip verifying spelling in files
      --no-unicode              Only allow ASCII characters in identifiers
      --locale <LOCALE>         Language locale to suggest corrections for [possible values: en, en-us, en-gb, en-ca, en-au]

Mode:
      --diff                       Print a diff of what would change
  -w, --write-changes              Write fixes out
      --files                      Debug: Print each file that would be spellchecked
      --file-types                 Debug: Print each file's type
      --highlight-identifiers      Debug: Print back out files, stylizing identifiers that would be spellchecked
      --identifiers                Debug: Print each identifier that would be spellchecked
      --highlight-words            Debug: Print back out files, stylizing words that would be spellchecked
      --words                      Debug: Print each word that would be spellchecked
      --dump-config <DUMP_CONFIG>  Write the current configuration to file with `-` for stdout
      --type-list                  Show all supported file types

Output:
      --format <FORMAT>  Render style for messages [default: long] [possible values: silent, brief, long, json, sarif]
      --color <WHEN>     Controls when to use color [default: auto] [possible values: auto, always, never]
  -v, --verbose...       Increase logging verbosity
  -q, --quiet...         Decrease logging verbosity

Installation on mega-linter Docker image

  • Dockerfile commands :
    # renovate: datasource=github-releases depName=crate-ci/typos extractVersion=^v(?<version>.+)$
    ARG SPELL_TYPOS_VERSION=1.52.0
    RUN case "${TARGETARCH}" in \
          amd64) TYPOS_ARCH="x86_64" ;; \
          arm64) TYPOS_ARCH="aarch64" ;; \
          *) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;; \
        esac && \
        curl -fsSL "https://github.com/crate-ci/typos/releases/download/v${SPELL_TYPOS_VERSION}/typos-v${SPELL_TYPOS_VERSION}-${TYPOS_ARCH}-unknown-linux-musl.tar.gz" \
        | tar -xz -C /usr/local/bin ./typos && \
        chmod +x /usr/local/bin/typos
    

Installation without Docker (native mode)

This linter can run without Docker, see native mode.

  • Install method: Verified release download
NATIVE_LINTERS: [SPELL_TYPOS]
Platform Support
Linux (x86-64) ✅
Linux (ARM64) ✅
macOS (Intel) ✅
macOS (Apple Silicon) ✅
Windows (Git Bash) ✅
INSTALL_DIR="$HOME/.megalinter/linters/SPELL_TYPOS"
mkdir -p "$INSTALL_DIR"
curl -fsSL -o "$INSTALL_DIR/typos-v1.52.0-x86_64-unknown-linux-musl.tar.gz" https://github.com/crate-ci/typos/releases/download/v1.52.0/typos-v1.52.0-x86_64-unknown-linux-musl.tar.gz &&
  tar -xzf "$INSTALL_DIR/typos-v1.52.0-x86_64-unknown-linux-musl.tar.gz" -C "$INSTALL_DIR" &&
  rm "$INSTALL_DIR/typos-v1.52.0-x86_64-unknown-linux-musl.tar.gz" &&
  export PATH="$INSTALL_DIR:$PATH"
INSTALL_DIR="$HOME/.megalinter/linters/SPELL_TYPOS"
mkdir -p "$INSTALL_DIR"
curl -fsSL -o "$INSTALL_DIR/typos-v1.52.0-aarch64-unknown-linux-musl.tar.gz" https://github.com/crate-ci/typos/releases/download/v1.52.0/typos-v1.52.0-aarch64-unknown-linux-musl.tar.gz &&
  tar -xzf "$INSTALL_DIR/typos-v1.52.0-aarch64-unknown-linux-musl.tar.gz" -C "$INSTALL_DIR" &&
  rm "$INSTALL_DIR/typos-v1.52.0-aarch64-unknown-linux-musl.tar.gz" &&
  export PATH="$INSTALL_DIR:$PATH"
INSTALL_DIR="$HOME/.megalinter/linters/SPELL_TYPOS"
mkdir -p "$INSTALL_DIR"
curl -fsSL -o "$INSTALL_DIR/typos-v1.52.0-x86_64-apple-darwin.tar.gz" https://github.com/crate-ci/typos/releases/download/v1.52.0/typos-v1.52.0-x86_64-apple-darwin.tar.gz &&
  tar -xzf "$INSTALL_DIR/typos-v1.52.0-x86_64-apple-darwin.tar.gz" -C "$INSTALL_DIR" &&
  rm "$INSTALL_DIR/typos-v1.52.0-x86_64-apple-darwin.tar.gz" &&
  export PATH="$INSTALL_DIR:$PATH"
INSTALL_DIR="$HOME/.megalinter/linters/SPELL_TYPOS"
mkdir -p "$INSTALL_DIR"
curl -fsSL -o "$INSTALL_DIR/typos-v1.52.0-aarch64-apple-darwin.tar.gz" https://github.com/crate-ci/typos/releases/download/v1.52.0/typos-v1.52.0-aarch64-apple-darwin.tar.gz &&
  tar -xzf "$INSTALL_DIR/typos-v1.52.0-aarch64-apple-darwin.tar.gz" -C "$INSTALL_DIR" &&
  rm "$INSTALL_DIR/typos-v1.52.0-aarch64-apple-darwin.tar.gz" &&
  export PATH="$INSTALL_DIR:$PATH"
INSTALL_DIR="$HOME/.megalinter/linters/SPELL_TYPOS"
mkdir -p "$INSTALL_DIR"
curl -fsSL -o "$INSTALL_DIR/typos-v1.52.0-x86_64-pc-windows-msvc.zip" https://github.com/crate-ci/typos/releases/download/v1.52.0/typos-v1.52.0-x86_64-pc-windows-msvc.zip &&
  unzip -q "$INSTALL_DIR/typos-v1.52.0-x86_64-pc-windows-msvc.zip" -d "$INSTALL_DIR" &&
  rm "$INSTALL_DIR/typos-v1.52.0-x86_64-pc-windows-msvc.zip" &&
  export PATH="$INSTALL_DIR:$PATH"

Comments