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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for async functions in no-synchronous-tests #138

Merged
merged 2 commits into from Jun 19, 2017
Merged

Added support for async functions in no-synchronous-tests #138

merged 2 commits into from Jun 19, 2017

Conversation

jawadst
Copy link
Contributor

@jawadst jawadst commented Jun 14, 2017

One note: the updated rule throws errors when the provided options do not match a certain format.
eslint itself usually does not test those exception cases (it ignores them for code coverage: https://github.com/eslint/eslint/blob/master/lib/rules/new-cap.js#L38) and I wasn't sure how to test an exception with the RuleTester so I ignored those cases as well.

@jawadst jawadst mentioned this pull request Jun 14, 2017
@lo1tuma
Copy link
Owner

lo1tuma commented Jun 16, 2017

To validate options you can provide a JSON schema which ESLint will take to check if the passed options match against the schema. So I guess we could just define a schema here instead of implementing our own validation logic.

}

return callee.name;
function getCalleeName(callee) {
Copy link
Owner

Choose a reason for hiding this comment

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

I know this function was already there before but it would be nice to re-use the getNodeName method from our AST utils.

💅

// allow arrow statements calling a promise with implicit return.
returnStatement = bodyStatement;
}
function getAllowedAsyncMethocsFromOptions(options) {
Copy link
Owner

Choose a reason for hiding this comment

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

Typo? I guess it should be getAllowedAsyncMethodsFromOptions.

Copy link
Owner

@lo1tuma lo1tuma left a comment

Choose a reason for hiding this comment

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

Overall it looks good 👍, but I would change the option validation to use a JSON schema.

@jawadst
Copy link
Contributor Author

jawadst commented Jun 18, 2017

I have implemented the requested changes. I am using isTestCase/isHookIdentifier from ast utils and got rid of the list of identifiers for tests/hooks in no-synchronous-tests.

Copy link
Owner

@lo1tuma lo1tuma left a comment

Choose a reason for hiding this comment

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

Nice, LGTM.

Thanks for your contribution.

@lo1tuma lo1tuma merged commit d40bbfe into lo1tuma:master Jun 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants