Regression 1.23.4 -> 1.23.5+. `Cargo.toml` file stopped being checked for typos
Take this Cargo.toml file as an example (yes, it's not a valid cargo config, but just an example):
key = "compliation"
wher = 32
Make sure the file is named Cargo.toml exactly. If you run typos of version 1.23.5+ (including the latest one 1.26.0) against this file it won't produce any errors. Even if you run typos ./Cargo.toml by specifying the path to the file explicitly it still doesn't work.
Looks like the feature of storing the typos config in Cargo.toml broke its typos checking (release 1.23.5).
With the older version 1.23.4 everything works fine:
error: `compliation` should be `compilation`
--> ./Cargo.toml:1:8
|
1 | key = "compliation"
| ^^^^^^^^^^^
|
error: `wher` should be `where`, `were`
--> ./Cargo.toml:2:1
|
2 | wher = 32
| ^^^^
|
Hmm, this leads to competing needs.
Config files can define new invalid words. When we check a config file, it'll report those as invalid. So we skip checking of config files. As we add new config files (pyproject.toml, Cargo.toml), that means we won't be checking those file types anymore.
If Cargo.toml doesn't contain any typos config section it should definitely be checked for typos. This can be used as a low-effort heuristic that will just reduce the scope of the problem.
But if there is a typos config and it configures new invalid words then it's more complex and typos needs to track the span of the invalid word to avoid reporting it if the span is equal to the span of the word from the config. Won't there be a problem with hierarchical config here though? Maybe typos could be a bit less granular and avoid checking any text that overlaps with the span of any typos config?
I don't think I want to go to the degree of span tracking.
I don't think I also want to do it based on whether the file has the section or not.
What might work is limiting the check to only the config we load.
While I think this is a reasonable default for .typos.toml files, I think not checking Cargo.toml and pyproject.toml is a severe footgun.
Even worse, there is no way to override this behavior. This means this issue also occurs when using typos-lsp. A force-check = ["glob"] option or force-check-configs = ["Cargo.toml"] would be nice to have a way to override this default.