This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-14
Channels
- # aleph (2)
- # asami (1)
- # aws (6)
- # beginners (65)
- # cider (12)
- # clj-kondo (11)
- # cljs-dev (1)
- # clojure (179)
- # clojure-dev (15)
- # clojure-europe (5)
- # clojure-losangeles (5)
- # clojure-nl (1)
- # clojure-spec (6)
- # clojuredesign-podcast (50)
- # clojurescript (27)
- # cryogen (31)
- # data-science (10)
- # emacs (2)
- # events (1)
- # fulcro (39)
- # helix (4)
- # luminus (3)
- # malli (5)
- # nrepl (4)
- # off-topic (3)
- # pathom (1)
- # reveal (10)
- # shadow-cljs (5)
- # spacemacs (3)
- # tools-deps (6)
- # vscode (1)
- # xtdb (3)
Is it possible to teach clj-kondo that a particular macro defines many names, and so those names are no longer undefined (without declare
), e.g. : https://github.com/lvh/caesium/pull/74/files#diff-65e89161949c41707e1727f4a784969c02b9626b37ac949f704efcd26f7a9519R6
(as specified in that PR, it works: clj-kondo doesn't complain, because there's a declare
, I'm asking if there's a magic configuration incantation that makes it unnecessary)
@lvh if the macro is syntactically similar to a core one, then you can :lint-as
but for this macro that doesn't apply. E.g. if defconsts
was varargs like declare
then :lint-as
with clojure.core/declare
would work.
The other way is to write a hook to rewrite your function call to multiple top-level defs
or just declare
.
@lvh This works:
[email protected] /tmp $ cat foo.clj
(require '[foo.bar :as b])
(b/defconst [a b c])
a
b
c
[email protected] /tmp $ cat .clj-kondo/config.edn
{:hooks {:analyze-call {foo.bar/defconst hooks.defconst/defconst}} }
[email protected] /tmp $ cat .clj-kondo/hooks/defconst.clj
(ns hooks.defconst
(:require [clj-kondo.hooks-api :as api]))
(defn defconst [{:keys [:node]}]
(let [[_ vector-node] (:children node)
const-nodes (:children vector-node)
new-node (api/list-node (list* (api/token-node 'declare)
const-nodes))]
{:node (with-meta new-node
(meta node))}))
It's internal so I think I'll just change the API to take varargs and lint it like declare
I have an overloaded function, it has a 1-ary and a 2-ary version. I need to specify a :lint-as
that is different for each. Is that something that clj-kondo support?