-
Notifications
You must be signed in to change notification settings - Fork 18
Adds jest/no-if
#232
Adds jest/no-if
#232
Conversation
310ed4a
to
bdf93cd
Compare
lib/rules/jest/no-if.js
Outdated
'fit', | ||
'test', | ||
'xtest', | ||
'describe', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure you need to include describe
blocks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured I'd leave it cause it's not like we want to allow:
describe('SomeThing', () => {
if(!someFlag) {
it('testing', () => {
//...
})
}
})
} | ||
|
||
context.report({ | ||
messageId: 'noIf', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL
lib/rules/jest/no-if.js
Outdated
if (notTestFunction(node) || hasEmptyBody(node)) { | ||
return; | ||
} | ||
inCallExpression = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The iffy thing with doing this in scope is that nesting can throw things off. Nesting might not be too much of an issue here but you still might want to go with the more formal mechanism for this (state)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify what you mean when you say more formal mechanism for this (state)
?
Fixing the nesting part should be easy if I just keep track of the depth instead of just a boolean for being in a call expression or not. Maybe that is what you meant by state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant having it on the context.state
or whatever that field is called so that it is scoped to the part of the tree where you are actually inside the test block (structurally, I don't think it makes much of a difference, but that's what the feature is there for)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait actually maybe I am getting mixed up with Babel plugins :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol you are. I only know because I did the same thing. 😛
version "1.2.0" | ||
resolved "https://registry.yarnpkg.com/merge/-/merge-1.2.0.tgz#7531e39d4949c281a66b8c5a6e0265e8b05894da" | ||
integrity sha1-dTHjnUlJwoGma4xabgJl6LBYlNo= | ||
merge@1.2.1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From here I guess: d45d8d0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Closes #227