HLint plugin ignores "ignore"s defined as {-# HLINT ... -#} annotations
ProofOfKeags opened this issue · comments
Your environment
VSCode, Linux, GHC 8.10.2, HLS 0.6.0
Steps to reproduce
- name a variable
test_VARIABLE_NAME
. This will generate an hlint suggestion about camelCase usage - Try any and all suggestions from https://github.com/ndmitchell/hlint/blob/master/README.md#ignoring-hints
- Observe lint error still in the window.
Expected behaviour
Ignored hlint suggestions should not have blue underlines.
Actual behaviour
Ignored hlint suggestions have blue underlines still.
I also came across this issue but for me module-wide ANN
annotations like {-# ANN module "HLint: ignore" #-}
seem to work fine.
Thanks for the report and the possible workaround.
I was thinking the fact we are using the parsed module to hlint for 8.10 (but no for 8.8.) and we were losing those annotations. But it is not hold for,at least ANN
ones
Otoh ignores in the hlint specific configuration should work, @ProofOfKeags does the config works for other elements other than ignores or you did not get to make the plugin honour the config at all?
@ProofOfKeags
I've tested a file with this contents:
module ApplyRefact where
f = (1)
camel_case = undefined
and with .hlint.yaml
one with:
- ignore: { name: "Redundant bracket" }
- ignore: { name: "Use camelCase" }
And i've got no hlint warnings about the redundant bracket or camel case, using ghc-8.10.1.
So it seems one of the suggestions from hlint README works for me.
Apologies. I was referring to "single use" ignores. I didn't try module wide or project wide ignores.
In my particular case I would like to keep the warning at the project level and ideally the module level as well but just get rid of it for that one top level diff. In theory hlint supports this.
@ProofOfKeags no worries, it is a usual setup.
I think .hlint.yaml
lets you configure hints per source file (from its readme, not tested):
- ignore: {name: Eta reduce, within: [MyModule1, MyModule2]}
I've just tried annotations in the source file and as @snowleopard noted above ANN
annotations work but HLINT
ones dont:
So the issue seems to be delimited for HLINT
source file annotations.
I found the annotations need to be qualified, if OverloadedStrings is enabled
{-# ANN module ("HLint: ignore Eta reduce" :: String) #-}
I am not sure if this triggers it. And I am pretty sure I am using these annotations in ghc-exactprint, and they work fine for me developing there.
Thanks to the recent added tests in hlint: https://github.com/haskell/haskell-language-server/blob/master/test/functional/FunctionalCodeAction.hs#L131-L142 we discover that {-#- HLINT #-}
is honoured by the plugin with ghc 8.6 and 8.8, but no 8.10
FWIW, the currently recommended form is {- HLINT ... -}
, and all other forms will trigger a HLint suggestion to change them in a future version. If we're going to write tests, I'd focus on that form.
thanks for noting it, I had added tests for the three kind of annotations, unfortunately, for some ghc versions, the recommended one does not work