reagent-project / reagent

A minimalistic ClojureScript interface to React.js
http://reagent-project.github.io/
MIT License
4.76k stars 414 forks source link

Find a way to make Hiccup forms easier to analyze #522

Open Deraen opened 3 years ago

Deraen commented 3 years ago

https://github.com/borkdude/clj-kondo/issues/25

borkdude commented 3 years ago

Alternatives (not necessarily better than what's already mentioned):

(defmacro f [& args] `[~@args])
(r/f component  1 2 3)

This solution doesn't need any changes to other code in Reagent, but allows static analysis to detect reagent calls accurately.

Kaspazza commented 3 weeks ago

Form-2 components are marked by clj-kondo as unused binding

(defn outer 
  [a b c]            ;; <--- those parameters will get marked by clj-kondo as unused-binding
  ;;  ....
  (fn [a b c]        ;; <--- they are repeated here
    [:div
      (str a b c)]))
borkdude commented 3 weeks ago

@Kaspazza The way to solve this is to write:

(defn outer [_a _b _c] ...)
Kaspazza commented 3 weeks ago

@borkdude Hmmm, I was in a mindset it is used so there should be no warning... But it makes sense... Thanks!