From 85e4195ecb9373befd42018a8fe4f4bb13cfa629 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Tue, 6 Aug 2019 11:29:54 +0200 Subject: [PATCH] chore: add no-negated-condition lint rule --- .eslintrc.js | 1 + src/rules/prefer-expect-assertions.js | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 867ca42f4..97b4b0afc 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -30,6 +30,7 @@ module.exports = { '@typescript-eslint/ban-ts-ignore': 'warn', '@typescript-eslint/ban-types': 'error', 'no-else-return': 'error', + 'no-negated-condition': 'error', eqeqeq: ['error', 'smart'], strict: 'error', 'prefer-template': 'warn', diff --git a/src/rules/prefer-expect-assertions.js b/src/rules/prefer-expect-assertions.js index 701bef6d7..0705aa4db 100644 --- a/src/rules/prefer-expect-assertions.js +++ b/src/rules/prefer-expect-assertions.js @@ -54,13 +54,13 @@ export default { 'CallExpression[callee.name=/^(it|test)$/][arguments.1.body.body]'(node) { const testFuncBody = node.arguments[1].body.body; - if (!isFirstLineExprStmt(testFuncBody)) { - reportMsg(context, node); - } else { + if (isFirstLineExprStmt(testFuncBody)) { const testFuncFirstLine = getFunctionFirstLine(testFuncBody); if (!isExpectAssertionsOrHasAssertionsCall(testFuncFirstLine)) { reportMsg(context, node); } + } else { + reportMsg(context, node); } }, };