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

refactor(expect-expect): clean up and use ESQuery syntax #171

Merged
merged 1 commit into from
Oct 2, 2018

Conversation

macklinu
Copy link
Collaborator

@macklinu macklinu commented Oct 2, 2018

This PR refactors to use selector syntax. Open to feedback on if this is a helpful refactor! 馃槃

Relates to #158, #169, #170

'CallExpression[callee.name=/^it|test$/]'(node) {
unchecked.push(node);
},
[`CallExpression[callee.name=/^${assertFunctionNames.join('|')}$/]`]() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This statement replaces the isExpectCall() function (same behavior).

},
[`CallExpression[callee.name=/^${assertFunctionNames.join('|')}$/]`]() {
// Return early in case of nested `it` statements.
for (const ancestor of context.getAncestors()) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved from using Array#some() to using a for..of loop because it felt more semantically correct. When we find the element we are looking for, call unchecked.splice() then break, instead of returning true in Array#some().

@macklinu macklinu merged commit 0276985 into master Oct 2, 2018
@macklinu macklinu deleted the esquery/expect-expect branch October 2, 2018 22:33
@SimenB
Copy link
Member

SimenB commented Oct 14, 2018

馃帀 This PR is included in version 21.24.2 馃帀

The release is available on:

Your semantic-release bot 馃摝馃殌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants