This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-09-21
Channels
- # announcements (12)
- # architecture (26)
- # beginners (165)
- # biff (19)
- # calva (25)
- # circleci (2)
- # clj-kondo (25)
- # clojure (70)
- # clojure-dev (17)
- # clojure-europe (37)
- # clojure-nl (1)
- # clojure-norway (22)
- # clojure-spec (10)
- # clojure-sweden (1)
- # clojure-uk (24)
- # clojurescript (10)
- # clr (9)
- # cursive (17)
- # data-science (2)
- # datahike (1)
- # deps-new (1)
- # dev-tooling (3)
- # emacs (3)
- # events (7)
- # helix (10)
- # honeysql (1)
- # hugsql (3)
- # humbleui (3)
- # hyperfiddle (30)
- # introduce-yourself (3)
- # jobs (1)
- # malli (4)
- # music (1)
- # off-topic (3)
- # pathom (3)
- # polylith (6)
- # portal (7)
- # re-frame (16)
- # reitit (3)
- # releases (3)
- # remote-jobs (1)
- # shadow-cljs (23)
- # xtdb (14)
Hey.
What is the best way to suppress linter error from a macro in a library that I don't control? This library is from 2012 but they added a commit recently.
I could add a config.edn
but is this the best way?
This is what the template
macro does:
There is this issue but the library author closed it: https://github.com/brandonbloom/backtick/issues/8
I would add :lint-as {backtick/defquote clojure.core/def}
to the .clj-kondo/config.edn
This worked. Thanks 💯
that wouldn't fix the problem with unresolved symbols but at least template
macro will be known to kondo
That fixes the underlying outside symbols not being "used" and I think that I can fix the unknown macro by adding one more rule. But the undefined symbols is actually already good.
I did this and it fixed the underlying unknown symbols:
{:lint-as
{backtick/defquote clojure.core/def}
:linters {:unresolved-symbol {:exclude [(backtick/template)]}}}
But then the template
macro itself is said to be undefined. So I added this to the code:
#_{:clj-kondo/ignore [:unresolved-var]}
I'm not sure how to fix it.one way - keep only :lint-as {backtick/defquote clojure.core/def}
and then ignore unresolved symbols close to the usage of template:
(let [x 5 v [:a :b]]
#_{:clj-kondo/ignore [:unresolved-symbol]}
(b/template {:x ~x, s #{~@v "c" inc}}))
I also want to ignore the non-existent-var somehow. But I don't know how to write it. This doesn't work:
{:lint-as
{backtick/defquote clojure.core/def}
:linters {:unresolved-symbol {:exclude [(backtick/template)]}
:unresolved-var {:exclude [(backtick/template)]}}} <------------------------- this
why you need to ignore unresolved-var?
Because backtick/template
gives this:
Diagnostics:
1. Unresolved var: backtick/template [unresolved-var]
So I want to add #_{:clj-kondo/ignore [:unresolved-symbol]}
line but add it globally into the config if anybody would want to use this macro. I want it only for the macro and not underlying form :thinking_face:
So that I would be able to forget that it existed.that should be fixed by linting backtick/defquote as clojure.core/def at least it works in my playground
I added your rule but it's not fixed :thinking_face:
this:
{:lint-as
{backtick/defquote clojure.core/def}
#_#_:linters {:unresolved-symbol {:exclude [(backtick/template)]}
:unresolved-var {:exclude [(backtick/template)]}}}
Results in this:hm... here is what I have: in .clj-kondo/config.edn {:lint-as {backtick/defquote clojure.core/def}} and in the source code:
(let [x 5 v [:a :b]]
#_{:clj-kondo/ignore [:unresolved-symbol]}
(b/template {:x ~x, s #{~@v "c" inc}}))
rerun your linter to force kondo diagnostics to see if it actually worksI restart my IDE and it reloads the config but it doesn't suppress the nonexistent ns var error.
And importing [backtick :as b]
doesn't help too as b/template
gives the same error.
I don't add #_{:clj-kondo/ignore [:unresolved-symbol]}
into the source code.
I want to make it work without it.
It works with it but I don't want to use it.
to disable unresolved-symbol globally for b/template:
{:lint-as {backtick/defquote clojure.core/def}
:linters {:unresolved-symbol {:exclude [(backtick/template)]}}}
btw, do you know your kondo version?
This covers everything:
{:lint-as
{backtick/defquote clojure.core/def}
:linters {:unresolved-symbol {:exclude [(backtick/template)]}
:unresolved-var {:exclude [backtick/template]}}}
I upgraded my system yesterday.
clojure-lsp --version
clojure-lsp 2023.08.06-00.28.06
clj-kondo 2023.07.14-SNAPSHOT