-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
Description
Example use cases
Always use the prefix 'math' for dart:math
When using the dart:math library, we should always use the prefix 'math' for imports.
rules:
- target: "**"
disallow: dart:math
exclude_disallow: { path: dart:math, as: math } # <---- NEW SYNTAX
reason: Always use the prefix 'math' for dart:math.import 'dart:math'; // Not allowed
import 'dart:math' as m; // Not allowed
import 'dart:math' as math; // AllowedEnforce the use of a custom logger instead of the built-in log function
rules:
- target: "**"
exclude_target: lib/common/logger.dart
disallow: dart:developer
exclude_disallow: { path: dart:developer, hide: log } # <----- NEW SYNTAX
reason: |
Always use lib/common/logger.dart instead of the built-in log function.
If you need to import dart:developer, try hiding the log function from the import.// lib/main.dart
import 'dart:developer'; // Not allowed
import 'dart:developer' as dev; // Not allowed
import 'dart:developer' hide log; // Allowed// lib/common/logger.dart
import 'dart:developer'; // Exceptionally allowed
class Logger {
void info(String message) {
log('[$DateTime.now().toIso8601String()] $message');
}
}Reactions are currently unavailable