clj-kondo

https://github.com/clj-kondo/clj-kondo
borkdude 2021-02-24T11:12:13.020500Z

This project uses clj-kondo analysis :)

Carnun 2021-02-24T12:38:51.032100Z

Hi. Quick question about unused cljs requires! :)) The following seems to elicit a false positive:

[react-autosuggest :as AutoSuggest] > warning: namespace react-autosuggest is required but never used
There's also an erroneous 'Unresolved symbol' in one of the two places AutoSuggest is passed as a component to https://github.com/lilactown/helix/blob/master/docs/creating-elements.md#-macro $ (???):
($ AutoSuggest > error: Unresolved symbol: AutoSuggest
   {:suggestions ...

...

($ AutoSuggest {:getSuggestionValue get-suggestion-value ...
Now, https://www.npmjs.com/package/react-autosuggest (see pic below) kinda suggests that I should be doing [react-autosuggest :refer [Autosuggest]] or something, not :as. But making this change (and accounting for AutoSuggest -> Autosuggest) breaks things. (Separate issue, but probably because of helix...) So it could be that react-autosuggest is just strange (and I should add an inline reader comment or do some other config, say). Or maybe kondo doesn't realise react-autosuggest is a js module, not a ns? Or something else?

Carnun 2021-02-24T12:42:50.032500Z

Also, my bad if this is more appropriate for #clojurescript! 🙂

Carnun 2021-02-24T12:53:25.032800Z

Or #helix, for that matter...

borkdude 2021-02-24T13:27:23.033Z

@carnunmp Let's start with the first issue

borkdude 2021-02-24T13:27:59.033200Z

Can you make a full .cljs minimal repro for me?

Carnun 2021-02-24T13:43:01.033400Z

For sure. On it! 🙂

Carnun 2021-02-24T14:10:26.033600Z

This seems to do it @borkdude: https://github.com/CarnunMP/kondo-repro

Carnun 2021-02-24T14:12:11.033900Z

In fact, both the 'required but never used' warning and the 'Unresolved symbol' error show up:

borkdude 2021-02-24T14:15:08.034400Z

@carnunmp Yeah, this is a known issue. You should use a string namespace when using npm deps.

(ns hello
  (:require ["react-autosuggest" :as AutoSuggest]))

(defn x
  []
  (AutoSuggest))

borkdude 2021-02-24T14:15:26.034600Z

This way clj-kondo can distuingish between normal cljs deps and npm deps

Carnun 2021-02-24T14:16:25.034800Z

🙏

Carnun 2021-02-24T14:16:36.035Z

Good to know! Thanks. :)))

borkdude 2021-02-24T22:28:33.035500Z

🎉 6