@rgdelato Since you're the maintainer of that package, I hope you don't mind questions about it here?
sure, I'll answer as best as I can
I have the following code:
(api/with-validated-params [::api-spec/reset-new-stats nil]
(act/visit (:user-id-int params) (:pagename params))
(resp/response {})))
and it flags params
as being undeclared -- I've told Joker that api.support/with-validated-params
is a macro but that hasn't helped (the macro introduces that symbol).Hmm. I don't know. Can you be a bit more specific? Where is your .joker
file located and what exactly does it contain?
{:known-macros [api.support/with-validated-params
api/with-validated-params]}
Just in case it didn't understand the ns alias of api.support
to api
, and it's in a parent folder a few levels up from that source file.That looks okay. Give me a sec, I'll try and reproduce the issue
Looks like a limitation on how :known-macros
works. If I have (api/with-validated-params foo ...)
it won't flag that, but it doesn't understand a macro may introduce new names it seems.
yeah, I'm seeing the same behavior as well
I'll go open an issue on Joker.
thanks, sorry about that
I could change the macro to require the symbol name in the vector that is the first argument -- updating the code to
(api/with-validated-params [params ::api-spec/reset-new-stats nil]
(act/visit (:user-id-int params) (:pagename params))
(resp/response {})))
makes the error go away (interestingly, Joker thinks the symbol is a top-level one, and all references to params
pass the linter at that point!)Which means Joker doesn't understand binding-style macros, I suspect...
It's still extremely useful -- it found a bunch of unused namespace requires in the very first file I popped open!
It also spotted an if-let
that should have been just an if
(the introduced local symbol was not used).
I had to create a .joker file for this to work on Windows, but it is now working. Pretty cool.
Does joker understand namespace aliases? I'm getting an error on a keyword using an aliased namespace. Actually, I don't think the namespace even exists, it's clojure.spec.test.check
.
@rgdelato For CLJC files, it appears that linter-joker only runs joker with the --lintclj
option, since it doesn't catch errors in #?(:cljs ...)
blocks. I am able to see CLJS errors if I run with --lintcljs
from the command line.
yeah, Joker doesn't have a --cljc
option, and so it defaults to clj
@rgdelato I tried to hack joker to have a`--cljc` that just ran lint twice, but it seems pretty deeply wired to run exactly once. Seems like it should be possible to run the command line joker twice from linter-joker. I'd be willing to take a shot at that and make a PR if successful. If you have any pointers, please let me know.