Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(prefer-to-contain): check that expect argument is defined before use #542

Merged
merged 2 commits into from Mar 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/rules/__tests__/prefer-to-contain.test.ts
Expand Up @@ -5,6 +5,7 @@ const ruleTester = new TSESLint.RuleTester();

ruleTester.run('prefer-to-contain', rule, {
valid: [
'expect().toBe(false);',
'expect(a).toContain(b);',
"expect(a.name).toBe('b');",
'expect(a).toBe(true);',
Expand Down
1 change: 1 addition & 0 deletions src/rules/prefer-to-contain.ts
Expand Up @@ -187,6 +187,7 @@ export default createRule({

if (
!matcher ||
!includesCall ||
(modifier && modifier.name !== ModifierName.not) ||
!isBooleanEqualityMatcher(matcher) ||
!isFixableIncludesCallExpression(includesCall)
Expand Down