avoid-top-level-members-in-tests
Warns when a public top-level member (expect the entrypoint) is declared inside a test file.
It helps reduce code duplication and find unused declarations in test files.
info
To lint only the files that end with _test.dart
, set the include
configuration for this rule to be test/**/*_test.dart
.
Example​
Bad:
final public = 1; // LINT
void function() {} // LINT
class Class {} // LINT
mixin Mixin {} // LINT
extension Extension on String {} // LINT
enum Enum { first, second } // LINT
typedef Public = String; // LINT
Good:
final _private = 2;
void _function() {}
class _Class {}
mixin _Mixin {}
extension _Extension on String {}
enum _Enum { first, second }
typedef _Private = String;