Is it possible to add an analyze hook for defn?
Something like
(defn my-hook
[{:keys [node] :as input}]
(if (something node)
(do my stuff)
input)) ;; fall back to original behavior
Is there some existing hook I should call orWhat I'm trying to do: hook into defn, check if any of the arglists has .child and replace it with _ child to resolve warnings in clojuredart (I know it's super hacky but it could at least resolve the most major case)
have you tried it?
Yeah if I just replace the args like that, it seems that defn forms get ignored by clj-kondo altogether. That's why I wondered if I could call into some existing hook to "extend" the default behavior
For now I worked around this by aliasing defn as defwidget, adding a hook for defwidget and replacing every defn that had a .child with defwidget
> it seems that defn forms get ignored by clj-kondo altogether. what are you returning?
The updated {:node node} thing
could it be that you are messing something up?
no offense of course
None taken, that sanity check was my first step too. But alas the hook as below seems to have had that effect
(defn my-hook
[{:keys [node] :as input}]
input)
you can run clj-kondo with --debug to have extra verification when constructing nodes
also printing the new node might help to see if it's constructed correctly
Just to make sure I understand correctly If I add a hook for clojure.core/defn, and my hook returns a node that still starts with defn, it should get passed to the "default" linters for defn?
I think so
I'm taking a look at this https://github.com/clojure-lsp/clojure-lsp/issues/1957 and realized that it doesn't work because of how clj-kondo return findings of syntax type ๐งต
for the following code:
(ns clojure-lsp.feature.foo)
foobar/
{:end-row 4, :type :syntax, :level :error, :col 1, :uri "file:///home/greg/dev/clojure-lsp/lib/src/clojure_lsp/feature/foo.clj", :end-col 1, :langs (), :message "Invalid symbol: foobar/.", :row 4}
would be possible to end-col be 6 o7 instead of 1?other types like unresolved-namespace or unknown-symbol work with the end-col matching properly
@lee is this perhaps an issue that is related to the tools.reader bump in rewrite-clj?
@ericdallo feel free to post an issue
I believe this behavior is pretty old, will create a issue
thanks
> @lee is this perhaps an issue that is related to the tools.reader bump in rewrite-clj? I don't think so... The tools.reader bug was an off by one end-col for numbers/symbols/keywords at eof.