# include: package:lint/analysis_options.yaml analyzer: # strong-mode: # Will become the default once non-nullable types land # https://github.com/dart-lang/sdk/issues/31410#issuecomment-510683629 # implicit-casts: false errors: # treat missing required parameters as a warning (not a hint) missing_required_param: warning # treat missing returns as a warning (not a hint) missing_return: warning todo: ignore # Rules are in the same order (alphabetically) as documented at http://dart-lang.github.io/linter/lints # and https://github.com/dart-lang/linter/blob/master/example/all.yaml linter: rules: # Prevents accidental return type changes which results in a breaking API change. # Enforcing return type makes API changes visible in a diff # pedantic: enabled # http://dart-lang.github.io/linter/lints/always_declare_return_types.html - always_declare_return_types # Single line `if`s are fine as recommended in Effective Dart "DO format your code using dartfmt" # pedantic: disabled # http://dart-lang.github.io/linter/lints/always_put_control_body_on_new_line.html # - always_put_control_body_on_new_line # Flutter widgets always put a Key as first optional parameter which breaks this rule. # Also violates other orderings like matching the class fields or alphabetically. # pedantic: disabled # http://dart-lang.github.io/linter/lints/always_declare_return_types.html # - always_put_required_named_parameters_first # All non nullable named parameters should be and annotated with @required. # This allows API consumers to get warnings via lint rather than a crash a runtime. # Might become obsolete with Non-Nullable types # pedantic: enabled # http://dart-lang.github.io/linter/lints/always_require_non_null_named_parameters.html - always_require_non_null_named_parameters # Since dart 2.0 dart is a sound language, specifying types is not required anymore. # `var foo = 10;` is enough information for the compiler to make foo a int. # Violates Effective Dart "AVOID type annotating initialized local variables". # Makes code unnecessarily complex https://github.com/dart-lang/linter/issues/1620 # pedantic: disabled # http://dart-lang.github.io/linter/lints/always_specify_types.html # - always_specify_types # Protect against unintentionally overriding superclass members # pedantic: enabled # http://dart-lang.github.io/linter/lints/annotate_overrides.html - annotate_overrides # All methods should define a return type. dynamic is no exception. # Violates Effective Dart "PREFER annotating with dynamic instead of letting inference fail" # pedantic: disabled # http://dart-lang.github.io/linter/lints/avoid_annotating_with_dynamic.html # - avoid_annotating_with_dynamic # A leftover from dart1, should be deprecated # pedantic: disabled # - https://github.com/dart-lang/linter/issues/1401 # http://dart-lang.github.io/linter/lints/avoid_as.html # - avoid_as # Highlights boolean expressions which can be simplified # http://dart-lang.github.io/linter/lints/avoid_bool_literals_in_conditional_expressions.html - avoid_bool_literals_in_conditional_expressions # There are no strong arguments to enable this rule because it is very strict. Catching anything is useful # and common even if not always the most correct thing to do. # pedantic: disabled # http://dart-lang.github.io/linter/lints/avoid_catches_without_on_clauses.html # - avoid_catches_without_on_clauses # Errors aren't for catching but to prevent prior to runtime # pedantic: disabled # http://dart-lang.github.io/linter/lints/avoid_catching_errors.html - avoid_catching_errors # Can usually be replaced with an extension # pedantic: disabled # http://dart-lang.github.io/linter/lints/avoid_classes_with_only_static_members.html # - avoid_classes_with_only_static_members # Never accidentally use dynamic invocations # Dart SDK: unreleased • (Linter vnull) # https://dart-lang.github.io/linter/lints/avoid_dynamic_calls.html # avoid_dynamic_calls # Only useful when targeting JS # pedantic: disabled # http://dart-lang.github.io/linter/lints/avoid_double_and_int_checks.html # - avoid_double_and_int_checks # Prevents accidental empty else cases. See samples in documentation # pedantic: enabled # http://dart-lang.github.io/linter/lints/avoid_empty_else.html - avoid_empty_else # It is expected that mutable objects which override hash & equals shouldn't be used as keys for hashmaps. # This one use case doesn't make all hash & equals implementations for mutable classes bad. # pedantic: disabled # https://dart-lang.github.io/linter/lints/avoid_equals_and_hash_code_on_mutable_classes.html # - avoid_equals_and_hash_code_on_mutable_classes # Use different quotes instead of escaping # Dart SDK: >= 2.8.0-dev.11.0 • (Linter v0.1.111) # https://dart-lang.github.io/linter/lints/avoid_escaping_inner_quotes.html - avoid_escaping_inner_quotes # Prevents unnecessary allocation of a field # pedantic: disabled # http://dart-lang.github.io/linter/lints/avoid_field_initializers_in_const_classes.html - avoid_field_initializers_in_const_classes # Prevents allocating a lambda and allows return/break/continue control flow statements inside the loop # http://dart-lang.github.io/linter/lints/avoid_function_literals_in_foreach_calls.html - avoid_function_literals_in_foreach_calls # Don't break value types by implementing them # http://dart-lang.github.io/linter/lints/avoid_implementing_value_types.html - avoid_implementing_value_types # Removes redundant `= null;` # https://dart-lang.github.io/linter/lints/avoid_init_to_null.html - avoid_init_to_null # Only useful when targeting JS # Warns about too large integers when compiling to JS # pedantic: disabled # https://dart-lang.github.io/linter/lints/avoid_js_rounded_ints.html # - avoid_js_rounded_ints # Null checks aren't required in ==() operators # pedantic: enabled # https://dart-lang.github.io/linter/lints/avoid_null_checks_in_equality_operators.html - avoid_null_checks_in_equality_operators # Good APIs don't use ambiguous boolean parameters. Instead use named parameters # https://dart-lang.github.io/linter/lints/avoid_positional_boolean_parameters.html - avoid_positional_boolean_parameters # Don't call print in production code # pedantic: disabled # https://dart-lang.github.io/linter/lints/avoid_print.html - avoid_print # Always prefer function references over typedefs. # Jumping twice in code to see the signature of a lambda sucks. This is different from the flutter analysis_options # https://dart-lang.github.io/linter/lints/avoid_private_typedef_functions.html - avoid_private_typedef_functions # Don't explicitly set defaults # Dart SDK: >= 2.8.0-dev.1.0 • (Linter v0.1.107) # https://dart-lang.github.io/linter/lints/avoid_redundant_argument_values.html - avoid_redundant_argument_values # package or relative? Let's end the discussion and use package everywhere. # pedantic: enabled # https://dart-lang.github.io/linter/lints/avoid_relative_lib_imports.html - avoid_relative_lib_imports # Not recommended to break dartdoc but besides that there is no reason to continue with bad naming # https://dart-lang.github.io/linter/lints/avoid_renaming_method_parameters.html # - avoid_renaming_method_parameters # Setters always return void, therefore defining void is redundant # pedantic: enabled # https://dart-lang.github.io/linter/lints/avoid_return_types_on_setters.html - avoid_return_types_on_setters # Especially with Non-Nullable types on the horizon, `int?` is fine. # There are plenty of valid reasons to return null. # pedantic: disabled # https://dart-lang.github.io/linter/lints/avoid_returning_null.html # - avoid_returning_null # Don't use `Future?`, therefore never return null instead of a Future. # Will become obsolete one Non-Nullable types land # https://dart-lang.github.io/linter/lints/avoid_returning_null_for_future.html - avoid_returning_null_for_future # Use empty returns, don't show off with you knowledge about dart internals. # https://dart-lang.github.io/linter/lints/avoid_returning_null_for_void.html - avoid_returning_null_for_void # Hinting you forgot about the cascade operator. But too often you did this on purpose. # There are plenty of valid reasons to return this. # pedantic: disabled # https://dart-lang.github.io/linter/lints/avoid_returning_this.html # - avoid_returning_this # Prevents logical inconsistencies. It's good practice to define getters for all existing setters. # https://dart-lang.github.io/linter/lints/avoid_setters_without_getters.html - avoid_setters_without_getters # Don't reuse a type parameter when on with the same name already exists in the same scope # pedantic: enabled # https://dart-lang.github.io/linter/lints/avoid_shadowing_type_parameters.html - avoid_shadowing_type_parameters # A single cascade operator can be replaced with a normal method call # pedantic: enabled # https://dart-lang.github.io/linter/lints/avoid_single_cascade_in_expression_statements.html - avoid_single_cascade_in_expression_statements # Might cause frame drops because of synchronous file access on mobile, especially on older phones with slow storage. # There are no known measurements sync access does *not* drop frames. # pedantic: disabled # https://dart-lang.github.io/linter/lints/avoid_slow_async_io.html # - avoid_slow_async_io # Don't use .toString() in production code which might be minified # Dart SDK: >= 2.10.0-144.0.dev • (Linter v0.1.119) # https://dart-lang.github.io/linter/lints/avoid_type_to_string.html - avoid_type_to_string # Don't use a parameter names which can be confused with a types (i.e. int, bool, num, ...) # pedantic: enabled # https://dart-lang.github.io/linter/lints/avoid_types_as_parameter_names.html - avoid_types_as_parameter_names # Adding the type is not required, but sometimes improves readability. Therefore removing it doesn't always help # https://dart-lang.github.io/linter/lints/avoid_types_on_closure_parameters.html # - avoid_types_on_closure_parameters # Containers without parameters have no effect and can be removed # https://dart-lang.github.io/linter/lints/avoid_unnecessary_containers.html - avoid_unnecessary_containers # Unused parameters should be removed # https://dart-lang.github.io/linter/lints/avoid_unused_constructor_parameters.html - avoid_unused_constructor_parameters # TODO double check # For async functions use `Future` as return value, not `void` # This allows usage of the await keyword and prevents operations from running in parallel. # pedantic: disabled # https://dart-lang.github.io/linter/lints/avoid_void_async.html - avoid_void_async # Flutter mobile only: Web packages aren't available in mobile flutter apps # https://dart-lang.github.io/linter/lints/avoid_web_libraries_in_flutter.html - avoid_web_libraries_in_flutter # Use the await keyword only for futures. There is nothing to await in synchronous code # pedantic: enabled # https://dart-lang.github.io/linter/lints/await_only_futures.html - await_only_futures # Follow the style guide and use UpperCamelCase for extensions # pedantic: enabled # https://dart-lang.github.io/linter/lints/camel_case_extensions.html - camel_case_extensions # Follow the style guide and use UpperCamelCase for class names and typedefs # https://dart-lang.github.io/linter/lints/camel_case_types.html - camel_case_types # Prevents leaks and code executing after their lifecycle. # Discussion https://github.com/passsy/dart-lint/issues/4 # # pedantic: disabled # https://dart-lang.github.io/linter/lints/cancel_subscriptions.html - cancel_subscriptions # The cascade syntax is weird and you shouldn't be forced to use it. # False positives: # https://github.com/dart-lang/linter/issues/1589 # # https://dart-lang.github.io/linter/lints/cascade_invocations.html # - cascade_invocations # Don't cast T? to T. Use ! instead # Dart SDK: >= 2.11.0-182.0.dev • (Linter v0.1.120