crate-ci / typos

Source code spell checker
Apache License 2.0
2.61k stars 104 forks source link

Extend configuration from another file #1129

Open jvacek opened 3 hours ago

jvacek commented 3 hours ago

I'd like to have the entire configuration for typos shared among multiple repositories as a base, and be able to override those options locally after inheriting.

It would be nice if there was an option in the config file to extend from another config file, much like ruff or pyright does.

Currently, for ruff, I can for example do something like this in my pyproject.toml (docs)

[tool.ruff]
extend = ".company-submodule/ruff.toml"
line-length = 150

For typos, I would expect it to look something like

[tool.typos]
extend = ".company-submodule/typos.toml"

[tool.typos.default]
locale = 'en-gb'

Where the locale inherited from the submodule's typos.toml would be overwritten by the locally declared en-gb

This would imply the following order for sourcing:

  1. Command line arguments
  2. File specified via --config PATH
  3. Search parents of specified file / directory for one of typos.toml, _typos.toml, .typos.toml, Cargo.toml, or pyproject.toml.
    1. Directly in the config file
    2. Inherited from an extended config file
jvacek commented 3 hours ago

In regards to #931, supporting something like this would allow people to write/generate their own files like false_positives.toml which they can then include/share as well, and you don't have to support some additional format for config