Open Rexios80 opened 1 year ago
Ah I finally found one: https://github.com/dart-lang/linter/issues/525
Feel free to close this issue if you feel it shouldn't exist
If you're interested in trying out _dart_codemetrics package, we have this rule available https://dcm.dev/docs/rules/common/prefer-async-await/
I wrote a simple implementation of this rule in my linter package here: https://github.com/Rexios80/rexios_lints/blob/445f781ccb96ca92a812440a8cfba87b2348e532/lib/custom_lint/prefer_async_await.dart
no_raw_futures (maybe no_async_then?)
Description
Do not call
Future.then()
. Callawait
instead. Maybe only enforce in async methods?Details
Future.then()
is much less readable thanawait
calls. To the point where I thinkFuture.then()
should be deprecated but that's outside of our scope.Kind
Enforce style
Bad Examples
Real code my coworkers came up with
Good Examples
Coworkers code that I rewrote
Discussion
My coworkers keep using
Future.then()
in async methods and I wish they would stop it.Effective Dart: https://dart.dev/guides/language/effective-dart/usage#prefer-asyncawait-over-using-raw-futures Dart Code Metrics: https://dcm.dev/docs/individuals/rules/common/prefer-async-await/
I feel like there should already be a proposal for this, but I couldn't find one.
Discussion checklist