This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-10-27
Channels
- # announcements (11)
- # aws (1)
- # babashka (15)
- # beginners (345)
- # calva (5)
- # chlorine-clover (14)
- # clj-kondo (40)
- # cljfx (30)
- # clojure (174)
- # clojure-australia (6)
- # clojure-europe (64)
- # clojure-france (1)
- # clojure-nl (12)
- # clojure-uk (20)
- # clojurescript (29)
- # conjure (1)
- # core-async (53)
- # cryogen (3)
- # cursive (8)
- # datomic (12)
- # emacs (5)
- # events (4)
- # fulcro (27)
- # graalvm (1)
- # graphql (9)
- # helix (8)
- # keechma (11)
- # london-clojurians (1)
- # malli (12)
- # off-topic (12)
- # pathom (8)
- # portal (1)
- # re-frame (19)
- # reagent (13)
- # reitit (16)
- # ring-swagger (2)
- # sci (38)
- # shadow-cljs (31)
- # spacemacs (3)
- # specter (14)
- # sql (14)
- # tools-deps (31)
- # vim (4)
- # xtdb (9)
if I have something declared with a macro like
(defmymacro x 1)
and then it's below in the same namespace, I can ignore easily the defmymacro
lines, but how do I ignore the usages of these vars?
@andrea.crotti I think you can use {:lint-as {your-awesome-lib.defmymacro clojure.core/def}
for this
ah nice didn't think about that
and also should Emacs with fly-clj-kondo read the .clj-kondo/config.edn file right?
it looks sometimes that running from the cli and what I see in Emacs are out of sync
should not be the case, the same binary is invoked. you might want to restart emacs and see if that solved anything
Is it possible to write tests for hooks? I don’t see how to define a project that makes clj-kondo.hooks-api
available.
@hugod I usually test this by just writing examples and see if they work: https://github.com/clj-kondo/config/blob/master/resources/claypoole/src/example.clj you could also just run clj-kondo (binary or JVM), capture the output (as strings or EDN) and then write tests on that (using the JVM or babashka)
I was hoping to run it in a project so I could also debug the hooks. clj-kondo
seems to be silently ignoring my config and I’ve no idea why. I’m not sure if the config is somehow wrong, or there is an error in my hook, or…
if the hook doesn't return a map with :node
then it continues to lint without a transformed node, but with the original node
could also be that you're using an old version of clj-kondo. many things can be wrong without clj-kondo being able to print an error
thanks for the offer - not sure I can post it as is. Using v2020.10.10. The config is valid edn at least 😉.
looks like clj-kondo sometimes manages to resolve the symbols that are being hooked and sometimes it doesn’t. I’m trying to find a pattern to this. It seems to work when linting the whole class path. The symbols are used unqualified in code through a :use
, which I guess is the root of the problem. Can’t change the code base in that respect though.
There is an issue about this: https://github.com/borkdude/clj-kondo/issues/1010 clj-kondo tries to do its best to resolve those vars, but this is at the very end of the linting, where the cache is consulted.
as clj-kondo doesn't recommend refer :all or :use I have marked this issue as low priority
In our case we have a language embedded in clojure, so we have great chunks of code that import the language with :use
.
Provided you have linted that other namespace as well. Else clj-kondo has no way of knowing what vars that other ns has
unfortunately, we usually have several. Definitely better behaviour once the cache is built.
👋 I’ve seen some mentions of orchestra.core/defn-spec
in the github issues and I’ve tried adding {:lint-as {orchestra.core/defn-spec clj-kondo.lint-as/def-catch-call}}
to my config.edn but I’m still getting unresolved-symbol
errors for all the fn args. Is there a solution to this?
Can you give an example? Clj-kondo now supports hooks so this might be the better way to support that macro
Usage looks something like this:
(defn-spec arities number?
([a number?]
(inc a))
([a number?, b number?]
(+ a b))
([a string?, b boolean?, c map?]
0))
Where the predicates are specsthat looks quite doable then yes. there are other examples here: https://github.com/clj-kondo/config