Skip to content

Commit

Permalink
fix(no-if): report conditionals in call expressions
Browse files Browse the repository at this point in the history
fixes #557
  • Loading branch information
G-Rath committed Jul 26, 2020
1 parent 8670c39 commit 4cfcf08
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/rules/__tests__/no-if.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ ruleTester.run('conditional expressions', rule, {
},
],
invalid: [
{
code: `it('foo', () => {
expect(bar ? foo : baz).toBe(boo);
})
`,
errors: [
{
data: { condition: 'conditional' },
messageId: 'conditionalInTest',
},
],
},
{
code: `it('foo', () => {
const foo = bar ? foo : baz;
Expand Down
4 changes: 3 additions & 1 deletion src/rules/no-if.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ export default createRule({

return {
CallExpression(node) {
stack.push(isTestCase(node));
if (isTestCase(node)) {
stack.push(true);
}
},
FunctionExpression() {
stack.push(false);
Expand Down

0 comments on commit 4cfcf08

Please sign in to comment.