Fork me on GitHub
#clj-kondo
<
2021-10-13
>
JonR16:10:19

Does anyone have a suggestion for fixing warnings for unsued bindings in cljs anonymouse fns? Example:

(hooks/use-callback
                             []
                             (util/debounce
                              (fn [ev]
                                (let [{:keys [input-value]} (util/->clj ev)]
                                  (when on-change
                                    (on-change input-value))))
                              debounce-time))

JonR16:10:32

I get clj-kondo warnings on input-value being unused

JonR16:10:07

I tried using the lsp action resolves as clojure.core/defn but that didn't help. That also seems like it shouldn't be needed so probably not a good plan

JonR16:10:30

Similarly in this example I get used binding on the second arg, item, but not the first...

(chakra/List
      (->clj (getMenuProps))
      (when isOpen
        (map-indexed
         (fn [i item]
           (chakra/ListItem
            (merge
             {:key i
              :bg (if (= highlightedIndex i)
                    "#bde4ff"
                    "#F7FAFC")
              :borderBottom "solid 1px #E2E8F0"}
             (->clj (getItemProps (->js {:item  (->js item)
                                         :index i
                                         :key   i}))))
            (render-item
             {:hover? (= highlightedIndex i)
              :item   item})))
         items)))

ericdallo19:10:58

that's odd, you are actually using that input-value variable right?

JonR15:10:33

Yup, in both examples the vars are for sure used. It seems like somehow any anonymous fn arg is having this happen in my cljs code...

JonR15:10:09

Here is my config.edn

{:linters {:unresolved-symbol {:exclude [_]}
           :invalid-arity     {:skip-args [mxv.client.react/defrc]}
           :unused-binding    {:exclude-destructured-keys-in-fn-args true
                               :exclude-destructured-as              true}}
 :lint-as {mxv.client.react/defrc clojure.core/defn
           com.wsscode.pathom.connect/defmutation clojure.core/defn}
 :skip-comments true
 :config-paths ["clj-kondo/helix"]}

ericdallo16:10:26

could you make a simple repro so we can test it?

JonR16:10:09

It's in a big mono repo so I'll probably need to make a new little project. Will let you know when I have that up. Thanks

👍 1