Fork me on GitHub
#clj-kondo
<
2021-11-26
>
chrisn19:11:52

Getting this error while linting datatype.clj :

src/tech/v3/datatype.clj:167:19: error: Unresolved symbol: idx
src/tech/v3/datatype.clj:167:19: warning: Unresolved namespace hooks.datatype. Are you missing a require?
That hooks.datatype file does exist: https://github.com/cnuernber/dtype-next/tree/clj-kondo-builtin/resources/clj-kondo.exports/cnuernber/dtype-next

borkdude19:11:59

src/tech/v3/datatype.clj:167:19: warning: Unresolved namespace hooks.datatype. Are you missing a require?
This warning just means that you're using the namespace without having required it.

borkdude19:11:32

Probably your hook is generating some code with this name in it?

borkdude19:11:09

Yeah that's the issue. Your macro is defined in a namespace hooks.*. I recommend renaming this namespace to the same namespace as where the original namespace is occurring.

borkdude19:11:11

It's recommended for exported config hook code to use unique namespaces anyway and the convention is <org>/your_lib/file.clj or so, similar to how you would do it in your lib

chrisn19:11:09

I put the config file exactly there, cnuernber/dtype-next/config.edn. Then it will have an entry that is {:macroexpand {tech.v3.datatype/make-reader tech.v3.datatype/make-reader}} with the code under resources/clj-kondo.exports/cnuernber/dtype-next/tech/v3/datatype.clj. Is that the recommendation?

chrisn19:11:39

Also, I have a few namespaces that simply extend protocols but aren't used directly in the file. Is there a good way to annotate those namespaces or the require itself?

borkdude19:11:25

(to the first question)

borkdude19:11:25

I don't understand the need for "annoting those namespaces".

borkdude19:11:35

Can you clarify with an example?

chrisn19:11:59

(ns a.b.c
  (:require [protocol-defs :as pdef]
            [protocol-impls]))

(defs/use-protocol :a)  

chrisn19:11:02

Something like there where there are protocol or multimethod implementations but the namespace doesn't export anything aside from that.

borkdude19:11:18

I still don't understand. What is the problem?

chrisn19:11:32

unused namespace warning

borkdude19:11:59

because you're not using pdef?

borkdude19:11:18

if you don't add an alias then clj-kondo will assume you are requiring only for side effects

chrisn19:11:44

Ah, ok, there it is. The times I have seen it I had an alias, sorry, that clears it up.