From 3b3564203ccf6087b49c1e8494d14e675fe111ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dandelion=20Man=C3=A9?= Date: Tue, 29 May 2018 13:56:36 -0700 Subject: [PATCH] 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. --- .flowconfig | 2 ++ config/travis.js | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.flowconfig b/.flowconfig index 0d26140..ba01d69 100644 --- a/.flowconfig +++ b/.flowconfig @@ -8,5 +8,7 @@ flow-typed [lints] [options] +suppress_comment=\\(.\\|\n\\)*\\$ExpectFlowError +include_warnings=true [strict] diff --git a/config/travis.js b/config/travis.js index 1ada235..10ef36b 100644 --- a/config/travis.js +++ b/config/travis.js @@ -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: [], }, {