prefer-test-matchers
Recommends Matcher expectations and direct type, equality, or ordering matchers.
Invalid
import 'package:test/test.dart';
void main() {
test('manual expectations', () async {
expect(true, true);
expect(false, false);
expect(null, null);
expect(1 == 1, true);
await expectLater(false, false);
});
} test('manual expectations', () async { expect(true, true); expect(true, true); expect(false, false); expect(false, false); expect(null, null); expect(null, null); expect(1 == 1, true); expect(1 == 1, true); await expectLater(false, false);Valid
import 'package:test/test.dart' as t;
void main() {
t.test('dedicated matchers', () {
t.expect(true, t.isTrue);
t.expect(false, t.isFalse);
t.expect(null, t.isNull);
t.expect(1, t.equals(1));
t.expect([1], t.isNotNull);
void expect(dynamic actual, dynamic matcher) {}
expect(true, true);
});
}Configure prefer-test-matchers
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"prefer-test-matchers": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/prefer-test-matchers: <reason>More style rules
- prefer-trailing-comma
prefer-trailing-commaFlags multi-line argument lists that are missing a trailing comma.
- prefer-transform-over-containerflutter
Prefers
Transformover aContainerused only fortransform. - prefer-type-over-var
Prefer explicit types over
varin ordinary variable declarations. - prefer-typing-uninitialized-variables
prefer_typing_uninitialized_variablesrecommendedFlags uninitialized variables declared without a type annotation.
- prefer-underscore-for-unused-callback-parameters
prefer_underscore_for_unused_callback_parametersFlags unused closure parameters that are not named with underscores.
- prefer-void-callbackflutter
Prefers Flutter's
VoidCallbackalias over a nongenericvoid Function()type. - provide-deprecation-message
provide_deprecation_messagerecommendedFlags
@deprecatedand@Deprecated()annotations that carry no message. - public-member-api-docs
public_member_api_docsDocuments public declarations and members in package libraries.