Fork me on GitHub
#clj-kondo
<
2022-04-25
>
rayat03:04:12

On the topic of writing clj-kondo hooks (ie analyze-call), the debugging instructions in hooks.md suggests using prn statements. So the idea is that if I were to manually run clj-kondo from the cli - to lint some file that I know makes use of the macro I'm writing the hook for - I should see those prn statements in the command line alongside whatever linting results for the file (`eg linting took 57ms, errors: 1, warnings: 5`), right? If so, I do not see the print statements - how can I debug if I config'd it incorrectly?

1
Dumch06:04:37

I wasn't able to get it to work either, so I was just throwing errors to see the data 🙂 Subscribing to the thread.

borkdude06:04:44

If you don't see any output then simplify your example until you do see output and then go from there.

Dumch07:04:43

thanks 🙂

Dumch07:04:22

And previously I did evertything without terminal, used to see results only in diagnostics

borkdude07:04:52

terminal is easier

Dumch07:04:59

yes, I see now

Dumch07:04:13

May be docs "workflow" section would be helpful

borkdude07:04:34

I've written something here: https://github.com/clj-kondo/clj-kondo/blob/master/doc/hooks.md#debugging But it may not be obvious that testing from the terminal is what is implied here

wow 1
borkdude07:04:53

How else are you going to see those printlns

Dumch07:04:28

I also spent like half an hour trying to debug it with repl and googling for help, then surrendered

1
rayat16:04:13

I wasn't sure at all myself what was implied - I know for sure that there are many non standard workflows in the clojure/lisp/repl world thus I do not know what I do not know, and in this case, it is not so obvious if the answer to my question was either: 1. I made a mistake in the execution of my work/code within my hook, so I'll simplify my hook until it prints and then go from there 2. OR I made a mistake in my understanding of the workflow itself, or messed up config or namespacing or something I'm still new to, so no amount of simplifying my hook would help, as the issue was somewhere else unknown to me

Dumch12:12:16

@U037TPXKBGS, I just checked out the new https://github.com/clj-kondo/clj-kondo/blob/master/doc/hooks.md#developing-hooks-in-the-repl and it is amazing. I end up adding an alias in my deps.edn:

:clj-kondo
  {:extra-deps {clj-kondo/clj-kondo {:mvn/version "LATEST"}}}
And run a repl like: clj -M:nrepl:clj-kondo

Dumch16:04:06

Don't know if it's a bug or I do not know somehting. One (1) way linter works with nvim-lsp-config and command line, another (2) it works only in command line. 1. I get node directly from children and then pass it to let body. 2. I get node from children, do sexp on it, then convert it back to node (result is the same in print). here is a screen for 1:

Dumch16:04:32

My function looks like:

...
(prn :key2 key2)            ;=> :key <token: bob> 
(prn :key (token-node key)) ;=> :key <token: bob>
...
{:node <here a let form like:
 (let [name1 value1 ... name-n value-n]
    key2 ;; key2 works, (token-node key) does't work
    body-node)>}

Dumch16:04:44

by 'working in command line" I mean it prints error as expected for both key2 and (token-node key) varians

borkdude16:04:30

If it works on the command line then it's likely that your editor doesn't use the same version of clj-kondo

😮 1
borkdude16:04:48

or the locations aren't being set properly in the error

borkdude19:04:07

yep, that's what I thought ;) > or the locations aren't being set properly in the error

💯 1