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

use stc to improve deno lint #21946

Closed
KnorpelSenf opened this issue Jan 15, 2024 · 11 comments
Closed

use stc to improve deno lint #21946

KnorpelSenf opened this issue Jan 15, 2024 · 11 comments

Comments

@KnorpelSenf
Copy link
Contributor

deno lint is awesome because it's super fast. However, there are things I really wish it could do, but it can't. The prime example for this is no-floating promises.

function foo() { return Promise.resolve() }

foo() // forgot to use await!

The reason why Deno isn't able to lint such things properly is because it doesn't run tsc. Thus, there's no way to infer the return type of foo, so the promise is floating without a warning. Using tsc is not really an option due to the performance cost.

I suggest to use https://github.com/dudykr/stc which lets us do most of these things correctly. It isn't mature enough to replace tsc inside deno check IMO, but it could serve as the basis for much better linting as it would enable deno lint to access type information.

What's your opinion on this?

@dsherret
Copy link
Member

stc is not being worked on anymore.

stc: Donny confirmed the article direction and mentioned no longer working on stc.

https://www.joshuakgoldberg.com/blog/rust-based-javascript-linters-fast-but-no-typed-linting-right-now/

@dsherret
Copy link
Member

I also want no-floating-promises. It would be great if TypeScript would just add it microsoft/TypeScript#13376 (comment)

@dsherret dsherret closed this as not planned Won't fix, can't repro, duplicate, stale Jan 15, 2024
@KnorpelSenf
Copy link
Contributor Author

Oh no. I was not aware.

Would that mean that Deno would start running tsc during lint?

@dsherret
Copy link
Member

The TypeScript issue would probably mean another compiler option where it points out unawaited promises. So it would be pointed out with deno check.

@KnorpelSenf
Copy link
Contributor Author

Smart!

@KnorpelSenf
Copy link
Contributor Author

KnorpelSenf commented Jan 15, 2024

@dsherret have you considered adding opt-in type-based linting, such as deno lint --check or perhaps deno lint --types, which supports more rules at the expense of worse perf?

@bartlomieju
Copy link
Member

@KnorpelSenf weve considered it and it's possible, but we don't have bandwidth to work on it now. Contributions are welcome though :)

@dsherret
Copy link
Member

dsherret commented Jan 15, 2024

Contributions are welcome though :)

There should be agreement on something so large before it's implemented. It will be a lot of work and last time it was discussed Ry was against it.

@bartlomieju
Copy link
Member

Contributions are welcome though :)

There should be agreement on something so large before it's implemented. It will be a lot of work.

Yes, for sure. A proposal would be a good contribution first.

@dsherret
Copy link
Member

Btw, there is a list of type aware lints here: denoland/deno_lint#1138

@KnorpelSenf
Copy link
Contributor Author

Thanks for explaining! I currently also have too much on my list to work on this, but it's good to know that we can push in that direction if someone finds the time.

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

3 participants