From 31083c73db69d95e9d4111b6f5ee4d668a289e78 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Thu, 1 Aug 2019 11:44:58 +0300 Subject: [PATCH] coverage: Fixed coverage bug introduced in #2067 --- resources/inline-invariant.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/resources/inline-invariant.js b/resources/inline-invariant.js index f2d0134caa..90ce1ff469 100644 --- a/resources/inline-invariant.js +++ b/resources/inline-invariant.js @@ -46,12 +46,11 @@ module.exports = function inlineInvariant(context) { } else { path.replaceWith(invariantTemplate({ cond, args })); } + path.addComment('leading', ' istanbul ignore next '); } else if (calleeName === 'devAssert') { const [cond, args] = node.arguments; path.replaceWith(assertTemplate({ cond, args })); } - - path.addComment('leading', ' istanbul ignore next '); }, }, }; @@ -60,14 +59,11 @@ module.exports = function inlineInvariant(context) { const parentStatement = path.getStatementParent(); const previousStatement = parentStatement.container[parentStatement.key - 1]; - if (previousStatement.type === 'IfStatement') { - let lastIf = previousStatement; - while (lastIf.alternate && lastIf.alternate.type === 'IfStatement') { - lastIf = lastIf.alternate; - } - if (lastIf.alternate == null) { - t.addComment(lastIf, 'leading', ' istanbul ignore else '); - } + if ( + previousStatement.type === 'IfStatement' && + previousStatement.alternate == null + ) { + t.addComment(previousStatement, 'leading', ' istanbul ignore else '); } } };