Flow: enable `//$ExpectFlowError` (#315)

As of this commit, adding the comment `//$ExpectFlowError` in flow-typed
code asserts that the next line must cause a flow error. If it does, no
error or warning is generated. If it does not, then this produces a flow
warning, which is visible to developers running `yarn flow` and
additionally causes travis to fail.

Test plan:

- As committed, `yarn travis` passes.
- I added `//$ExpectFlowError` above some line of flow-checked code which does
not currently throw an error. Afterwards, `yarn travis` failed (and a
helpful message was displayed in console on running `yarn flow`)
- I added the following bad code into one of our files:
```javascript
//$ExpectFlowError
const foo: string = 3;
```
As expected, `yarn flow` and `yarn travis` both passed.
This commit is contained in:
Dandelion Mané 2018-05-29 13:56:36 -07:00 committed by GitHub
parent 87b7df5957
commit 3b3564203c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -8,5 +8,7 @@ flow-typed
[lints]
[options]
suppress_comment=\\(.\\|\n\\)*\\$ExpectFlowError
include_warnings=true
[strict]

View File

@ -41,7 +41,15 @@ function makeTasks(mode /*: "BASIC" | "FULL" */) {
},
{
id: "flow",
cmd: ["npm", "run", "--silent", "flow", "--", "--quiet"],
cmd: [
"npm",
"run",
"--silent",
"flow",
"--",
"--quiet",
"--max-warnings=0",
],
deps: [],
},
{