borkdude / flycheck-clj-kondo

Emacs integration for clj-kondo via flycheck
94 stars 17 forks source link

Support for file-less buffers (try 2) #7

Closed didibus closed 4 years ago

didibus commented 4 years ago

Same as: https://github.com/borkdude/flycheck-clj-kondo/pull/5 , but fixes the issue that one had when handling "edn" files.

The bug was that I forgot to wrap the let in an extra set of parenthesis, so buffer-file-name was always nil, and it would never use the file name to choose the checker. Seems like I would need a clj-kondo for emacs-lisp as well ;)

For clj, cljs, and cljc, it turned out relying on the mode always worked anyways, which is why I didn't catch that bug in the prior PR, but edn has no mode, so only the filename can be used, and this is where it failed.

I decided to also change the logic for the mode picking, to use pcase and choose the right equality check to use at macro-expansion, I found that to be clearer and better.

This time I tested all the following cases:

I also tested the scenario where someone chooses the wrong major mode for the given file, say you open a .clj file and choose clojurec-mode for example. In those cases, no clj-kondo linters are activated, which is the current behavior as well, because it has an associated file, it will use the file based predicate, and that would make it false for the mode flycheck is using.

didibus commented 4 years ago

Also fixes: https://github.com/flycheck/flycheck/issues/1665#

borkdude commented 4 years ago

Thanks both @didibus and @cpitclaudel