Strips flow directive fully (#9197)

This commit is contained in:
Tan Li Hau 2018-12-17 16:27:56 +08:00 committed by Nicolò Ribaudo
parent 5cb38995c0
commit 52fb884550
9 changed files with 14 additions and 2 deletions

View File

@ -5,7 +5,7 @@ import { types as t } from "@babel/core";
export default declare(api => {
api.assertVersion(7);
const FLOW_DIRECTIVE = "@flow";
const FLOW_DIRECTIVE = /(@flow(\s+(strict(-local)?|weak))?|@noflow)/;
let skipStrip = false;
@ -28,7 +28,7 @@ export default declare(api => {
if (comments) {
for (const comment of (comments: Array<Object>)) {
if (comment.value.indexOf(FLOW_DIRECTIVE) >= 0) {
if (FLOW_DIRECTIVE.test(comment.value)) {
directiveFound = true;
// remove flow directive

View File

@ -0,0 +1,2 @@
// @noflow
const a = 1;

View File

@ -0,0 +1,2 @@
// @flow strict-local
const a = 1;

View File

@ -0,0 +1,2 @@
// @flow strict
const a = 1;

View File

@ -0,0 +1,2 @@
// @flow weak
const a = 1;