Fork me on GitHub
#clj-kondo
<
2021-04-02
>
seancorfield19:04:49

I’m seeing warnings about “unused default for binding <sym>” for destructured argument bindings that absolutely are used in the function body that follows. Is this a known issue and/or recently fixed?

borkdude19:04:15

not known to me

seancorfield19:04:41

Sharing work code via DM.

cjsauer22:04:00

I’m having some trouble with Unresolved symbol errors happening inside of custom macros that are themselves inside of reader conditional forms. I have the following set in my config.edn file:

{:lint-as {mount.core/defstate                                      clojure.core/def
           taoensso.encore/if-let                                   clojure.core/let
           com.wsscode.pathom.connect/defresolver                   clojure.core/defn
           com.fulcrologic.fulcro.components/defsc                  clojure.core/defn
           com.fulcrologic.fulcro.routing.dynamic-routing/defrouter clojure.core/defn
           com.fulcrologic.fulcro.mutations/defmutation             clojure.core/defn
           com.fulcrologic.guardrails.core/>defn                    clojure.core/defn
           com.fulcrologic.rad.attributes/defattr                   clojure.core/def}
 :linters
 {:unresolved-symbol
  {:exclude
   [(com.fulcrologic.fulcro.mutations/defmutation)]}}}

cjsauer22:04:54

I thought the exclusion above would solve it, and it solved some of them, but I’m still seeing params linted incorrectly (see image)

borkdude22:04:24

you are using lint-as and unresolved-symbol config for the same macro

borkdude22:04:40

I'm not sure if that works

borkdude22:04:39

try {:lint-as {com.fulcrologic.fulcro.mutations/defmutation clj-kondo.lint-as/def-catch-all} and remove the :exclude

cjsauer22:04:44

Ah! That worked, but only for the forms inside of the #?(:cljs …) forms…the ones inside of #?(:clj …) are still showing the same unresolved symbol error :thinking_face:

cjsauer22:04:24

Something with the reader conditionals is confusing kondo. I see a whole bunch of “unused namespace” warnings too, but those are clearly used by the :cljs forms

borkdude22:04:18

@cjsauer if only the :cljs branch is using those namespaces, you should put the :require of that namespace in a :cljs branch too, else clj-kondo will tell you it's unused (namely in the JVM invocation of that .cljc file)

borkdude22:04:55

the model that clj-kondo uses for linting .cljc files is: 1) lint once for .clj, reading everything but not .cljs branches 2) lint once for .cljs, reading everything, but not .clj branches

borkdude22:04:39

I'll be afk now, it's getting late. Feel free to post an issue if nobody else helps you out in the coming few hours.

cjsauer22:04:07

That solved the unused namespace warnings! No prob, thank you @borkdude

cjsauer22:04:25

Actually, using the :lint-as and unresolved-symbol configurations together does almost seem to work. That removes all errors, except the unresolved symbols defined by the macros themselves.

cjsauer22:04:59

Ah there we go! Here is the config that ended up working ☝️

cjsauer22:04:40

> you are using lint-as and unresolved-symbol config for the same macro This seems to work just fine…although maybe that’s just a happy accident..