What warnings/errors do you always enable (or disable)?


#1

Bucklescript (and any Reason project compiled using it) has highly configurable warnings and errors in bsconfig.json. These are mostly inherited from the OCaml compiler, which has a list of options in its manual. Specifically, we’re interested in the -w and -warn-error settings which are equivalent to the bsconfig.json "warnings" settings "number" and "error", respectively. There are a ton of options, so it can be a bit overwhelming to try to figure out what settings you might want to use here.

How do you configure your warnings and errors in your projects? What are the must-have settings to catch those most insidious bugs? Are there any that are more trouble than they’re worth? Please share your config and briefly explain what the settings do and why you chose them.

For reference, here are the defaults for BuckleScript and OCaml. You should not need to explicitly set these unless you’re changing the default. A + enables the warning number that follows, while a - disables the warning or error immediately following it. A range of numbers is specified by placing .. in between. The a means “all”.

BuckleScript defaults to the following, which overrides some of the OCaml defaults:

{
  "warnings": {
    "number": "-30-40+6+7+27+32..39+44+45+101",
    "error": "-a"
  }
}

Default in OCaml 4.02:

{
  "warnings": {
    "number": "+a-4-6-7-9-27-29-32..39-41..42-44-45",
    "error": "-a"
  }
}

Default in OCaml 4.06:

{
  "warnings": {
    "number": "+a-4-6-7-9-27-29-32..42-44-45-48-50-60",
    "error": "-a+31"
  }
}

Fully destructure a record
#2

Fwiw the ocaml defaults are partially in such way to preserve backward-compatibility (don’t wanna suddenly add a warning-error or remove an error and cause stuff to fail compiling). BS was new so had a bit more leeway.

As an aside, it helps if folks keep their dependencies down. Such changes would be a bit more trivial if you just go in your codebase and fix them in minutes. Different story if you have third-party deps


#3

Is it the case that whatever warning settings you have will be used when compiling any dependencies as well? Does it then ignore the warning settings in the dependency’s bsconfig? If so, it might be nice if that behavior was configurable (since you’re not necessarily in control of the third party deps).


#4

it’s nottttttttttttt (20 chars)


#5

Well that’s good. I got confused about your comment regarding dependencies, but I guess you just meant that it can make changing the defaults in the compiler more difficult.