avoid-importing-entrypoint-exports
added in: 1.7.0
style
Warns when an entrypoint export is imported inside the library src
folder.
Package entrypoint exports are considered the package public API. Depending on this API in the implementation is fragile and can easily introduce cyclic imports.
⚙️ Config
Set only-in-src
(default is true
) to checks files only within the src/
directory. Disabling this flag will also highlight entrypoint exports usages in test/
.
dart_code_metrics:
...
rules:
...
- avoid-importing-entrypoint-exports:
only-in-src: true
Example
❌ Bad:
lib/src/some_class.dart
import 'package:package/value.dart'; // LINT
class SomeClass {}
✅ Good:
lib/src/some_class.dart
import 'package:package/src/path/to/value.dart';
class SomeClass {}