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

Detect Reagent component function calls for arity linting #25

Closed
borkdude opened this issue Mar 28, 2019 · 6 comments
Closed

Detect Reagent component function calls for arity linting #25

borkdude opened this issue Mar 28, 2019 · 6 comments
Labels
enhancement New feature or request expired expired - might be closed due to too little activity
Projects

Comments

@borkdude
Copy link
Member

borkdude commented Mar 28, 2019

(defn my-component []
  [:div "Hello"])

[:div [my-component 1 2 3]] ;; <- arity error
@borkdude
Copy link
Member Author

borkdude commented Apr 15, 2019

How do we detect if a function is intended as a Reagent component and hence a "vector call" should be interpreted as a function call?

A combination of one or more of these:

  1. we're in .cljs or a CLJS reader conditional part in .cljc
  2. We could look at the namespace requires. If reagent.core occurs there, it's extremely likely
  3. Check if a function uses r/create-class

Still, it's not 100% accurate to tell if [foo bar baz] is a Reagent component call or just a random vector with some symbols, so this will probably introduce a lot of false positives.

@borkdude borkdude added the enhancement New feature or request label Apr 25, 2019
@borkdude borkdude added this to Needs triage in clj-kondo Oct 15, 2019
@agoldhammer
Copy link

In addition, using the idiomatic reagent [component.classname ...] or [component#id ...] produces "unresolved symbol" errors. Can this be fixed?

@borkdude
Copy link
Member Author

@agoldhammer That's a separate issue. Can you please make an issue with a self-consistent example (.cljs file) that I can lint?

@borkdude borkdude changed the title Detect Reagent component function calls Detect Reagent component function calls for arity linting Oct 29, 2019
@borkdude
Copy link
Member Author

@agoldhammer According to a Reagent maintainer on Clojurians slack (@Deraen) this is not supported.

@agoldhammer
Copy link

Sorry, my mistake. Supported in Hiccup, not Reagent. Please ignore.

@borkdude borkdude added the expired expired - might be closed due to too little activity label Nov 23, 2019
@borkdude
Copy link
Member Author

Thought about this long enough and I don't see a feasible way to do this without producing false positives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request expired expired - might be closed due to too little activity
Projects
clj-kondo
  
Done
Development

No branches or pull requests

2 participants