This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-02
Channels
- # announcements (1)
- # babashka (19)
- # beginners (85)
- # calva (1)
- # cider (23)
- # clara (19)
- # clj-kondo (28)
- # clojars (4)
- # clojure (60)
- # clojure-australia (8)
- # clojure-dev (14)
- # clojure-europe (117)
- # clojure-nl (3)
- # clojure-uk (11)
- # clojurescript (68)
- # conjure (2)
- # core-async (39)
- # cryogen (11)
- # cursive (7)
- # data-science (1)
- # datomic (9)
- # emacs (10)
- # etaoin (1)
- # events (1)
- # fulcro (1)
- # helix (10)
- # jobs (4)
- # kaocha (2)
- # keechma (3)
- # leiningen (1)
- # malli (6)
- # pathom (15)
- # pedestal (10)
- # re-frame (5)
- # reitit (1)
- # remote-jobs (1)
- # rum (3)
- # shadow-cljs (18)
- # tools-deps (30)
- # vim (6)
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?
@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?
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
when generating a let, it's probably better to not attach location metadata, as to not trigger the redundant let linter
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
@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
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))