Skip to content

Commit d67eaef

Browse files
committed
Include false positives in avoid_futureor_void documentation
dart-lang/sdk#59232
1 parent f2ad478 commit d67eaef

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 2.7.0
4+
5+
- Enable [`use_truncating_division`](https://dart.dev/tools/linter-rules/use_truncating_division.html)
6+
- Enable [`avoid_futureor_void`](https://dart.dev/tools/linter-rules/avoid_futureor_void.html)
7+
38
## 2.6.2
49

510
- Disable [`document_ignores`](https://dart.dev/tools/linter-rules/document_ignores.html) due to unnecessary verbosity

lib/casual.yaml

+18-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ linter:
4444
# https://dart.dev/tools/linter-rules/always_declare_return_types
4545
# - always_put_required_named_parameters_first
4646

47-
4847
# Always use package: imports.
4948
# While both, relative and package imports are fine, package imports are preferred because they allow for easy find
5049
# and replace
@@ -130,8 +129,25 @@ linter:
130129
# https://dart.dev/tools/linter-rules/avoid_empty_else
131130
# - avoid_empty_else
132131

133-
# Experimental: Avoid using FutureOr<void> as it's redundant
132+
# Avoid using FutureOr<void> because the synchronous type void makes no sense since it can't be assigned to a variable
133+
#
134+
# Definitly never use it as return type of a function.
135+
#
136+
# Exception: It is ok to use it as parameter (also constructor parameter) to accept both a synchronous and asynchronous callback for flexability in API design
137+
#
138+
# ```
139+
# void executeTask(FutureOr<void> Function() task) async { // ok
140+
# await task();
141+
# }
142+
#
143+
# void main() {
144+
# executeTask(() => print('Sync task')); // sync is allowed
145+
# executeTask(() async => await Future.delayed(Duration(seconds: 1), () => print('Async task'))); // will be awaited
146+
# }
147+
# ```
134148
#
149+
# See discusson at https://github.com/dart-lang/sdk/issues/59232
150+
#
135151
# Dart SDK: >= 3.5.0
136152
#
137153
# https://dart.dev/tools/linter-rules/avoid_futureor_void

lib/strict.yaml

+18-1
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,25 @@ linter:
132132
# https://dart.dev/tools/linter-rules/avoid_empty_else
133133
- avoid_empty_else
134134

135-
# Experimental: Avoid using FutureOr<void> as it's redundant
135+
# Avoid using FutureOr<void> because the synchronous type void makes no sense since it can't be assigned to a variable
136136
#
137+
# Definitly never use it as return type of a function.
138+
#
139+
# Exception: It is ok to use it as parameter (also constructor parameter) to accept both a synchronous and asynchronous callback for flexability in API design
140+
#
141+
# ```
142+
# void executeTask(FutureOr<void> Function() task) async { // ok
143+
# await task();
144+
# }
145+
#
146+
# void main() {
147+
# executeTask(() => print('Sync task')); // sync is allowed
148+
# executeTask(() async => await Future.delayed(Duration(seconds: 1), () => print('Async task'))); // will be awaited
149+
# }
150+
# ```
151+
#
152+
# See discusson at https://github.com/dart-lang/sdk/issues/59232
153+
#
137154
# Dart SDK: >= 3.5.0
138155
#
139156
# https://dart.dev/tools/linter-rules/avoid_futureor_void

0 commit comments

Comments
 (0)