dart-lang/linter

discarded_futures generates warnings on waitFor

bsutton opened this issue · 2 comments

I'm the deveveloper of DCli which is an SDK for developing dart console apps.
https://onepub.dev/packages/dcli

DCli is a heavy user of waitFor (although we always us it wrapped in our own function waitForEx).

The new lint discarded_futures (which I'm very pleased to see has been released in 2.18) is however causing some problems in DCli code.

The purpose of the waitFor and waitForEx functions is to convert an async all to a sync call.

T waitFor(Future future, {Duration? timeout}) ;

T waitForEx(Future future)

Globally disabling the future isn't acceptable as it is a critical lint in CLI programming.
A forgotten await can result in you accidentally deleting the entire contents of your hard drive.

Is there some way to disable the lint at the declaration site rather than at each call site?
e.g.

// ignore_calls: discarded_futures
T waitForEx<T>(Future<T> future) {
{
}

rather than:

String resolveSymLink(String pathToLink) =>
            // ignore: discarded_futures
    waitForEx(core.resolveSymLink(pathToLink));

Yeah I'd say follow along at dart-lang/sdk#46218