fimbullinter / wotan

Pluggable TypeScript and JavaScript linter
Apache License 2.0
281 stars 23 forks source link

Linter: provide a streaming API for failures #480

Open ajafff opened 5 years ago

ajafff commented 5 years ago

As a LanguageService plugin we actually want to abort as soon as possible if there's a file change. This is currently not possible as every rule is executed on the file before the linter returns the whole result. There should be an API to return an Iterable<Failure> which allows aborting. It should also only load rules as necessary.

Of course this doesn't work with the lintAndFix API. Changing this one to use the iteration protocol would make sense too, but is not typesafe and doesn't bring any real benefit.

ajafff commented 5 years ago

Note that it's not sufficient to simply yield each failure. In that case it would load and execute all rules if there are no failures in the file. This might take a fair amount of time for big files with many rules.

Instead it should probably yield the failures of each rule.

ajafff commented 3 years ago

another consideration: use a similar approach to TypeScript's CancellationToken to abort the process by throwing a specific exception