Fork me on GitHub
#clj-kondo
<
2019-10-14
>
Hannu Hartikainen10:10:01

(ns foo (:require ["bar" :as Bar])) (Bar.) gives a warning for unused namespace. That’s a normal use case with shadow-cljs when a js library has module.exports = Bar.

Hannu Hartikainen10:10:26

I’d like to provide a fix but am not sure where to start.

borkdude10:10:17

is this also normal when using plain CLJS?

Hannu Hartikainen10:10:18

In fact it seems to me like there’s something off with constructor calls…

Hannu Hartikainen10:10:51

I think so, but I only work with shadow-cljs right now.

borkdude10:10:17

I think there was already a fix for this when using Bar as a value recently. But interop is pretty much ignored by clj-kondo, so the fix might not be straight forward.

borkdude10:10:49

Feel free to post an issue so I can think about it more. I'd be happy to point you in the right direction if you want to do a PR. Please post that in the message as well, if you're interested in doing one.

👍 4
borkdude10:10:06

I think you can avoid the false positive right now, by just having something like (comment Bar) in your code 😜

borkdude10:10:17

in fact it might be easy to hack it in in that place, by just stripping the last dot

Hannu Hartikainen10:10:35

Ok. I’m reading CLJS docs now to see if this is a shadow-cljs extension and I’m starting to think it is. Still interested in a fix?

Hannu Hartikainen10:10:47

> As discussed on Slack: it would be nice to only have this behavior if the user requires the namespace using a string. yes, that would be a good way to do both of these

borkdude10:10:55

I remember this feature not being documented well in CLJS but as a value it still worked

borkdude10:10:14

The string require is already in there as a later commit

Hannu Hartikainen10:10:44

Yep, I’ll read it later and make sure this works the same way. Thanks!

martinklepsch12:10:40

Has there been a conversation around Rum + clj-kondo? Rum’s macros trip up some of the analysis and I’m not sure it’s as easy as saying “they’re like defn” because they can take mixins etc