hey everyone, is clojure.spec intented to be use as a linter ? I mean currently it only outputs errors
but I see many opportunities it outputting warnings
instead. However I dont see anything in spec to “capture” the error and print it as a warning instead :thinking_face:
ps: not sure if this question belongs in this channel
@carocad Linters check code statically, Spec checks data structures and functions at runtime -- can you elaborate on how you image Spec being used in the former scenario?
> Linters check code statically
afaik, no such restriction exists. That is just the “standard” way
> Spec checks data structures and functions at runtime
maybe I am being naive but since you have access to the code on macro expansion it should be possible to pattern match the input code to issue warning/errors. Throwing would probably be bad but clojure introduced tap
so I guess it should be possible to just send the warning/errors over there.
Not sure yet how to make this work outside of a repl but so far this is just an idea 🙂
So you'd basically have to write a Spec for Clojure code and read in files and conform them to that Spec? 👀
yes
I'll be very interested in anything you produce in that vein. Sounds fascinating (but I'm seriously skeptical of the feasibility right now).
> I’m seriously skeptical of the feasibility right now me too … that is why I posted it here hoping that people with way more experience on the inner workings of clojure would point out any “obvious” error 😅
> So you’d basically have to write a Spec for Clojure code and read in files and conform them to that Spec? that would be for cli usage. I was hoping to “just” instrument the macro symbol and lint while on repl
if you want warnings instead of errors you could just catch the spec exceptions and handle them maybe?
@carocad are you aiming on specs for clojure.core? that has been done here as well: https://github.com/borkdude/speculative
@borkdude yeah I checked your work on speculative
great work btw 🙂 . Unfortunately it seems to only include functions not macros so I came here looking for more info 🙂
> if you want warnings instead of errors you could just catch the spec exceptions and handle them maybe?
I have not seen a way to do this since the error is thrown by the compiler. Not sure if the repl has a hook that I can use :thinking_face: