Is it possible to not show specific warning of custom macro? For instance I got the macro like
(defmacro in-node
[& body]
`(when config.core/NODEJS?
~@body))
which is lint-as
in config.edn
in the following manner:
core.isomorphic/in-node clojure.core/do
I would like this macro to not dispatch warning about redundant do
.Maybe :lint-as clojure.core/when
works? (lucky guess)
or clojure.core/fn
maybe, something which receives a body but which is not do
;)
I kind of remember looking at this, but maybe I confuse this with lint-as clojure.core/for
giving "redundant let" warnings. But kind of same thing maybe?
I think analyze-let-like-bindings
has some additional checks to differentiate calls to clojure.core macros and lint-as macros? https://github.com/borkdude/clj-kondo/commit/3e138713b6183f7faca74af8f0aa2b1b0486a1ac
true, we could do the same for do
if that isn't the case already. An alternative would be to write a small hook. Redundant let + do is ignored from generated hook code
Although all proposals. Altough those remove the redundant do warning they introduce new ones.
Not sure how to reproduce this, simple case seems to work:
❯ clj-kondo -c '{:lint-as {user/foo clojure.core/do}}' --lint -
(ns user)
(defmacro foo [& body] (when 2 ~@body))
(foo 1)
linting took 8742ms, errors: 0, warnings: 0
@juhoteperi You should use --config
Oops, also forgot backtick from the macro.
❯ clj-kondo --config '{:lint-as {user/foo clojure.core/do}}' --lint -
(ns user)
(defmacro foo [& body] `(when 2 ~@body))
(foo 1)
<stdin>:5:1: warning: redundant do
linting took 4304ms, errors: 0, warnings: 1
@karol.wojcik Why do you need :lint-as
at all? If you just pass a body to that macro, I don't think you would get false positives? (it could very well be, I'm not awake enough yet)
@borkdude you are right 😄 Thank you so much guys @juhoteperi @borkdude