From a00f44c1a076fd24ff8cc17c75b6d4365190b5de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Verit=C3=A9=20Mugabo?= Date: Sun, 9 Apr 2023 10:53:23 +0200 Subject: [PATCH] feat: updated smoke tests (#150) --- src/rules/prefer-comparison-matcher.test.ts | 3 ++- src/rules/prefer-comparison-matcher.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rules/prefer-comparison-matcher.test.ts b/src/rules/prefer-comparison-matcher.test.ts index be8dc13..2e29cd2 100644 --- a/src/rules/prefer-comparison-matcher.test.ts +++ b/src/rules/prefer-comparison-matcher.test.ts @@ -18,7 +18,8 @@ describe(RULE_NAME, () => { 'expect(a !== "string").toStrictEqual(true)', 'expect(5 != a).toBe(true)', 'expect(a == "string").toBe(true)', - 'expect(a == "string").not.toBe(true)' + 'expect(a == "string").not.toBe(true)', + 'expect().fail(\'Should not succeed a HTTPS proxy request.\');' ], invalid: [ { diff --git a/src/rules/prefer-comparison-matcher.ts b/src/rules/prefer-comparison-matcher.ts index f2ac21d..b281c92 100644 --- a/src/rules/prefer-comparison-matcher.ts +++ b/src/rules/prefer-comparison-matcher.ts @@ -9,7 +9,7 @@ type MESSAGE_IDS = 'useToBeComparison'; type Options = [] const isString = (node: TSESTree.Node) => { - return isStringNode(node) || node.type === AST_NODE_TYPES.TemplateLiteral + return isStringNode(node) || node?.type === AST_NODE_TYPES.TemplateLiteral } const isComparingToString = (expression: TSESTree.BinaryExpression) => { @@ -82,7 +82,7 @@ export default createEslintRule({ const { matcher } = vitestFnCall const matcherArg = getFirstMatcherArg(vitestFnCall) - if (comparison.type !== AST_NODE_TYPES.BinaryExpression || + if (comparison?.type !== AST_NODE_TYPES.BinaryExpression || isComparingToString(comparison) || // eslint-disable-next-line no-prototype-builtins !EqualityMatcher.hasOwnProperty(getAccessorValue(matcher)) ||