This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-14
Channels
- # announcements (1)
- # babashka (19)
- # beginners (50)
- # biff (7)
- # calva (6)
- # cider (13)
- # circleci (7)
- # clj-kondo (49)
- # clojure (45)
- # clojure-belgium (1)
- # clojure-europe (2)
- # clojure-indonesia (1)
- # clr (12)
- # datomic (3)
- # events (7)
- # fulcro (4)
- # graphql (2)
- # gratitude (1)
- # instaparse (5)
- # lsp (17)
- # off-topic (26)
- # polylith (15)
- # portal (4)
- # remote-jobs (2)
- # spacemacs (12)
curious, a question about linting cljc where a binding is used in only one target... is this the lowest-friction way to deal with unused-binding if you want zero warnings?
#_{:clj-kondo/ignore [:unused-binding]} ;; for `props`
(defui action-link-button [{:keys [href title] :as props}]
($ :a {:href href
#?@(:cljs [:on-click (with-prevent-link-events
(let [{{:keys [action-chan]} :action-queue
:keys [action]} props]
#(action! action-chan action)))])}
title))
I'm linting a macro that's intended for use with cljs. It expands to contain something like:
;; bar.clj
(ns foo.bar)
(defmacro baz
[]
`(some.other.ns/bish))
Then to make it available, I do:
;; bar.cljs
(ns foo.bar
(:require some.other.ns)
(:require-macros [foo.bar :refer [baz]]))
But kondo is insistent that when I use the macro that I need to require some.other.ns
.
;; app.cljs
(ns app
(:require [foo.bar :refer [baz]]))
(baz)
Is there some way I can have my analysis hook indicate that some.other.ns
will be loaded so it isn't a problem?The form needs to be expanded so it can be analyzed. Just not for this symbol referring to a namespace that isn't required.
I've missed the part where the form is sort of a fill in to get kondo to check that the code provided plays nicely in a threading macro with other code.
So I still want analyzed as if it works. But also, the require isn't missing, it's just done by the macro instead.
You want to generate (some-thing.foobar/whatever 1)
regardless of what your namespace aliases are. Then it's better to use single quote as this is unrelated to your namespace state.
Either: (list 'something.foobar/whatever 1)
or
`(~'something.foo/whatever 1)
does that:config-in-call {your.ns/macro {:linters {:unresolved-namespace {:exclude [some-thing.foobar]}}}
I'd prefer that the user was warned if they wrote the fully qualified namespace without requiring it.
But I want kondo to analyze usage with it 😜
Eg, I want to generate (call.to.foo/bar ~@user-code)
for kondo to lint that the user supplied list isn't longer than the args that bar can take, etc.
but if your macro generates that namespace usage, shouldn't the user at least require that namespace themselves? or is this never the case?
but a macro runs in the JVM and generates CLJS code. the JVM cannot require CLJS code.
That's why the cljs namespace is there to do :require-macros. This is how cljs-compatible macros work.
But in that case the user already requires this macro namespace and the require should already be present? Can you give me a real example that I can run that demonstrates the problem?
But I'm generating a call to a third namespace, not the namespace the macro is defined in.
so the :config-in-call
+ :unresolved-namespace
+ :exclude
should work but instead of :exclude
we should have something like :already-loaded
for namespace that are safely assumed to be loaded
Exactly. OR, we could allow to mark the "generated" code which only has some of the analysis applied to it.