git-hooks.nix
git-hooks.nix copied to clipboard
feature request: extra args for prettier
I think I need --plugin-search-dir
to use prettier-plugin-svelte
.
What I usually do is build a wrapper around prettier and create a new hook. Here is a Flake example with the TOML plugin:
{
description = "Test Flake";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.ixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = {
self,
flake-utils,
nixpkgs,
pre-commit-hooks,
}: let
supportedSystems = ["x86_64-linux"];
in
{
overlays.default = nixpkgs.lib.composeManyExtensions [
(final: prev: {
prettierWithTOML = prev.writeShellScriptBin "prettier" ''
${prev.nodePackages.prettier}/bin/prettier \
--plugin-search-dir "${prev.nodePackages.prettier-plugin-toml}/lib" \
"$@"
'';
})
];
}
// (flake-utils.lib.eachSystem supportedSystems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [self.overlays.default];
};
in {
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = with pkgs; {
prettier = {
enable = true;
entry = lib.mkForce "${prettierWithTOML}/bin/prettier --check";
types_or = ["markdown" "toml" "yaml"];
};
};
};
};
}));
}
However I can see this being added as a option.
@bbigras You should now be able to use settings.prettier.plugins
to provide paths to plugins like `prettier-plugin-svelte.
This was added in #388.
In case this does not work for you please let me know. Closing this issue for now.