From a329bca16b1ea0cdabd92b7de509e5f7c8191b1b Mon Sep 17 00:00:00 2001 From: Taimoor Zaeem Date: Mon, 22 Dec 2025 19:36:11 +0500 Subject: [PATCH] nix: add config file for hlint Adds a config file for hlint containing arguments and custom warnings. Signed-off-by: Taimoor Zaeem --- nix/tools/style.nix | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/nix/tools/style.nix b/nix/tools/style.nix index 4e1c2186a..ce1d74982 100644 --- a/nix/tools/style.nix +++ b/nix/tools/style.nix @@ -12,6 +12,7 @@ , silver-searcher , statix , stylish-haskell +, writeText }: let style = @@ -51,6 +52,20 @@ let ${git}/bin/git diff-index --exit-code HEAD -- '*.hs' '*.lhs' '*.nix' '*.py' ''; + hlintConfig = writeText "hlintConfig.yml" '' + + # Arguments passed to hlint + - arguments: [-j, -XQuasiQuotes, -XNoPatternSynonyms] + + # Warnings + - warn: { lhs: "a == a", rhs: "True", note: "This comparison always evaluates to True" } + - warn: { lhs: "a /= a", rhs: "False", note: "This comparison always evaluates to False" } + - warn: { lhs: "a < a", rhs: "False", note: "This comparison always evaluates to False" } + - warn: { lhs: "a > a", rhs: "False", note: "This comparison always evaluates to False" } + - warn: { lhs: "a <= a", rhs: "True", note: "This comparison always evaluates to True" } + - warn: { lhs: "a >= a", rhs: "True", note: "This comparison always evaluates to True" } + ''; + lint = checkedShellScript { @@ -79,7 +94,7 @@ let echo "Linting Haskell files..." # --vimgrep fixes a bug in ag: https://github.com/ggreer/the_silver_searcher/issues/753 ${silver-searcher}/bin/ag -l --vimgrep -g '\.l?hs$' . \ - | xargs ${hlint}/bin/hlint -j -X QuasiQuotes -X NoPatternSynonyms + | xargs ${hlint}/bin/hlint --hint=${hlintConfig} ''; in