Fork me on GitHub

Is there an util function that takes an expression of a definition (e.g., (def a (+ 1 1)) and gives body (`[(+ 1 1)]`)?


in the context of clj-kondo, how would you use that?


I'm thinking to enrich! with body to have all :vars and their corresponding bodies for playing around with semantics of a program. It's not something that clj-kondo intents to do, but I found reg-var! that is almost what I want. 🙂 (I'd like to have all vars of a program with their vals to later on derive one big val without vars) (sounds crazy, yeah)


So I thought, in order to derive body out of a def expr perhaps there is an utility function


;; TLDR no worries, I've got it. 😄 seems there is no such function, I see analysis functions for different def exprs parse it one child at a time e.g., in e.g., in I'm interested only in those atm and will tweak them to pass into reg-var! :body as well


I'm just dipping my toes into hooks and I want to figure it out with the repl. Are there any tricks I should know about in turning my code into a rewrite-clj node to feed it in for playing around, or is there another/better way that people test hooks?


I've got the (prn ,,,) working to give feedback from a command-line linter run, but was wondering if there's a good way to test them from eg. a (comment (my-hook ,,,)) block. Is making a fn rewrite-clj node -> rewrite-clj node all there is to it?


hm just re-read and I guess this'll do for now, since the linting run is so fast


oh that does help, thank you. So far I'd been trying to thin down my hook code to just call a function, return a very obvious map eg. {:new-let-binding-vec [,,,]} and do only very obviously correct stuff in the hook. Then I can work on the function someplace else and paste it back in.


(which is probably not a bad strategy for anything, tbh).


is it possible to specify a list of source paths for clj-kondo to lint against ? (aka src, test, shared-src, etc) in the ./clj-kondo/config.edn ?


@dviramontes not in config.edn, these are arguments to either the CLI or JVM lib:

--lint src:test:shared-src


nbd, thank you!