-
Notifications
You must be signed in to change notification settings - Fork 175
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
upgrade no-sync-fn-in-async-fn #1198
Comments
I wrote the code for this, check it out here https://github.com/denoland/deno_lint/compare/main...sigmaSd:lintup?expand=1 It seems I hit a fatal flow unfortantnly this gets linted correctly function foo() {
Deno.readTextFileSync("");
}"
async function foo2() {
foo()
} but this doesn't async function foo2() {
foo()
}
function foo() {
Deno.readTextFileSync("");
}" because the parsing is done from top to bottom, when we reach foo inside foo2 we don't know its a blocking call yet. Any ideas ? can I somehow parse twice ? |
Ofc I can just traverse the ast twice. |
@sigmaSd yes, you can traverse the AST twice in this specific rule |
Thanks @bartlomieju I already do that in this pr #1199 (comment) It seems to work but I'm not really confortable with the code base, would be great if you review it |
currently
no-sync-fn-in-async-fn
can't catch this:I thought maybe its possible to catch even this: for example we can consider each function that have inside it a deno Sync api a blocking function, and save it on a list and now each time we see it we also consider the parent blocking and so on, and now if we see one of these in an async context we emit a warning.
Do you think this is a reasonable idea ?
The text was updated successfully, but these errors were encountered: