Skip to content

Commit 741fee0

Browse files
feat: add proselint (#555)
* feat: add proselint or attempt to, since this will probably not work * fix: add proselint to tools and update lockfile * fix: correct proselint settings identifier * fix: correct proselint settings attributes * docs(fix): correct example config for proselint * fix: remove proselint migration * undo flake.lock bump --------- Co-authored-by: Sander <hey@sandydoo.me>
1 parent a548245 commit 741fee0

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

modules/hooks.nix

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,39 @@ in
13451345
};
13461346
};
13471347
};
1348+
proselint = mkOption {
1349+
description = "proselint hook";
1350+
type = types.submodule {
1351+
imports = [ hookModule ];
1352+
options.settings = {
1353+
config =
1354+
mkOption {
1355+
type = types.str;
1356+
description = "Multiline-string configuration passed as config file.";
1357+
default = "";
1358+
example = ''
1359+
{
1360+
"checks": {
1361+
"typography.diacritical_marks": false
1362+
}
1363+
}
1364+
'';
1365+
};
1366+
configPath =
1367+
mkOption {
1368+
type = types.str;
1369+
description = "Path to the config file.";
1370+
default = "";
1371+
};
1372+
flags =
1373+
mkOption {
1374+
type = types.str;
1375+
description = "Flags passed to proselint.";
1376+
default = "";
1377+
};
1378+
};
1379+
};
1380+
};
13481381
psalm = mkOption {
13491382
description = "psalm hook";
13501383
type = types.submodule {
@@ -3456,6 +3489,24 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
34563489
"${binPath} ${cmdArgs}";
34573490
types = [ "json" ];
34583491
};
3492+
proselint =
3493+
{
3494+
name = "proselint";
3495+
description = "A linter for prose.";
3496+
types = [ "text" ];
3497+
package = tools.proselint;
3498+
entry =
3499+
let
3500+
configFile = builtins.toFile "proselint-config.json" "${hooks.proselint.settings.config}";
3501+
cmdArgs =
3502+
mkCmdArgs
3503+
(with hooks.proselint.settings; [
3504+
[ (configPath != "") " --config ${configPath}" ]
3505+
[ (config != "" && configPath == "") " --config ${configFile}" ]
3506+
]);
3507+
in
3508+
"${hooks.proselint.package}/bin/proselint${cmdArgs} ${hooks.proselint.settings.flags}";
3509+
};
34593510
psalm =
34603511
{
34613512
name = "psalm";

nix/tools.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
, pkgsBuildBuild
6161
, poetry
6262
, pre-commit-hook-ensure-sops ? null
63+
, proselint
6364
, python3Packages
6465
, pyright ? nodePackages.pyright
6566
, php82Packages
@@ -150,6 +151,7 @@ in
150151
ormolu
151152
pre-commit-hook-ensure-sops
152153
poetry
154+
proselint
153155
pyright
154156
reuse
155157
revive

0 commit comments

Comments
 (0)