Flycheck support for the elm language
(eval-after-load 'flycheck
'(add-hook 'flycheck-mode-hook #'flycheck-elm-setup))
Flycheck support for the elm language
License: GNU General Public License v3.0
Flycheck doesn't yet have a way to set the working directory for checkers, and in this case they need to run in the directory that has elm-package.json
Relevant issues
flycheck/flycheck#312
flycheck/flycheck#754
My workaround at the moment is to set the default-directory
in an elm-mode-hook
.
I am using Node 6.2.2, Elm 0.17.1 and Emacs 24.5.1
I think this is an issue with elm-make
though I just wanted to check to see if there is another answer. For some types of elm errors flymake-elm
exits abnormally and the checker stops. It spits out a normal elm error message into the mini-buffer and flycheck
seems to hang.
I did some checking in the command line and elm-make
does not always return a json message even thought the --report=json
flag is used. And from reading the source code of flymake-elm
, it requires elm-make
to return json messages in order to properly parse them.
Here are a few of the types of errors that create the issue:
This file uses 0.16 syntax
-- Main.elm
module Main where
import Html exposing (..)
main : Html
main = text "Test"
Executing elm-make --report=json Main.elm
returns the message below rather than json.
-- SYNTAX PROBLEM ----------------------------------------------------- Main.elm
I ran into something unexpected when parsing your code!
1| module Main where
^
I am looking for one of the following things:
something like `exposing (..)` which replaced `where` in 0.17
whitespace
This file misspells exposing
as Fexposing
-- Main.elm
module Main exposing (..)
import Html Fexposing (..)
main : Html
main = text "Test"
Executing elm-make --report=json Main.elm
returns the message below rather than json.
-- SYNTAX PROBLEM ----------------------------------------------------- Main.elm
I need a fresh line to start a new declaration. This means a new line that
starts with stuff, not with spaces or comments.
3| import Html Fexposing (..)
^
I am looking for one of the following things:
reserved word `as`
reserved word `exposing`
whitespace
This file tries to import an uninstalled module
module Main exposing (..)
import Unknown -- Some known module
import Html exposing (..)
main : Html
main = text "Test"
Executing elm-make --report=json Main.elm
returns the message below rather than json.
I cannot find module 'Unknown'.
Module 'Main' is trying to import it.
Potential problems could be:
* Misspelled the module name
* Need to add a source directory or new dependency to elm-package.json
Elm 0.19 added additional information and changed the structure of the output JSON containing the errors.
I'm not sure if there is spec somewhere on what the full error could look like. There is however this package that decodes it in to Elm values https://package.elm-lang.org/packages/elm/project-metadata-utils/latest/Elm-Error
Hi there, and thanks for flycheck-elm. I use it every day at work and it saves me countless hours.
I have one question about the license of the package. The LICENSE file is gpl version 2 but the source files all refer to version 3+. Which is the real license for the package?
Thanks again!
Cheers,
John
Given this (obviously) broken code
test : String
test = 42
the error message seen in flycheck is pretty much lacking in details
The type annotation for `test` does not match its definition.
Sure, in the trivial case such above that's often good enough, but when the types are more complex and the type mismatch much less obvious it would be very useful to be able to see the rest of the error message somehow
The type annotation for `test` does not match its definition.
1| test : String
^^^^^^
The type annotation is saying:
String
But I am inferring that the definition has this type:
number
I've learned about flycheck-compile
but with the json output it's not at all readable. Seems the only way to see the full error message is to jump to shell and run elm-make
manually :-/
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?
My issue is when running the linting on a file from emacs C-c ! C-c
I get the following
-*- mode: compilation; default-directory: "~/work/elm-starter/src/elm/" -*-
Compilation started at Wed Oct 5 22:12:13
elm-make --report\=json /Users/nadeem/work/elm-starter/src/elm/Main.elm --output\=/dev/null
elm-make: elm-package.json: openBinaryFile: does not exist (No such file or directory)
Compilation exited abnormally with code 1 at Wed Oct 5 22:12:13
but if I run the following from the command line
elm-make --report\=json /Users/nadeem/work/elm-starter/src/elm/Main.elm --output\=/dev/null
I get
[{"tag":"TYPE MISMATCH","overview":"The argument to function `class` is causing a mismatch.","subregion":{"start":{"line":62,"column":17},"end":{"line":62,"column":18}},"details":"Function `class` is expecting the argument to be:\n\n String\n\nBut it is:\n\n number","region":{"start":{"line":62,"column":11},"end":{"line":62,"column":18}},"type":"error","file":"/Users/nadeem/work/elm-starter/src/elm/Main.elm"}]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.