One of the things I'm playing around with is using this style of destructuring:
(defn foo
[{:keys [bar baz] :as config}]
...
...do something with bar
...do something with baz
...)
As you notice, config
is not being used, however, it is useful for documenting, as pointed out elsewhere ...two fns that look superficially similar can be immediately distinguished [by looking at the :as]
Current clj-kondo flags config
as not being used. I know I could put an unused var escape before the form or globally, but that's overkill (globally) or noise (individually for each form)
Could clj-kondo have a configuration to ignore unused binding for :as
?
@dharrigan There is a recent issue for this.
oooh
<https://github.com/borkdude/clj-kondo/issues/1016>
right
for now the way to do this is to use :as _the-name
or :as #_:clj-kondo/ignore the-name
but this needs fixing
I'm sorta in agreement with the OP, using _
is a bit aesthetically out of place
yeah well, PR welcome. :)
🙂
if nobody will do a PR, I'll probably fix it relatively soon
since I'm getting paid for it by CT ;)
w00t! 🙂
I'll try to look (understand) the code base myself today to see if I can contribute
Let me mark this for the next release
OK
but um, don't wait for me 🙂
A hint: look in analyzer.clj in extract-bindings
👌
What would the lint-as equivalent be for this macro template/fn
?
; (template/fn args source)
; Example:
(def hello
(template/fn [name] "Hello <%= name %>"))
(hello "Alice")
https://github.com/weavejester/comb
I tried defn but defn has a function name before the argsprobably clojure.core/fn
but you will get unused bindings with that, since kondo doesn't know about this macro
you can suppress those with #_:clj-kondo/ignore[:unused-binding]
before the (template/fn ...)
call
I'm still new to clojure, but is it not possible to lint macros automatically without supporting them on a case by case basis
clj-kondo doesn't execute your code, so it can't know what your macro does, which is the fundamental problem
there are approaches that execute your code, but they aren't generally suited for editor integration because they are too slow
also these approaches tend to launch missiles
Is it possible to do something like this:
{:linters {:unused-binding {:exclude [comb.template/fn]}}}
I tried this in my config.edn but it doesn't seem to be workingAlas, that's not yet supported. Feel free to make an issue