This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-12
Channels
- # announcements (76)
- # babashka (10)
- # beginners (39)
- # biff (2)
- # calva (51)
- # chlorine-clover (8)
- # cider (6)
- # clj-kondo (15)
- # clj-on-windows (13)
- # cljdoc (26)
- # cljs-dev (8)
- # clojure (196)
- # clojure-austin (17)
- # clojure-europe (36)
- # clojure-nl (4)
- # clojure-spec (8)
- # clojure-uk (2)
- # clojurescript (18)
- # community-development (4)
- # conjure (1)
- # core-typed (38)
- # cursive (5)
- # datalevin (17)
- # datomic (25)
- # docker (1)
- # events (2)
- # interop (2)
- # jobs (4)
- # kaocha (28)
- # lsp (22)
- # nyc (1)
- # off-topic (10)
- # pedestal (1)
- # portal (22)
- # re-frame (22)
- # react (10)
- # shadow-cljs (19)
- # spacemacs (7)
- # tools-deps (11)
- # vim (14)
- # xtdb (7)
Is there an util function that takes an expression of a definition (e.g., (def a (+ 1 1)
) and gives body (`[(+ 1 1)]`)?
I'm thinking to enrich https://github.com/clj-kondo/clj-kondo/blob/9195cc0f0761a2b673816f5296a95380917ff05b/src/clj_kondo/impl/namespace.clj#L189! 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
found how to do https://github.com/clj-kondo/clj-kondo/blob/9195cc0f0761a2b673816f5296a95380917ff05b/src/clj_kondo/impl/analyzer.clj#L1005 body>, but don't know how to any def expr -> body
so far
;; 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 https://github.com/clj-kondo/clj-kondo/blob/9195cc0f0761a2b673816f5296a95380917ff05b/src/clj_kondo/impl/analyzer.clj#L502
e.g., in https://github.com/clj-kondo/clj-kondo/blob/9195cc0f0761a2b673816f5296a95380917ff05b/src/clj_kondo/impl/analyzer.clj#L1035
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 https://github.com/clj-kondo/clj-kondo/blob/master/doc/hooks.md#debugging and I guess this'll do for now, since the linting run is so fast
I asked something similar a while back, perhaps it hekps https://clojurians.slack.com/archives/CHY97NXE2/p1644324979611669?thread_ts=1644324979.611669&cid=CHY97NXE2
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.
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!