Strips flow directive fully (#9197)
This commit is contained in:
parent
5cb38995c0
commit
52fb884550
@ -5,7 +5,7 @@ import { types as t } from "@babel/core";
|
|||||||
export default declare(api => {
|
export default declare(api => {
|
||||||
api.assertVersion(7);
|
api.assertVersion(7);
|
||||||
|
|
||||||
const FLOW_DIRECTIVE = "@flow";
|
const FLOW_DIRECTIVE = /(@flow(\s+(strict(-local)?|weak))?|@noflow)/;
|
||||||
|
|
||||||
let skipStrip = false;
|
let skipStrip = false;
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ export default declare(api => {
|
|||||||
|
|
||||||
if (comments) {
|
if (comments) {
|
||||||
for (const comment of (comments: Array<Object>)) {
|
for (const comment of (comments: Array<Object>)) {
|
||||||
if (comment.value.indexOf(FLOW_DIRECTIVE) >= 0) {
|
if (FLOW_DIRECTIVE.test(comment.value)) {
|
||||||
directiveFound = true;
|
directiveFound = true;
|
||||||
|
|
||||||
// remove flow directive
|
// remove flow directive
|
||||||
|
|||||||
@ -0,0 +1,2 @@
|
|||||||
|
// @noflow
|
||||||
|
const a = 1;
|
||||||
@ -0,0 +1 @@
|
|||||||
|
const a = 1;
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
// @flow strict-local
|
||||||
|
const a = 1;
|
||||||
@ -0,0 +1 @@
|
|||||||
|
const a = 1;
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
// @flow strict
|
||||||
|
const a = 1;
|
||||||
@ -0,0 +1 @@
|
|||||||
|
const a = 1;
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
// @flow weak
|
||||||
|
const a = 1;
|
||||||
@ -0,0 +1 @@
|
|||||||
|
const a = 1;
|
||||||
Loading…
x
Reference in New Issue
Block a user