barrel_file_lints 1.0.3
barrel_file_lints: ^1.0.3 copied to clipboard
A Dart 3.10+ analyzer plugin that enforces barrel file import rules for feature-based Flutter architecture. Supports both feature_xxx/ and features/xxx/ naming conventions.
Example Usage #
1. Add to your project #
# pubspec.yaml
dev_dependencies:
barrel_file_lints: ^1.0.0
2. Configure analysis_options.yaml #
plugins:
barrel_file_lints:
diagnostics:
avoid_internal_feature_imports: true
avoid_core_importing_features: true
avoid_self_barrel_import: true
3. Example violations #
Bad: Internal feature import #
// lib/feature_home/ui/home_page.dart
// ❌ This will trigger avoid_internal_feature_imports
import 'package:myapp/feature_auth/data/auth_service.dart';
class HomePage extends StatelessWidget {
// ...
}
Good: Barrel file import #
// lib/feature_home/ui/home_page.dart
// ✅ Import via barrel file
import 'package:myapp/feature_auth/auth.dart';
class HomePage extends StatelessWidget {
// ...
}
Bad: Core importing feature #
// lib/core/network/api_client.dart
// ❌ This will trigger avoid_core_importing_features
import 'package:myapp/feature_auth/auth.dart';
class ApiClient {
// ...
}
4. Run analysis #
dart analyze
# or
flutter analyze