This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-18
Channels
- # ai (6)
- # announcements (3)
- # babashka (5)
- # beginners (22)
- # calva (1)
- # cider (3)
- # clj-kondo (30)
- # clj-yaml (20)
- # clojure-europe (83)
- # clojure-spec (4)
- # clojurescript (6)
- # fulcro (1)
- # graalvm (16)
- # holy-lambda (5)
- # malli (33)
- # music (1)
- # nbb (14)
- # releases (3)
- # sci (13)
- # scittle (3)
- # shadow-cljs (35)
- # xtdb (7)
- # yada (2)
ok, here's the new :unused-value
linter. Please try it out locally if you can.
https://github.com/clj-kondo/clj-kondo/blob/master/doc/linters.md#unused-value
should kondo highlight tag metadata as unresolved symbols? i.e. (a ^foo b)
, with a being a macro which abuses metadata 🙂
It highlights foo
currently as unrecognized symbol.
• is there a way to ignore it for one specific macro if it appears as metadata?
• should unrecognized symbols as tags be highlighted?
is there a way: not currently they are warned about as they are usually (99%+ of the time) referring to Java classes. except in macros where people (ab)use them differently ;)
if the names in those tags are a limited set, you could just suppress them in the unresolved symbol config
they aren't limited, I'm trying to make life slightly more convenient for myself with spec's cat
and alt
for cat
I want the default name to be either blank or taken as the name of a keyword reference, with the option to provide it by metadata:
(% #{:find} ^find (| ::find-rel ::find-coll ::find-tuple ::find-scalar))
it expands to
(s/cat :_ #{:find} :find (| ::find-rel ::find-coll ::find-tuple ::find-scalar))
so I need to play some other tricks, like using a fully qualified symbol and filtering on the namespace
in my experience with these kind of macros: I always regret these nifty tricks 6 months later
You could try to write a kondo hook which removes the tags so kondo won't see then or just ignore all unresolved symbols in your macro with a config
Would it be possible/helpful to have a linter to warn against returning a value where it would always be discarded? Like returning a literal value at the end of a doseq
and other similar situations.
(doseq [x (get-all-x)]
{:result (foo x)})
@alex.sheluchin There is a new linter on master called :unused-value
which should warn if you use a pure function in doseq
as the return value. But it doesn't work yet for a map literal.
Perhaps you can file an issue. I can look into that, or if you want, you can do it yourself
Yes, that new linter is what gave me this idea. I haven't turned it on just yet and didn't realize it would warn about situations like that. Thanks, @U04V15CAJ. I'll make an issue about the enhancement for literal returns.
Looks like the var-info.edn list from Eastwood could also be used to implement https://github.com/clj-kondo/clj-kondo/issues/1757