typos improvements
This PR comprises three changes to the typos hook:
- Use structured configuration by making
typos.settings.configurationan attrs. This change is not backwards compatible. - Add the
typos.settings.force-excludeoption that maps to typos'--force-excludeargument. In addition, enable it by default since you expect exclude globs set via the--excludeCLI option or the configuration file's[files.extend-exclude]option to be effective. - Enable multiple exclusion patterns in
typos.settings.exclude.
- Add the
typos.settings.force-excludeoption that maps to typos'--force-excludeargument. In addition, enable it by default since you expect exclude globs set via the--excludeCLI option or the configuration file's[files.extend-exclude]option to be effective.
🎉 , I was wondering why this didn't behave as expected
I find a strange behaviour when using this PR.
For this setting,
settings.exclude = [
"*.nix"
".hlint.yaml"
];
it generates a YAML with the following CLI:
❯ rg bin/typos .pre-commit-config.yaml
101: "entry": "/nix/store/n97528zsiq2yshvfq5whl4xpbydlnddl-typos-1.32.0/bin/typos --config /nix/store/0my2fa9n84gy2jk0wlclww22xzwckw0l-typos-config.toml --exclude *.nix --force-exclude",
Note that --exclude *.nix part. Somehow only the first exclude entry (*.nix) is being used, the rest (.hlint.yaml) is ignored.
But I'd think that the following use of map should have included all entries:
excludeFlags = lib.map (glob: "--exclude ${glob}") exclude;
Is this something to do with the use of coercedTo?
Note that
--exclude *.nixpart. Somehow only the first exclude entry (*.nix) is being used, the rest (.hlint.yaml) is ignored.
Thank you for the notification! It turned out that mkCmdArgs only considers the first and second items of the list, such that following items are ignored. Should be fixed now.
Been using this PR, it works great.