Fork me on GitHub

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?


I think using {:node (parse-string ...)} from the utils namespace does the trick


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


Hum, and they seem to contain different functions as well


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?


My hook needs to rewrite things with a quoted symbol?


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)))

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.

👍 3

Which I think is cause they are parsed differently, 'app results in a QuoteNode, while (quote app) result in a ListNode


That didn't seem to work for alias


But if the require linter works with it... Hum maybe I could rewrite my hook to a require instead of an alias.


That could work, nonetheless we should support this for alias as well


Switching to require worked. I still cut an issue for alias


Thanks, will be fixed.

🎉 3

but may be that's not going to help in your situation


@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.


We could expose a JVM version of the hooks API for testing as well.


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?


upgrade, it's already fixed

👍 3

ah found the issue, shoulda checked first