bsermons / flycheck-elm

Flycheck support for the elm language
GNU General Public License v3.0
18 stars 8 forks source link

Using flycheck-elm and elm-mode generates/overwrites index.html on file save #5

Closed xeob closed 8 years ago

xeob commented 8 years ago

Hi @bsermons, whenever I edit an .elm file in elm-mode with flycheck-elm enabled, an index.html gets generated (and overwrites an existing file if there was one). Such thing does not happen when the flycheck-elm is disabled. Is there any way to tweak this behavior?

trezona-lecomte commented 8 years ago

Hey @knikel, I noticed this as well after the upgrade to Elm 0.16. Previously elm-make defaulted to an output file called elm.js, but now it defaults to index.html. This impacts us because flycheck-elm uses elm-make under the hood to do its syntax checking.

There is an open issue on elm-make regarding the change of this default: https://github.com/elm-lang/elm-make/issues/68

If you want a quick fix you can just manually add the --output argument after --report=json in flycheck-elm.el:

(flycheck-define-checker elm
  "A syntax checker for elm-mode using the json output from elm-make"
  :command ("elm-make" "--report=json" "--output=elm.js"

Note that elm.js could be any filename you want with a js or html extension.

trezona-lecomte commented 8 years ago

Hey @bsermons, I've submitted https://github.com/bsermons/flycheck-elm/pull/6 as a possible way of dealing with this. Let me know what you think.

xeob commented 8 years ago

Thanks a lot @trezona-lecomte, I didn't get that far with tracing it yet! :clap: for the #6!

bsermons commented 8 years ago

I think that could work. Is it possible to set that variable to something different for different projects?

I was toying around with some of the options to get it to output to the temp directory from this doc: http://www.flycheck.org/manual/latest/Defining-syntax-checkers.html#Defining-syntax-checkers Specifically, the options from the flycheck-substitute-argument function mentioned outputting to null-device and that seems to work for me with the following code

(flycheck-define-checker elm
  "A syntax checker for elm-mode using the json output from elm-make"
  :command ("elm-make" "--report=json"
            "--output" null-device
            (eval (or flycheck-elm-main-file buffer-file-name)))
  :error-parser flycheck-elm-parse-errors
  :modes elm-mode)

Need to test it more tomorrow on a windows machine. What do you think about that solution @trezona-lecomte or do you think we should still be able to specify the output file?

trezona-lecomte commented 8 years ago

Hey @bsermons, yeah I think that's definitely a more sane default (output to null-device).

What if we were to default to null-device, but still allow the option to specify an output file? I'll put together an amended PR with that option if you like.

bsermons commented 8 years ago

Yea that would be great if you can. If not, I can try and get around to adding it tomorrow.

trezona-lecomte commented 8 years ago

I've updated #6 with a commit that means we default to null-device, with the option to provide an output file, but I haven't yet tested it on a windows machine.

bsermons commented 8 years ago

This is fixed in latest commit. @trezona-lecomte added the variableflycheck-elm-output-file which defaults to write to /dev/null.

xeob commented 8 years ago

Thanks a bunch!