This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-31
Channels
- # announcements (3)
- # aws-lambda (1)
- # babashka (122)
- # beginners (241)
- # calva (28)
- # cider (7)
- # clara (7)
- # clj-kondo (43)
- # clojars (5)
- # clojure (326)
- # clojure-europe (60)
- # clojure-italy (2)
- # clojure-nl (4)
- # clojure-spec (21)
- # clojure-uk (4)
- # clojurescript (162)
- # cursive (30)
- # datomic (3)
- # editors (5)
- # emacs (4)
- # figwheel-main (1)
- # fulcro (24)
- # gratitude (3)
- # helix (7)
- # honeysql (20)
- # improve-getting-started (1)
- # introduce-yourself (11)
- # jobs (3)
- # joker (2)
- # kaocha (15)
- # lsp (21)
- # lumo (2)
- # meander (3)
- # off-topic (34)
- # re-frame (6)
- # reagent (1)
- # releases (4)
- # rum (2)
- # shadow-cljs (37)
- # spacemacs (16)
- # tools-deps (16)
- # vim (23)
- # xtdb (32)
is it possible to exclude a given symbol’s use?
something like {:disallowed [clojure.core/cond]}
and then if that symbol is used, a warning/error is thrown
There is an open issue about this: https://github.com/clj-kondo/clj-kondo/issues/996 Feel free to provide feedback or upvote it using a thumbs up
You can also leverage the analysis output to look for used vars and do your own thing with it, currently
Interesting concept, but I gotta ask, of all the vars you could disallow, cond
?
well, 1) it’s just an example, but 2) i adapted Racket’s cond
and want to use it in my library and want to enforce using it instead of the built-in cuz i am the literal devil
very cool, thank you. i’ve subscribed to that issue, don’t have much to add yet tho
just wrote my first hook! Very nifty and easy to use.
To double check, if I want to export a library’s config and hooks, this should be the folder structure? (output from git status)
new file: .clj-kondo/config.edn
new file: .clj-kondo/hooks/cond_plus.clj
new file: resources/clj-kondo.exports/cond-plus/cond-plus/config.edn
new file: resources/clj-kondo.exports/cond-plus/cond-plus/hooks/cond_plus.clj
@nbtheduke Yes. You can even add resources/clj-kondo.exports/cond-plus/cond-plus
to :config-paths
into your .clj-kondo/config.edn
so you don't have to duplicate your config
I’m struggling to get this to work
noah@Noahs-MBP ~/Personal/cond-plus [master ≡ +3 ~2 -0 | +0 ~1 -0]
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: .clj-kondo/config.edn
modified: .gitignore
new file: resources/clj-kondo.exports/cond_plus/cond_plus/cond_plus/cond_plus.clj
new file: resources/clj-kondo.exports/cond_plus/cond_plus/config.edn
modified: test/cond_plus/core_test.clj
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: test/cond_plus/core_test.clj
noah@Noahs-MBP ~/Personal/cond-plus [master ≡ +3 ~2 -0 | +0 ~1 -0]
$ cat .clj-kondo/config.edn
{:config-paths ["resources/clj-kondo.exports/cond_plus/cond_plus"]}
noah@Noahs-MBP ~/Personal/cond-plus [master ≡ +3 ~2 -0 | +0 ~1 -0]
$ cat resources/clj-kondo.exports/cond_plus/cond_plus/config.edn
{:linters {:cond-plus/empty-else {:level :error}
:cond-plus/missing-fn {:level :error}
:cond-plus/non-final-else {:level :error}
:cond-plus/sequence {:level :error}
:unresolved-symbol {:exclude [(cond-plus.core/cond+ [=> else])]}}
:hooks {:analyze-call {cond-plus.core/cond+ cond-plus.cond-plus/cond+}}}
noah@Noahs-MBP ~/Personal/cond-plus [master ≡ +3 ~2 -0 | +0 ~1 -0]
$ clj-kondo --lint .
./test/cond_plus/core_test.clj:126:30: error: Unresolved symbol: =>
./test/cond_plus/core_test.clj:168:27: error: Unresolved symbol: else
linting took 67ms, errors: 2, warnings: 0
i’ve modified the test file to produce an error, which should be caught by kondo, and instead it’s telling me about something that should be ignored
$ head resources/clj-kondo.exports/cond_plus/cond_plus/cond_plus/cond_plus.clj
(ns cond-plus.cond-plus
(:require [clj-kondo.hooks-api :as api]))
(defn analyze-clauses [clauses]
(reduce
(fn [found-else? clause]
;; non-sequence clause
(if (not (or (api/list-node? clause)
(api/vector-node? clause)))
(let [{:keys [row col]} (meta clause)]
(lol at cond_plus/cond_plus/cond_plus/cond_plus.clj
)
no worries
did some digging and it seems that the :config-paths
is relative from the config.edn
file, not from the project root/where clj-kondo
is called?
okay, seems i misunderstood that
yep! doing that makes it work
@nbtheduke Also note that you have to lowercase your directory names: cond_plus/cond_plus
i suspect this is outside the scope of this channel, but i’ve already published the library with that org, so i’m not sure how I would go about changing it
i’ll keep that in mind in the future