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

False positives for any function named "async" in classes or object literals #30

Open
Melab opened this issue Jun 11, 2022 · 2 comments

Comments

@Melab
Copy link

Melab commented Jun 11, 2022

isAsyncFunction will return true for both (class { async () {} }).prototype.async and { async () {} }.async. The cause is that keywords are allowed to be used as function/getter/setter names in classes and object literals, which the module is-async-function does not take into account.

@tunnckoCore
Copy link
Collaborator

tunnckoCore commented Jun 18, 2022

@Melab

It's allowed but it's a bad practice, it's just a legacy pre async javascript.

Also, you may try parse-function, it uses full-fledged parsers, so there are no errors like this.

parseFunction(fn)

// result.isArrow
// result.isAsync
// result.isNamed
// result.isAnonymous
// result.isGenerator
// result.isExpression

@Melab
Copy link
Author

Melab commented Jun 18, 2022

@Melab

It's allowed but it's a bad practice, it's just a legacy pre async javascript.

Also, you may try parse-function, it uses full-fledged parsers, so there are no errors like this.

parseFunction(fn)

// result.isArrow
// result.isAsync
// result.isNamed
// result.isAnonymous
// result.isGenerator
// result.isExpression

Of course it's allowed. I wouldn't have been able to test isAsyncFunction on it if it were invalid. I am just reporting this false positive to this project as a courtesy so that it may be fixed.

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

No branches or pull requests

2 participants