fix comments containg @flow being completely removed from output rather than just the specific directive - fixes #2022
This commit is contained in:
parent
641ee9d883
commit
4833dad4e2
@ -13,6 +13,11 @@ _Note: Gaps between patch versions are faulty, broken or test releases._
|
||||
|
||||
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
|
||||
|
||||
## 5.7.4
|
||||
|
||||
* **Bug Fix**
|
||||
* Fix comments containg `@flow` being completely removed from output rather than just the specific directive.
|
||||
|
||||
## 5.7.3
|
||||
|
||||
* **Bug Fix**
|
||||
|
||||
@ -4,6 +4,8 @@ export var metadata = {
|
||||
group: "builtin-trailing"
|
||||
};
|
||||
|
||||
const FLOW_DIRECTIVE = "@flow";
|
||||
|
||||
/**
|
||||
* [Please add a description.]
|
||||
*/
|
||||
@ -16,8 +18,12 @@ export var visitor = {
|
||||
|
||||
Program(node, parent, scope, file) {
|
||||
for (var comment of (file.ast.comments: Array)) {
|
||||
if (comment.value.indexOf("@flow") >= 0) {
|
||||
comment._displayed = true;
|
||||
if (comment.value.indexOf(FLOW_DIRECTIVE) >= 0) {
|
||||
// remove flow directive
|
||||
comment.value = comment.value.replace(FLOW_DIRECTIVE, "");
|
||||
|
||||
// remove the comment completely if it only consists of whitespace and/or stars
|
||||
if (!comment.value.replace(/\*/g, "").trim()) comment._displayed = true;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -6,4 +6,9 @@
|
||||
* @flow
|
||||
*/
|
||||
|
||||
/**
|
||||
* @providesModule Foo
|
||||
* @flow
|
||||
*/
|
||||
|
||||
foo();
|
||||
|
||||
@ -1 +1,6 @@
|
||||
/**
|
||||
* @providesModule Foo
|
||||
*
|
||||
*/
|
||||
|
||||
foo();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user