This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-12-14
Channels
- # adventofcode (42)
- # babashka (37)
- # beginners (62)
- # cider (13)
- # clj-kondo (12)
- # cljdoc (1)
- # clojure (80)
- # clojure-australia (2)
- # clojure-dev (43)
- # clojure-europe (69)
- # clojure-italy (8)
- # clojure-nl (10)
- # clojure-switzerland (130)
- # clojure-uk (12)
- # clojurescript (23)
- # code-reviews (8)
- # cryogen (5)
- # cursive (6)
- # datomic (3)
- # duct (4)
- # emacs (12)
- # fulcro (60)
- # kaocha (7)
- # lambdaisland (4)
- # malli (4)
- # meander (1)
- # nrepl (31)
- # off-topic (2)
- # re-frame (16)
- # rewrite-clj (5)
- # shadow-cljs (11)
- # spacemacs (7)
- # xtdb (1)
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
.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