clj-kondo

https://github.com/clj-kondo/clj-kondo
seancorfield 2021-04-02T19:48:49.167500Z

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?

borkdude 2021-04-02T19:49:15.167700Z

not known to me

seancorfield 2021-04-02T19:51:41.168100Z

Sharing work code via DM.

cjsauer 2021-04-02T22:04:00.170100Z

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/&gt;defn                    clojure.core/defn
           com.fulcrologic.rad.attributes/defattr                   clojure.core/def}
 :linters
 {:unresolved-symbol
  {:exclude
   [(com.fulcrologic.fulcro.mutations/defmutation)]}}}

cjsauer 2021-04-02T22:04:54.171100Z

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

borkdude 2021-04-02T22:05:24.171600Z

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

borkdude 2021-04-02T22:05:40.172100Z

I'm not sure if that works

borkdude 2021-04-02T22:06:39.172800Z

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

cjsauer 2021-04-02T22:07:44.173600Z

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:

cjsauer 2021-04-02T22:08:24.174400Z

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

borkdude 2021-04-02T22:09:18.175400Z

@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)

borkdude 2021-04-02T22:10:55.176200Z

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

borkdude 2021-04-02T22:12:39.177400Z

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.

cjsauer 2021-04-02T22:14:07.177800Z

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

cjsauer 2021-04-02T22:25:25.180100Z

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.

cjsauer 2021-04-02T22:25:48.180200Z

cjsauer 2021-04-02T22:28:51.180600Z

cjsauer 2021-04-02T22:28:59.181Z

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

cjsauer 2021-04-02T22:29:40.181600Z

> 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..