Skip to content

Commit 18b37d6

Browse files
committed
+feat: Add more annotations
1 parent d6a3cf9 commit 18b37d6

6 files changed

+40
-38
lines changed

lib/src/annotations/must_await_all_futures_annotation.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
1111
//.title~
1212

13+
const mustAwaitAllFuturesOrError = MustAwaitAllFuturesOrErrorAnnotation();
14+
15+
/// The class that enables the `@mustAwaitAllFuturesOrError` annotation.
16+
final class MustAwaitAllFuturesOrErrorAnnotation {
17+
const MustAwaitAllFuturesOrErrorAnnotation();
18+
}
19+
1320
const mustAwaitAllFutures = MustAwaitAllFuturesAnnotation();
1421

1522
/// The class that enables the `@mustAwaitAllFutures` annotation.

lib/src/annotations/must_be_anonymous_annotation.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@
1010
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
1111
//.title~
1212

13-
const mustBeAnonymousAnnotation = MustBeAnonymousAnnotation();
13+
const mustBeAnonymous = MustBeAnonymousAnnotation();
1414

15-
/// The class that enables the `@mustBeAnonymousAnnotation` annotation.
15+
/// The class that enables the `@mustBeAnonymous` annotation.
1616
final class MustBeAnonymousAnnotation {
1717
const MustBeAnonymousAnnotation();
1818
}
19+
20+
const mustBeAnonymousOrError = MustBeAnonymousOrErrorAnnotation();
21+
22+
/// The class that enables the `@mustBeAnonymousOrError` annotation.
23+
final class MustBeAnonymousOrErrorAnnotation {
24+
const MustBeAnonymousOrErrorAnnotation();
25+
}

lib/src/annotations/must_be_strict_annotation.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@
1010
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
1111
//.title~
1212

13-
const mustBeStrictAnnotation = MustBeStrictAnnotation();
13+
const mustBeStrictOrError = MustBeStrictOrErrorAnnotation();
1414

15-
/// The class that enables the `@mustBeStrictAnnotation` annotation.
15+
/// The class that enables the `@mustBeStrictOrError` annotation.
16+
final class MustBeStrictOrErrorAnnotation {
17+
const MustBeStrictOrErrorAnnotation();
18+
}
19+
20+
const mustBeStrict = MustBeStrictAnnotation();
21+
22+
/// The class that enables the `@mustBeStrict` annotation.
1623
final class MustBeStrictAnnotation {
1724
const MustBeStrictAnnotation();
1825
}

lib/src/annotations/must_handle_return_annotation.dart

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,16 @@
1010
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
1111
//.title~
1212

13-
/// An annotation used to mark a function whose return value must be handled.
14-
///
15-
/// When a function is annotated with `@mustHandleReturn`, the Dart static
16-
/// analyzer will issue a warning if the function is called and its return value
17-
/// is not used (i.e., not assigned to a variable, passed to another function,
18-
/// or used in an expression).
19-
///
20-
/// This is particularly useful for functions that return a `Result`, `Option`,
21-
/// or `Resolvable` where ignoring the result can lead to unhandled errors or
22-
/// unexpected behavior.
23-
///
24-
/// ### Example
25-
///
26-
/// ```dart
27-
/// @mustHandleReturn
28-
/// Result<int> safeDivide(int a, int b) {
29-
/// if (b == 0) {
30-
/// return Err('Cannot divide by zero');
31-
/// }
32-
/// return Ok(a ~/ b);
33-
/// }
34-
///
35-
/// void main() {
36-
/// // GOOD: The result is handled.
37-
/// final result = safeDivide(10, 2);
38-
/// result.ifOk((ok) => print('Result: ${ok.value}'));
39-
///
40-
/// // BAD: This will trigger a lint warning because the Result is discarded.
41-
/// safeDivide(10, 0);
42-
/// }
43-
/// ```
44-
@Deprecated('Use @useResult instead.')
13+
const mustHandleReturnOrError = MustHandleReturnAnnotation();
14+
15+
/// The class that enables the `@mustHandleReturnOrError` annotation.
16+
final class MustHandleReturnOrErrorAnnotation {
17+
const MustHandleReturnOrErrorAnnotation();
18+
}
19+
4520
const mustHandleReturn = MustHandleReturnAnnotation();
4621

4722
/// The class that enables the `@mustHandleReturn` annotation.
48-
@Deprecated('Use @useResult instead.')
4923
final class MustHandleReturnAnnotation {
5024
const MustHandleReturnAnnotation();
5125
}

lib/src/annotations/no_futures_allowed_annotation.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
1111
//.title~
1212

13+
const noFuturesAllowedOrError = NoFuturesAllowedOrErrorAnnotation();
14+
15+
/// The class that enables the `@noFuturesAllowedOrError` annotation.
16+
final class NoFuturesAllowedOrErrorAnnotation {
17+
const NoFuturesAllowedOrErrorAnnotation();
18+
}
19+
1320
const noFuturesAllowed = NoFuturesAllowedAnnotation();
1421

1522
/// The class that enables the `@noFuturesAllowed` annotation.

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
name: df_safer_dart_annotations
1414
description: Annotations for the df_safer_dart_lints package.
15-
version: 0.1.2
15+
version: 0.1.3
1616
homepage: https://dev-cetera.com/
1717
repository: https://github.com/dev-cetera/df_safer_dart_annotations
1818
funding:

0 commit comments

Comments
 (0)