git-hooks.nix icon indicating copy to clipboard operation
git-hooks.nix copied to clipboard

typos improvements

Open bmrips opened this issue 8 months ago • 3 comments

This PR comprises three changes to the typos hook:

  • Use structured configuration by making typos.settings.configuration an attrs. This change is not backwards compatible.
  • Add the typos.settings.force-exclude option that maps to typos' --force-exclude argument. In addition, enable it by default since you expect exclude globs set via the --exclude CLI option or the configuration file's [files.extend-exclude] option to be effective.
  • Enable multiple exclusion patterns in typos.settings.exclude.

bmrips avatar Apr 13 '25 06:04 bmrips

  • Add the typos.settings.force-exclude option that maps to typos' --force-exclude argument. In addition, enable it by default since you expect exclude globs set via the --exclude CLI option or the configuration file's [files.extend-exclude] option to be effective.

🎉 , I was wondering why this didn't behave as expected

joscha avatar May 06 '25 14:05 joscha

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?

srid avatar May 31 '25 22:05 srid

Note that --exclude *.nix part. 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.

bmrips avatar May 31 '25 23:05 bmrips

Been using this PR, it works great.

srid avatar Jul 14 '25 20:07 srid