Fork me on GitHub
#clj-kondo
<
2022-10-30
>
Matthew Twomey19:10:20

Not positive if this is the best channel, but I’ve run into a strangeness with Kondo (via LSP) in Emacs. I’m editing a babashka script and kondo appear to work fine with one exception: I have several requires in my file, always using the :as [thing] qualifier. All of my references lint ok with the exception of “io.avisio.ansi” (`(require [io.aviso.ansi :as ansi-colors])`). It functions fine in my code (e.g. (str (ansi-colors/bold-white "Hi, I'm bold!")) , however I can’t get rid of “unresolved var” linting warnings on every use of ansi-colors/*** in my code. All my other requires lint just fine. I believe I’ve deleted all caches everywhere and this still happens. Has anyone run into anything similar?

hiredman20:10:04

It is likely to due to how io.aviso.ansi defines those names

hiredman20:10:51

Kondo's static analysis cannot understand that, so it doesn't know those names are defined there

Matthew Twomey20:10:27

well shoot. Ok - well at least I’m not crazy 🙂

borkdude20:10:26

You can exclude that namespace from unresolved var:

:unresolved-var {:exclude [io.aviso.ansi]}

Matthew Twomey20:10:03

Yeah I’ll probably give that a shot just to clean it up a bit. Thanks.

Matthew Twomey20:10:38

This is good to know as I start to develop my own libs to keep them linter friendly.

👍 2
borkdude20:10:30

If you are using clojure-lsp, then you could also generate stubs: https://clojure-lsp.io/settings/#stub-generation which emit (declare ..) or (def ...) just for the purpose linting/completions

Matthew Twomey00:10:08

Oooh - I hadn’t heard of that (yes I’m using clojure-lsp), will take a look thanks.

Matthew Twomey02:10:55

@U04V15CAJ Stubs worked a treat. Thansk!

Matthew Twomey19:10:21

This also is preventing auto-suggestion / completion (which is my primary pain really).