clj-kondo

https://github.com/clj-kondo/clj-kondo
dharrigan 2021-06-25T07:25:35.281400Z

I have an interesting one. I'm working on a project that has something like this (sql/defsql "filetoload.sql" :as q)

dharrigan 2021-06-25T07:26:22.282300Z

the sql/defsql is a defmacro that uses hugsql. I've read the helpful tips about hugsql on the wiki, but in this case it doesn't apply, since...

dharrigan 2021-06-25T07:26:58.282900Z

the macro does this (in its internals) (alias '~alias query-namespace#) where the alias is the q above.

dharrigan 2021-06-25T07:27:09.283200Z

so, in the namespace, I get this:

dharrigan 2021-06-25T07:28:44.283400Z

(a moment, just editing file)

dharrigan 2021-06-25T07:29:34.283500Z

dharrigan 2021-06-25T07:32:33.285800Z

So, the q is defined in the namespace as an alias. It is then used in that namespace as q/some-hugsql-thingie, but clj-kondo doesn't know anything about it.

dharrigan 2021-06-25T07:44:08.286100Z

I've put up an example here <https://github.com/dharrigan/clj-kondo-unresolved-namespace>

borkdude 2021-06-25T07:57:10.286600Z

@dharrigan oh man :)

borkdude 2021-06-25T07:57:17.286800Z

I didn't even know hugsql could do this

dharrigan 2021-06-25T07:57:51.287500Z

I think it's more the project I'm working on, and the way they've done it, rather than hugsql 🙂

dharrigan 2021-06-25T07:58:00.287800Z

but yeah....I hear you

borkdude 2021-06-25T07:58:02.287900Z

but I think you could write a hook for this, shouldn't be too hard

borkdude 2021-06-25T07:58:43.288200Z

and if you figure the hook out, you could contribute it to: https://github.com/clj-kondo/config/tree/master/resources/clj-kondo.exports/clj-kondo

dharrigan 2021-06-25T07:59:04.288700Z

I'll see if I can get some time to think about how to do it

borkdude 2021-06-25T07:59:20.289100Z

or perhaps you could put (comment (alias 'q ...)) in there, so clj-kondo thinks there is an alias q, but this would be a workaround