clj-kondo 2025-03-29

Hi! Is there a way to access sci.core/parse-next+string from within a hook?

my OCD wants me to write a hook for the << macro, which does string interpolation:

i need some way to incrementally read forms from the string, keeping track of read position in the string

I think it would make sense to expose edamame which is the clojure parser library used in SCI. which would let you write it almost in the same way https://github.com/borkdude/edamame is this the clojure contrib << interpolation macro?

user=> (require '[edamame.core :as e])
user=> (e/parse-next+string (e/source-reader ", (+ 1 2 3)"))
[(+ 1 2 3) ", (+ 1 2 3)"]

feel free to open an issue about it

Is it possible to get a lint error if a var that is required is not defined in the source code of a namespace? Example (ns lib) (def foo 1) (ns app (:require [lib :refer [foo bar]])) -> ns lib does not contain bar, so I would like to get a lint error.

@hoertlehner this already works.

$ clj-kondo --lint - <<< '(ns lib) (def foo 1) (ns app (:require [lib :refer [foo bar]]))'
<stdin>:1:41: warning: namespace lib is required but never used [:unused-namespace]
<stdin>:1:53: warning: #'lib/foo is referred but never used [:unused-referred-var]
<stdin>:1:57: warning: #'lib/bar is referred but never used [:unused-referred-var]
<stdin>:1:57: warning: Unresolved var: bar [:unresolved-var]

the last warning is about that

let's take this to a different thread though, as it's not related at all to the OP

Wow ! Thanks so much @borkdude! I dont know about OP - I posted on clj-kondo thread; isnt that the right thread?

On slack a channel (#clj-kondo) is the main thing where you post messages. if you want to react to a specific message, you can start a thread. you're now in a thread started by @micha about a specific question

I see that now. Im the ui on my Phone I had no way of seeing that. Sorry!!