Fork me on GitHub
#protorepl
<
2017-08-24
>
seancorfield00:08:47

@rgdelato Since you're the maintainer of that package, I hope you don't mind questions about it here?

rgdelato00:08:03

sure, I'll answer as best as I can

seancorfield00:08:40

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).

rgdelato00:08:44

Hmm. I don't know. Can you be a bit more specific? Where is your .joker file located and what exactly does it contain?

seancorfield00:08:44

{: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.

rgdelato00:08:25

That looks okay. Give me a sec, I'll try and reproduce the issue

seancorfield00:08:25

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.

rgdelato00:08:06

yeah, I'm seeing the same behavior as well

seancorfield00:08:12

I'll go open an issue on Joker.

rgdelato00:08:27

thanks, sorry about that

seancorfield00:08:56

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!)

seancorfield00:08:30

Which means Joker doesn't understand binding-style macros, I suspect...

seancorfield00:08:57

It's still extremely useful -- it found a bunch of unused namespace requires in the very first file I popped open!

seancorfield00:08:53

It also spotted an if-let that should have been just an if (the introduced local symbol was not used).

sparkofreason03:08:17

I had to create a .joker file for this to work on Windows, but it is now working. Pretty cool.

sparkofreason03:08:16

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.

sparkofreason17:08:33

@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.

rgdelato17:08:09

yeah, Joker doesn't have a --cljc option, and so it defaults to clj

sparkofreason21:08:59

@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.