fd_lints 2.2.0 fd_lints: ^2.2.0 copied to clipboard
An opiniated set of lint rules for Dart and Flutter projects. Made by yours truly Floating Dartists.
fd_lints #
An opiniated set of lint rules for Dart and Flutter projects. Made by yours truly Floating Dartists.
You can use 2 different sets of rules:
dart
: for Dart projectsflutter
: for Flutter projects (includesdart
rules)
Installing fd_lints #
- Add both fd_lints and custom_lint to your
pubspec.yaml
file:
dev_dependencies:
custom_lint:
fd_lints:
- Include the set of rules you want to use and enable
custom_lint
's plugin in youranalysis_options.yaml
file:
include: package:fd_lints/dart.yaml # Recommended for Dart projects
# include: package:fd_lints/flutter.yaml # Recommended for Flutter projects
analyzer:
plugins:
- custom_lint
Analyzer #
Language #
Stricter type check is enabled by default. Applying the following rules:
strict-casts
strict-inference
strict-raw-types
Exclude #
The following files are excluded by default:
lib/**.g.dart
lib/**.freezed.dart
test/**.mocks.dart
Linter rules #
- ℹ️ : info
- ⚠️ : warning
- ❌ : error
Custom #
Those rules were created by us by using the custom_lint package.
Rule | Severity |
---|---|
avoid_non_null_assertion | ⚠️ |
avoid_as | ⚠️ |
Dart #
Rule | Severity |
---|---|
always_use_package_imports | ℹ️ |
avoid_dynamic_calls | ℹ️ |
avoid_empty_else | ℹ️ |
avoid_relative_lib_imports | ℹ️ |
avoid_slow_async_io | ⚠️ |
avoid_types_as_parameter_names | ℹ️ |
cancel_subscriptions | ⚠️ |
close_sinks | ⚠️ |
control_flow_in_finally | ℹ️ |
collection_methods_unrelated_type | ❌ |
empty_statements | ℹ️ |
hash_and_equals | ⚠️ |
literal_only_boolean_expressions | ℹ️ |
no_duplicate_case_values | ℹ️ |
prefer_void_to_null | ℹ️ |
test_types_in_equals | ⚠️ |
unnecessary_statements | ℹ️ |
unrelated_type_equality_checks | ❌ |
valid_regexps | ℹ️ |
always_declare_return_types | ℹ️ |
annotate_overrides | ℹ️ |
avoid_annotating_with_dynamic | ⚠️ |
avoid_bool_literals_in_conditional_expressions | ℹ️ |
avoid_catching_errors | ⚠️ |
avoid_classes_with_only_static_members | ℹ️ |
avoid_double_and_int_checks | ℹ️ |
avoid_equals_and_hash_code_on_mutable_classes | ℹ️ |
avoid_escaping_inner_quotes | ℹ️ |
avoid_field_initializers_in_const_classes | ℹ️ |
avoid_final_parameters | ℹ️ |
avoid_init_to_null | ℹ️ |
avoid_multiple_declarations_per_line | ℹ️ |
avoid_null_checks_in_equality_operators | ⚠️ |
avoid_positional_boolean_parameters | ℹ️ |
avoid_redundant_argument_values | ℹ️ |
avoid_renaming_method_parameters | ℹ️ |
avoid_return_types_on_setters | ℹ️ |
avoid_returning_null_for_void | ℹ️ |
avoid_shadowing_type_parameters | ⚠️ |
avoid_single_cascade_in_expression_statements | ℹ️ |
avoid_unused_constructor_parameters | ℹ️ |
avoid_void_async | ⚠️ |
await_only_futures | ❌ |
camel_case_extensions | ℹ️ |
camel_case_types | ℹ️ |
cascade_invocations | ℹ️ |
cast_nullable_to_non_nullable | ❌ |
combinators_ordering | ℹ️ |
conditional_uri_does_not_exist | ❌ |
constant_identifier_names | ℹ️ |
curly_braces_in_flow_control_structures | ℹ️ |
deprecated_consistency | ℹ️ |
directives_ordering | ℹ️ |
empty_catches | ℹ️ |
empty_constructor_bodies | ℹ️ |
eol_at_end_of_file | ℹ️ |
exhaustive_cases | ⚠️ |
file_names | ℹ️ |
implementation_imports | ℹ️ |
implicit_call_tearoffs | ℹ️ |
join_return_with_assignment | ℹ️ |
leading_newlines_in_multiline_strings | ℹ️ |
library_names | ℹ️ |
library_prefixes | ℹ️ |
library_private_types_in_public_api | ℹ️ |
no_leading_underscores_for_library_prefixes | ℹ️ |
no_leading_underscores_for_local_identifiers | ℹ️ |
no_runtimeType_toString | ⚠️ |
non_constant_identifier_names | ℹ️ |
noop_primitive_operations | ℹ️ |
null_check_on_nullable_type_parameter | ❌ |
null_closures | ❌ |
only_throw_errors | ⚠️ |
overridden_fields | ℹ️ |
package_prefixed_library_names | ℹ️ |
parameter_assignments | ⚠️ |
prefer_adjacent_string_concatenation | ℹ️ |
prefer_asserts_in_initializer_lists | ℹ️ |
prefer_collection_literals | ℹ️ |
prefer_conditional_assignment | ℹ️ |
prefer_const_constructors | ℹ️ |
prefer_const_declarations | ℹ️ |
prefer_constructors_over_static_methods | ℹ️ |
prefer_contains | ⚠️ |
prefer_final_fields | ℹ️ |
prefer_final_in_for_each | ℹ️ |
prefer_final_locals | ℹ️ |
prefer_for_elements_to_map_fromIterable | ⚠️ |
prefer_function_declarations_over_variables | ℹ️ |
prefer_generic_function_type_aliases | ℹ️ |
prefer_if_elements_to_conditional_expressions | ℹ️ |
prefer_if_null_operators | ℹ️ |
prefer_initializing_formals | ℹ️ |
prefer_inlined_adds | ℹ️ |
prefer_int_literals | ℹ️ |
prefer_interpolation_to_compose_strings | ℹ️ |
prefer_is_empty | ⚠️ |
prefer_is_not_empty | ⚠️ |
prefer_is_not_operator | ℹ️ |
prefer_iterable_whereType | ℹ️ |
prefer_mixin | ℹ️ |
prefer_null_aware_method_calls | ❌ |
prefer_null_aware_operators | ❌ |
prefer_spread_collections | ℹ️ |
prefer_typing_uninitialized_variables | ❌ |
provide_deprecation_message | ℹ️ |
recursive_getters | ❌ |
require_trailing_commas | ℹ️ |
slash_for_doc_comments | ℹ️ |
sort_constructors_first | ℹ️ |
sort_unnamed_constructors_first | ℹ️ |
tighten_type_of_initializing_formals | ❌ |
type_annotate_public_apis | ❌ |
type_init_formals | ℹ️ |
unawaited_futures | ⚠️ |
unnecessary_await_in_return | ℹ️ |
unnecessary_brace_in_string_interps | ℹ️ |
unnecessary_breaks | ℹ️ |
unnecessary_const | ℹ️ |
unnecessary_constructor_name | ℹ️ |
unnecessary_getters_setters | ℹ️ |
unnecessary_lambdas | ℹ️ |
unnecessary_late | ℹ️ |
unnecessary_new | ℹ️ |
unnecessary_null_aware_assignments | ℹ️ |
unnecessary_null_aware_operator_on_extension_on_nullable | ℹ️ |
unnecessary_null_checks | ℹ️ |
unnecessary_null_in_if_null_operators | ℹ️ |
unnecessary_nullable_for_final_variable_declarations | ℹ️ |
unnecessary_overrides | ℹ️ |
unnecessary_parenthesis | ℹ️ |
unnecessary_raw_strings | ℹ️ |
unnecessary_string_escapes | ℹ️ |
unnecessary_string_interpolations | ℹ️ |
unnecessary_this | ℹ️ |
unnecessary_to_list_in_spreads | ℹ️ |
use_enums | ⚠️ |
use_function_type_syntax_for_parameters | ℹ️ |
use_if_null_to_convert_nulls_to_bools | ℹ️ |
use_is_even_rather_than_modulo | ℹ️ |
use_late_for_private_fields_and_variables | ℹ️ |
use_named_constants | ℹ️ |
use_rethrow_when_possible | ℹ️ |
use_setters_to_change_properties | ℹ️ |
use_string_buffers | ⚠️ |
use_string_in_part_of_directives | ℹ️ |
use_super_parameters | ℹ️ |
use_test_throws_matchers | ℹ️ |
void_checks | ℹ️ |
invalid_use_of_visible_for_testing_member | ❌ |
missing_return | ❌ |
missing_required_param | ❌ |
invalid_annotation_target | ignored |
Flutter #
Rule | Severity |
---|---|
avoid_print | ℹ️ |
avoid_web_libraries_in_flutter | ℹ️ |
avoid_unnecessary_containers | ℹ️ |
no_logic_in_create_state | ℹ️ |
use_build_context_synchronously | ❌ |
use_key_in_widget_constructors | ℹ️ |
avoid_function_literals_in_foreach_calls | ℹ️ |
avoid_js_rounded_ints | ⚠️ |
sized_box_for_whitespace | ℹ️ |
sized_box_shrink_expand | ℹ️ |
sort_child_properties_last | ℹ️ |
use_colored_box | ℹ️ |
use_decorated_box | ℹ️ |
use_full_hex_values_for_flutter_colors | ⚠️ |
prefer_const_constructors_in_immutables | ℹ️ |
prefer_const_literals_to_create_immutables | ℹ️ |
flutter_style_todos | ℹ️ |