This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-19
Channels
- # admin-announcements (1)
- # asami (9)
- # aws (46)
- # beginners (117)
- # calva (9)
- # cider (48)
- # clj-kondo (27)
- # cljdoc (6)
- # clojure (41)
- # clojure-australia (2)
- # clojure-europe (22)
- # clojure-nl (3)
- # clojure-spec (3)
- # clojure-uk (26)
- # clojurescript (57)
- # code-reviews (25)
- # cursive (9)
- # data-science (2)
- # datomic (31)
- # events (1)
- # expound (24)
- # figwheel-main (8)
- # fulcro (38)
- # graalvm (40)
- # helix (6)
- # jackdaw (4)
- # java (5)
- # jobs (1)
- # kaocha (7)
- # kekkonen (1)
- # meander (65)
- # off-topic (67)
- # pathom (4)
- # reagent (9)
- # reitit (8)
- # remote-jobs (3)
- # ring (2)
- # shadow-cljs (24)
- # spacemacs (13)
- # timbre (2)
- # tools-deps (4)
Is there a way when I write my hook I can test it at the REPL? Like can I call api/something clojure-code-to-lint
which will parse the clojure-code-to-lint and call my hook with the rewrite-clj node for it?
Also, I'm only seeing a clj-kondo.impl.hooks
in the Jar, but the doc says my hook needs to require clj-kondo.hooks-api
Ok, so it seems in the Jar clj-kondo.impl.utils is the same as clj-kondo.hooks-api inside sci when acutally running through clj-kondo
So now, my last issue is, how do you create a QuoteNode? It doesn't seem that there is a util for that?
If I just use token node, I get: "Unable to resolve symbol" which makes sense, since its supposed to be a quoted symbol
I tried to use list-node with quote but it doesn't help me, because this:
(do (alias (quote app) (quote app)))
::app/db
Doesn't lint, it seems the alias linter doesn't work if using (quote app)
instead of 'app
We should support that in clj-kondo. Please post an issue, I will mark it as high priority and pick it up before next release.
Which I think is cause they are parsed differently, 'app
results in a QuoteNode, while (quote app)
result in a ListNode
for quoting i think this might work: https://github.com/sogaiu/libpython-clj/blob/dbb0e36a5211cfbfac9a34c4eb5d973f55d2c61c/resources/clj-kondo.exports/clj-python/libpython-clj/hooks/libpython_clj/require/import_python.clj#L38
But if the require linter works with it... Hum maybe I could rewrite my hook to a require instead of an alias.
for debugging, i've been copying what @lee did here: https://github.com/lread/rewrite-cljc-playground/blob/09882e1244a8c12879ef8c1e6872724748e7914b/.clj-kondo/hooks/rewrite_cljc/potemkin/import_vars_with_mods.clj#L60-L61 then invoke clj-kondo from the command line
@U0K064KQV Yes, prn/println is good for debugging. For running actual tests, I recommend just linting source with the hook and write tests based on the linter results
I found I can just swap the require for the clj-kondo.impl.utils namespace at the REPL, and call my hook with parse-string wrapped in a {:node} map and it works. As long I make sure I don't use anything in utils that sci doesn't include in api.
I think that be useful. It wasn't too hard for me to swap the namespace require back and forth, but still a bit annoying.
Also, could be nice to have a parse-for-hook util or something. Which does: ({:node (parse-string string-form)})
or something similar. Though again, it wasn't very hard for me to just wrap parse-string in it.
if i have an empty (or)
i get this error at the ns decl Wrong number of args (0) passed to: clj-kondo.impl.types.utils/union-type
is this known about and i just need to upgrade?
ah found the issue, shoulda checked first