Skip to content

Commit ce8b4cd

Browse files
coverage: Fixed coverage bug introduced in #2067 (#2070)
1 parent d130a60 commit ce8b4cd

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

resources/inline-invariant.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@ module.exports = function inlineInvariant(context) {
4646
} else {
4747
path.replaceWith(invariantTemplate({ cond, args }));
4848
}
49+
path.addComment('leading', ' istanbul ignore next ');
4950
} else if (calleeName === 'devAssert') {
5051
const [cond, args] = node.arguments;
5152
path.replaceWith(assertTemplate({ cond, args }));
5253
}
53-
54-
path.addComment('leading', ' istanbul ignore next ');
5554
},
5655
},
5756
};
@@ -60,14 +59,11 @@ module.exports = function inlineInvariant(context) {
6059
const parentStatement = path.getStatementParent();
6160
const previousStatement =
6261
parentStatement.container[parentStatement.key - 1];
63-
if (previousStatement.type === 'IfStatement') {
64-
let lastIf = previousStatement;
65-
while (lastIf.alternate && lastIf.alternate.type === 'IfStatement') {
66-
lastIf = lastIf.alternate;
67-
}
68-
if (lastIf.alternate == null) {
69-
t.addComment(lastIf, 'leading', ' istanbul ignore else ');
70-
}
62+
if (
63+
previousStatement.type === 'IfStatement' &&
64+
previousStatement.alternate == null
65+
) {
66+
t.addComment(previousStatement, 'leading', ' istanbul ignore else ');
7167
}
7268
}
7369
};

0 commit comments

Comments
 (0)