I have one more question related to clj-kondo
lint-as
for plumbing.core
I have tried to apply this configuration
:lint-as {plumbing.core/defnk clojure.core/defn
plumbing.core/letk clojure.core/let}
and as result I get syntax linter error “error: unsupported binding form :events” for
(defnk init [[:events on-select-fn :as events] path]
and “error: unsupported binding form :results” for
(letk [[[:results {result nil} {nextCursorMark nil}]] results]
@borkdude is it expected or it is a bug similar to what was solved yesterday for plumbing.core/?>
?This is expected since :events
is indeed not a valid binding form in defn
If you want to have proper support for these macros you will have to write a hook. https://github.com/borkdude/clj-kondo/blob/master/doc/hooks.md You can contribute it to https://github.com/clj-kondo/config for sharing the hook with others. The other way is to simply ignore unresolved bindings in these macros.
by ignore do you mean configure somehow clj-kondo to ignore them?
yes
:unresolved-symbol {:exclude [(plumbing.core/defnk)]}
thanks, it is actually what we are doing right now. I’ll try to look on hooks for the better solution to fix the problem
Actually :unresolved-symbol {:exclude [(plumbing.core/defnk)]}
generates new unresolved-symbol errors for declarations inside (defnk fn [])
So probably only hooks are the rescue when plubming.core
is used 😞
@vguzar Can you give me a repro of this? I think you should always be able to suppress warnings using config
@borkdude sorry I have wrongly described the error. When :unresolved-symbol {:exclude [(plumbing.core/defnk)]}
is used everything that is declared using defnk
of letk
became unresolved symbol. For example for all usages of declared request-async
(defnk request-async [{method :get} {headers nil} url {payload nil}])
you’ll get error: Unresolved symbol: request-async
@vguzar Ah, for this we have:
{:lint-as {plumbing.core/defnk clj-kondo.lint-as/def-catch-all}}
lint-as def-catch-all will use the first symbol as the var name and won't warn about anything else in that defn-like macro
thanks, that could be a rescue let me try
works perfectly, thank you one more time
:thumbsup:
sorry for bothering but one error related to `
:unresolved-symbol
which is bothering me and I cannot understand. For this code
(defn set-channels [search {:keys [channel static-channels]
:or {channel (:channel search)}}]
clj-kondo complains with error: Unresolved symbol: search
The syntax seems to be ok and code is working as it should, any ideas what is wrong here?@vguzar There is an issue about this here: https://github.com/clj-kondo/clj-kondo/issues/916 and https://github.com/clj-kondo/clj-kondo/issues/782 I think this should be supported but was considered not supported in Clojure at one point, but this viewpoint has changed.
For now it's probably best to use a let binding
I will bump the priority of issue 916
oh, thanks
Another issue with :unresolved-symbol
related to anonymous methods #()
and metadata. In this case
#(let [status (.getStatus ^clj %)])
I got an error error: Unresolved symbol: clj
Didn’t get the same for regular function definition (fn [^clj xhr]
@vguzar Is this .cljc code or only .cljs?
cljs
what does ^clj
mean in the context of .cljs code?
actually it is a good a question 🙂 I would try to get an answer. Could it influence the fix for linter. I see it used in many places in regular fn
but linter is complaining only about anonymous function
Ah, I see:
(defn foo [^clj x])
(fn [^clj x])
#(do ^clj %) ;; only here
That's probably a bug in clj-kondo
Please post an issue
Issue https://github.com/clj-kondo/clj-kondo/issues/1212 is here
Anyone have an example of a .clj-kondow/config.edn
configured for reagent macros to share?
Thanks