I’m about to release a new version of clj-kondo this weekend with detection for unused bindings (function arguments, let bindings, etc.) I’d appreciate it if someone would test this, since I refactored quite a bit of code…. So if you’re bored… 🙂 The binaries for Mac and Linux can be found at the top comment in this issue: https://github.com/borkdude/clj-kondo/issues/173
The only thing that confuses me is I can't tell if the missing j refers to the :keys vector or to the structure of the map on the right.
the :keys
vector
And the fact that i is a :i
in the :keys vector is a keyword adds a little confusion for me.
Huh, I didn't know you could put keywords in there
Well, in that case, it makes more sense
I was hoping the word destructured
would make it clear it was about the :keys
vector
Yeah, I guess I was only thrown off by the :i
in keys. I usually do :keys [i] ...
So I was expecting i to throw that error before j
@john you can even put namespaced keywords there, so:
(let [{:keys [:person/name]} {:person/name "Rich"}] name)
yeah, interesting :thinking_face:
or:
(let [{:person/keys [name address]} #:person{:name "Rich" :address "Some city"}] [name address])
["Rich" "Some city"]
oh, I like that... can you have multiple :some-ns/keys
instances?
yeah 🙂
nice!
I like that better than having to destructure namespaced keys key by key
So to answer your question, given that knowledge, I say the error message makes sense
kcool 🙂
@stefan.van.den.oord thanks for the feedback. where is this syntax for CLJS documented? (:require ["react-native-view-overflow" :default ViewOverflow])
It’s from the shadow-cljs user manual: https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages
First line in table 1
oh shadow-cljs
:the_horns:
how are you using this default? is that like an alias?
It’s the equivalent of this in JS: import defaultExport from "module-name"
Some 3d party modules export their stuff as default
, which is considered old fashioned, but what can you do 😕
let me ask the question another way: how can clj-kondo know that you are using the namespace 🙂
By detecting that I’m using the ViewOverflow
thing.
ok, so it’s like :refer
in that regard
e.g. [:> ViewOverflow ... ]
Yeah I guess…
ok, I’ll make a different issue for this
for now you can add this namespace to the ignored namespace using some config: https://github.com/borkdude/clj-kondo/blob/master/doc/config.md#exclude-required-but-unused-namespace-from-being-reported
While you’re at it, you may have a look at the other constructs in that table, e.g. :rename
, if you don’t support that yet…
:rename
is standard Clojure, that’s already supported
oh ok 🙂
Soooo many ways to do things in JS, you gotta love it 😉
I wonder why shadow-cljs adds a different thing instead of :refer
though
you can just use refer I guess?
I’ll ask in #clojurescript
or ask in #shadow-cljs
does your code still work when you use :refer
? because then my suggestion would be to just use that and not introduce deviations from standard CLJS
No, that doesn’t seem to work…
@borkdude https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports