This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-11
Channels
- # announcements (1)
- # beginners (67)
- # calva (4)
- # cider (6)
- # clj-kondo (26)
- # clojure (61)
- # clojure-belgium (2)
- # clojure-sweden (1)
- # clojurescript (12)
- # community-development (27)
- # cursive (2)
- # datascript (4)
- # datomic (20)
- # emacs (4)
- # funcool (1)
- # graphql (11)
- # honeysql (3)
- # malli (15)
- # membrane (6)
- # nbb (4)
- # nextjournal (7)
- # pathom (8)
- # polylith (7)
- # rdf (1)
- # re-frame (1)
- # releases (2)
- # shadow-cljs (42)
- # specter (3)
- # tools-deps (25)
- # xtdb (17)
For writing hooks: is it possible to get the lexical context of a macro?
(let [config {:a 1}]
(my-macro :watch [{:keys [a]} config] ...)) ;; rewrites into (let [{:keys [a]} config] ...)
kondo still cannot resolve symbol a
, I assume it's because it is not aware of the binding of config
an level aboveif you expand into (let [{:keys [a]} config] ...)
then there should be no problem, but perhaps your expansion isn't quite right?
It often helps to print the node before returning it so you can check it on the command line if it looks right
For sure, thanks! It's for linting clojureDart. f/widget
is the culprit macro
(let [config {:width 50.0}]
(f/widget
:watch [{:keys [width]} config]
(m/Container
.width width)))
This is what I get running clj-kondo --lint
(printing the nodes)
[clj-kondo] Linting file: src/acme/main.cljd
:inherit ()
(let [{:keys [width]} config] (m/Container .width width)) {:node <list: (let [{:keys [width]} config] (m/Container .width width))>}
src/acme/main.cljd:14:22: error: Unresolved symbol: width
linting took 248ms, errors: 1, warnings: 0
I remember that someone else has also written some hooks for this: https://clojurians.slack.com/archives/CHY97NXE2/p1650903306070559
cc @UL05W6AEM - perhaps these hooks can be bundled with that flutter wrapper library
Ah it's already there: https://github.com/Tensegritics/ClojureDart/blob/main/resources/clj-kondo.exports/tensegritics/clojuredart/hooks/flutter.clj
@U04AFSRJHNF Is that the same library you're referring to?
If so, then you can install those hooks with:
clj-kondo --lint $(clojure -Spath) --dependencies --copy-configs
Yeah, it's the same library. However, I think there's still something wrong... Maybe it's the line numbers
I was trying to fix this issue:https://github.com/Tensegritics/ClojureDart/issues/191
cool. Maybe @UL05W6AEM can help out as well. I'm going to sleep now, but I'll have a look later too
I haven't looked into it in about a half year; I'll see if my code is still in use and try to fix it.
Okay, here's the issue I see: There used to be flutter.alpha/widget, and I wrote the clj-kondo hook to support it. It's not working right now for two reasons: 1. It isn't referenced in clj-kondo/config. 2. Even if it will be referenced, it will not properly work because flutter.alpha2/widget is almost 80% diffrent.
@U04V15CAJ, can we add support for a :flds destructuring directly in clj-kondo (https://github.com/D00mch/clj-kondo/commit/26b5901b68d5897d9fcd888350913da8b8c2e9c2)?
@UL05W6AEM What is :flds
?
I suppose it's a custom syntax for field destructuring. I know it's tempting, but it's unfortunate that ClojureDart makes up new syntax since this isn't in general good for tooling compatibility. In squint I also have field destructuring but I used metadata to indicate that it's JS destructuring (inspired by the js-interop library):
^:js {:keys [a b c]
This way clj-kondo doesn't have to change for experimental language features. Other tooling that might have problems with this is cursive
cc @U2N9GDB1U @U3E46Q1DG@UL05W6AEM thanks for creating that PR to ClojureDart