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

Prettier hook running 'Successfully' but nothing formatted

Open marcusnewton opened this issue 3 years ago • 2 comments

I'm having issues getting Prettier hook working.

I see the entry in .pre-commit-config.yaml is

"/nix/store/6rq65zsjg4a07y0af936mqk7qjh7fdp7-node_prettier-2.2.1/bin/prettier --write --list-different --ignore-unknown"

For Prettier to actually do anything I would expect to specify the directory:

prettier --write --list-different --ignore-unknown .

I've attempted to specify this via the pre-commit-check config in default.nix, but this doesn't work

hooks = {
  prettier.enable = true;
  prettier.files = ".";
};

I've also tried this, but I admit I'm very bad at regex

hooks = {
  prettier.enable = true;
  prettier.files = "\\*$";
};

marcusnewton avatar Jul 06 '21 12:07 marcusnewton

cc @macalinao

domenkozar avatar Jul 08 '21 14:07 domenkozar

I have since moved to using the husky nodejs tool, but I may have confused myself since this should only run on staged files. I don't believe I was using this with any unformatted staged files. Please ignore this issue if you see this working for staged files.

marcusnewton avatar Jul 09 '21 03:07 marcusnewton