-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESlint: Handle modifiers on expect
in valid-expect
#3306
Conversation
not
being used, and check for typo
/cc @jkimbo |
I'm not good enough at Flow to resolve the type error... Too bad eslint does not have an official flow typing. Error:
|
Seg fault now, I don't think that's on me, though... |
From what I can tell, the Flow error is because the We just need to refine the type to be more specific. let propertyName = node.parent.property.name;
- let grandParentType = node.parent.parent.type;
+ let grandParent = node.parent.parent;
// a property is accessed, get the next node
if (grandParent.type === 'MemberExpression') {
// a modifier is used, just get the next one
if (expectProperties.indexOf(propertyName) > -1) {
- /* $FlowFixMe */
- propertyName = node.parent.parent.property.name;
- grandParentType = node.parent.parent.parent.type;
+ propertyName = grandParent.property.name;
+ grandParent = grandParent.parent;
} else {
// only a few properties are allowed
context.report({
message: `"${propertyName}" is not a valid property of expect.`,
node,
});
}
}
// matcher was not called
- if (grandParentType === 'ExpressionStatement') {
+ if (grandParent.type === 'ExpressionStatement') {
context.report({
message: `"${propertyName}" was not called.`,
node,
});
} |
@wyze Thank you, I could remove the suppression now! |
not
being used, and check for typoexpect
in valid-expect
Codecov Report
@@ Coverage Diff @@
## master #3306 +/- ##
==========================================
+ Coverage 63.9% 63.95% +0.05%
==========================================
Files 176 176
Lines 6475 6484 +9
Branches 4 4
==========================================
+ Hits 4138 4147 +9
Misses 2336 2336
Partials 1 1
Continue to review full report at Codecov.
|
Thanks @SimenB |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Part 1 of #3082 split up, see that for justification. I'll send a PR for locations soon™️
Test plan
See added tests which failed before this change