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

Extend `yamllint` hook

Open totoroot opened this issue 1 year ago • 0 comments

I added a couple of options to the yamllint hook, as so far it was only possible to pass a path to the configuration file. In some comments, I also reasoned why some options weren't added as they do not make sense for a pre-commit hook.

Similar to how I did it for the typos hook, there is now also an option to pass a multiline string as configuration to yamllint. Additionally yamllint allows for a serialized configuration, but the multiline string configuration option is the preferred way. Of course just providing a path to a configuration file remains possible.

The behaviour of the hook itself mostly stayed the same, although the relaxed option was removed in favour of a more generalized preset option, that allows us to easily add presets, should more ever be added to yamllint.

A pre-commit hook only makes sense, if it prevents you from committing if errors were found, so --strict should definitely be the default.

Breaking changes:

  • settings.yamllint.relaxed = true; is now settings.yamllint.preset = "relaxed";
  • settings.yamllint.strict was added and defaults to true :arrow_right: strict error checking for hook

Additional changes:

For some hooks I recently worked on, I noticed that I was shadowing the top-level attribute config, which is never a good idea, so I changed the multiline configuration options to configuration. Affected hooks are typos and vale. The options were only added recently.

totoroot avatar Feb 16 '24 11:02 totoroot