In a hook, is it possible to set :clj-kondo/ignore
on the rewritten forms? e.g. if we rewrite something as a let
we don’t want clj-kondo to complain about a redundant let in the body.
@hugod In the newest clj-kondo, clj-kondo should already not complain about this anymore. Which version are you using?
The latest version is 2020.10.10
Using the version you patched to early load the cache
@hugod The current behavior should be: if any of the two nested let nodes doesn't have location metadata, there is no warning.
The replacement node (the let) that is being generated has the input node’s meta set on it - is that not the intended pattern?
if that's the outer node returned, then that's probably good. but you are generating another let inside of that?
oh I see
if the user then uses your node inside their let, it will warn. in this case, it's maybe better to leave out the location metadata
you can put an ignore on that probably, but this will disable linting for all the inside nodes as well
Almotst - the generated let
contains the body of the macro expression, which happens to be a let
yeah, same problem
when generating a let, it's probably better to not attach location metadata, as to not trigger the redundant let linter
ok, got it, thanks
What does omitting the metadata do to reported line numbers if the let binding contains a lint error/warning?
the let itself probably doesn't have warnings, if it's generated syntactically correct. when you will have unused bindings, the location of the binding symbols is used instead
to avoid those warnings you could use underscored symbols
@hugod another approach is to use let*
which also will never trigger a warning, but this is kind of undocumented behavior. I was hoping the location metadata rule was sufficient
if that turns out not to be the case, we could make this explicit using some bespoke metadata
or we could always add metadata on the generated nodes, so clj-kondo has a different way to know that the node was generated using the API
maybe that's more robust
Not adding metadata should work for now, but it might be nice not to have to think about this as a hook writer.
@hugod The check to suppress a warning is this: https://github.com/borkdude/clj-kondo/blob/b8a9bac8748999b0ea96db70c2a3cb4d1d3c27fd/src/clj_kondo/impl/analyzer.clj#L574
We could make that (:clj-kondo.impl/generated (meta node))
and then automatically add that to all the generated nodes
ok, I'll change this to make that more robust
@hugod I now pushed this change, so you can re-add your location metadata and you should not get a warning with latest master
Thank you, again!