Hello!
I recently discovered the --warnings-as-errors
flag and strongly prefer the workflow of being blocked by compiler warnings. Warnings in Elixir seem to be much more important (i.e. calls to undefined functions) than what I typically see as warnings in my experience with other languages (i.e. lint errors, unused variables).
I’m currently working through a Phoenix project but found that mix phx.server --warnings-as-errors
was unrecognized. Is there a way to tell mix
/Elixir to use --warnings-as-errors
under the hood when running phx.server
?
Thank you for your help!
1 Like
Hello!
--warnings-as-errors
is a flag for mix compile
.
What do you expect from --warnings-as-errors
when running phx.server
? Do not start server at all?
If so, then this command may help:
$ mix do compile --warnings-as-errors, phx.server
3 Likes
If you want to enable that flag by default you can use:
elixirc_options: [
:warnings_as_errors
]
9 Likes
Thanks for the responses!
Adding elixirc_options: [warnings_as_errors: true]
to my project
in mix.exs
achieved my goal! Now warnings display as errors when I am working in Phoenix, which works great with live reload. If I start the server with an error, it fails to run - which is fine with me.
The only down side is that the warning itself is not printed to the browser - it just shows a generic compilation error
screen. The console in which I ran mix phx.server
still displays the rest of the information, at least. I assume there is a configuration setting somewhere to output those warnings to the web display, but for now I am happy.
Thank you again!
1 Like