Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Deraen opened this issue Dec 22, 2020 · 4 comments
Open

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

Deraen opened this issue Dec 22, 2020 · 4 comments

Comments

@Deraen
Copy link
Member

Deraen commented Dec 22, 2020

clj-kondo/clj-kondo#25

  • Optional way to create normal Reagent components from functions using some keyword, like :n> :$. Would work the same way as [comp], but the keyword would make it possible to find the calls.
    • Namespaced keyword would be even better, but would be quite verbose.
  • Provide function based API to optionally replace Hiccup syntax (like om.dom, helix.dom).
@borkdude
Copy link

borkdude commented Dec 23, 2020

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

  • macro which expands into a vector call:
(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.

  • clj-kondo could have a mode in which it always treats [foo 1 2 3] as a function call in .cljs files. False positives should be handled by users.

@Kaspazza
Copy link

Kaspazza commented Nov 5, 2024

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
Copy link

borkdude commented Nov 5, 2024

@Kaspazza The way to solve this is to write:

(defn outer [_a _b _c] ...)

@Kaspazza
Copy link

Kaspazza commented Nov 5, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants