Quick tip: treat warnings as errors in ReasonML
August 18, 2018
I've been playing with Reason a lot lately as I'm building an open source personal note taking app. One thing I like to do in my projects is be strict about warnings by treating them as errors, so I wanted to do this in Reason as well.
I couldn't find exactly how to do this in the docs, so I started looking at some OCaml resources and stumbled upon this chapter of the Real World OCaml book where it was mentioned in passing that
@A can be used to enable all warnings.
Putting it all together, for Reason this means putting the following in your
"bsc-flags": ["-warn-error", "@A"]
This worked, but also suddenly enabled warnings that were not enabled before and looked pretty harmless. Fortunately, it's possible to disable warnings on a per warning basis like so:
"bsc-flags": ["-warn-error", "@A", "-w", "@A-9-40-41-42-102"]
These numbers like
40 and so forth refer to specific compiler warnings documented here. The Bucklescript compiler also outputs these numbers as warnings are generated so it's easy to figure out which ones you want to put in there.