This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-22
Channels
- # announcements (7)
- # babashka (1)
- # beginners (87)
- # boot (1)
- # cider (1)
- # clj-kondo (33)
- # cljfx (1)
- # cljs-dev (8)
- # clojars (3)
- # clojure (105)
- # clojure-austin (3)
- # clojure-europe (74)
- # clojure-finland (1)
- # clojure-korea (4)
- # clojure-nl (1)
- # clojure-uk (6)
- # clojurescript (10)
- # conjure (9)
- # cursive (29)
- # datalog (6)
- # datomic (13)
- # emacs (3)
- # events (4)
- # figwheel-main (1)
- # gratitude (1)
- # humbleui (6)
- # introduce-yourself (7)
- # jackdaw (1)
- # jobs (1)
- # lsp (29)
- # malli (3)
- # nbb (2)
- # podcasts-discuss (1)
- # portal (5)
- # re-frame (4)
- # reitit (28)
- # remote-jobs (5)
- # shadow-cljs (38)
- # tools-deps (46)
- # vim (6)
- # xtdb (24)
I have a function schema like this:
{:malli/schema [:=> [:cat :some-type [:maybe :coordinates]] :some-other-type]}
When I generate clj-kondo config for it, it generates an {:op :keys}
for it, which is not nilable
. So when a caller passes explicit nil
to it, it produces a linter warning. Is this expected? I could do [:or :coordinates :nil]
, but that produces :any
in clj-kondo, which is far less useful for linting.@ingesol Maybe it's better if malli generated :nilable/map
in this case, if there are no keys specified
@borkdude Having the :ops
spec there is very useful when there are keys specified. So :nilable
support would be nice. I also realize I should have inserted my actual spec for coordinates
, which is something like [:map [[:x number?] [:y number?]]
I'd like to be able to show a warning when someone requires a certain library in the ns
declaration.
Is that something I should do with clj-kondo hooks or maybe there are even easier ways?
I mean potentially even grepping could work in this particular case, but that's not really a great idea in general, would rather at least parse the code properly and grep.
that was release just today ) https://github.com/clj-kondo/clj-kondo/blob/master/doc/linters.md#discouraged-namespace
hehe that's great timing
I'll try it then, incredible turnaround, getting features even before you ask for them
I have a fn that is being used only by tests (but no production code is using it) is there a way of clj-kondo to hint me about these?
:discouraged-var
in combination with :config-in-ns
should work. You might also need to declare :ns-group
to separate test namespaces from production
Is there a particular reason you couldn't put this var into a test utility namespace? There's no reason that you can't have non-test vars (or even namespaces with no tests) in your tests directory.
its production code, but no one is using it yet, and I want the linter to say to me “Hey you have an unused function” this is not happening because the tests are currently using this function
Ah I see, that's the opposite of the problem we thought it was.
You can do this by just not including your tests on the path while you lint. I'm not 100% sure how you ensure that in kondo though.
Right, the point here would be to basically run the linter twice, once on the source directory, and once on the test directory. When running it on the tests you need the source to be on the path, and when you run it on the source directory you need the tests to not be on the path.
I don't know if there's a convenient way to do this at the moment however.
Can you re-state the problem? > I have a fn that is being used only by tests (but no production code is using it) > > is there a way of clj-kondo to hint me about these? It isn't at all clear to me what the problem is. What should clj-kondo hint?
This I think is actually about the clojure-lsp lint of unused public vars (@UKFSJSM38), but the problem is that vars should still be considered unused if they are used in tests.
the issue is: how clojure-lsp know that usage is from a test and not a different source-path?
I think it'd just be a config option for that lint that specifies ignored directories