Dan Field | 8af3e48 | 2019-01-11 13:38:02 -0800 | [diff] [blame] | 1 | # Specify analysis options. |
| 2 | # |
| 3 | # Until there are meta linter rules, each desired lint must be explicitly enabled. |
| 4 | # See: https://github.com/dart-lang/linter/issues/288 |
| 5 | # |
| 6 | # For a list of lints, see: http://dart-lang.github.io/linter/lints/ |
| 7 | # See the configuration guide for more |
| 8 | # https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer |
| 9 | # |
| 10 | # There are other similar analysis options files in the flutter repos, |
| 11 | # which should be kept in sync with this file: |
| 12 | # |
| 13 | # - analysis_options.yaml (this file) |
| 14 | # - packages/flutter/lib/analysis_options_user.yaml |
| 15 | # - https://github.com/flutter/plugins/blob/master/analysis_options.yaml |
| 16 | # - https://github.com/flutter/engine/blob/master/analysis_options.yaml |
| 17 | # |
| 18 | # This file contains the analysis options used by Flutter tools, such as IntelliJ, |
| 19 | # Android Studio, and the `flutter analyze` command. |
krisgiesing | 07b5f83 | 2016-05-04 10:15:15 -0700 | [diff] [blame] | 20 | |
| 21 | analyzer: |
Dan Field | 8af3e48 | 2019-01-11 13:38:02 -0800 | [diff] [blame] | 22 | strong-mode: |
| 23 | implicit-dynamic: false |
krisgiesing | 07b5f83 | 2016-05-04 10:15:15 -0700 | [diff] [blame] | 24 | errors: |
Dan Field | 8af3e48 | 2019-01-11 13:38:02 -0800 | [diff] [blame] | 25 | # treat missing required parameters as a warning (not a hint) |
| 26 | missing_required_param: warning |
| 27 | # treat missing returns as a warning (not a hint) |
| 28 | missing_return: warning |
| 29 | # allow having TODOs in the code |
| 30 | todo: ignore |
Siva | b110922 | 2019-01-03 10:55:50 -0800 | [diff] [blame] | 31 | # Ignore analyzer hints for updating pubspecs when using Future or |
| 32 | # Stream and not importing dart:async |
| 33 | # Please see https://github.com/flutter/flutter/pull/24528 for details. |
Alexander Aprelev | fe1a51a | 2018-12-27 14:55:07 -0800 | [diff] [blame] | 34 | sdk_version_async_exported_from_core: ignore |
Devon Carew | 207451f | 2016-08-18 19:11:39 -0700 | [diff] [blame] | 35 | exclude: |
Alexandre Ardhuin | 919dcf5 | 2019-06-27 21:23:16 +0200 | [diff] [blame] | 36 | - "bin/cache/**" |
Ian Hickson | cbda208 | 2017-01-22 16:43:24 -0800 | [diff] [blame] | 37 | # the following two are relative to the stocks example and the flutter package respectively |
| 38 | # see https://github.com/dart-lang/sdk/issues/28463 |
Shi-Hao Hong | 3e4bf57 | 2019-11-06 12:52:03 -0800 | [diff] [blame] | 39 | - "lib/i18n/messages_*.dart" |
Alexandre Ardhuin | 919dcf5 | 2019-06-27 21:23:16 +0200 | [diff] [blame] | 40 | - "lib/src/http/**" |
Dan Field | 8af3e48 | 2019-01-11 13:38:02 -0800 | [diff] [blame] | 41 | |
| 42 | linter: |
| 43 | rules: |
| 44 | # these rules are documented on and in the same order as |
| 45 | # the Dart Lint rules page to make maintenance easier |
| 46 | # https://github.com/dart-lang/linter/blob/master/example/all.yaml |
| 47 | - always_declare_return_types |
| 48 | - always_put_control_body_on_new_line |
| 49 | # - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219 |
| 50 | - always_require_non_null_named_parameters |
| 51 | - always_specify_types |
| 52 | - annotate_overrides |
| 53 | # - avoid_annotating_with_dynamic # conflicts with always_specify_types |
| 54 | - avoid_as |
Alexandre Ardhuin | fecf99f | 2019-06-25 17:40:05 +0200 | [diff] [blame] | 55 | - avoid_bool_literals_in_conditional_expressions |
Dan Field | 8af3e48 | 2019-01-11 13:38:02 -0800 | [diff] [blame] | 56 | # - avoid_catches_without_on_clauses # we do this commonly |
| 57 | # - avoid_catching_errors # we do this commonly |
| 58 | - avoid_classes_with_only_static_members |
| 59 | # - avoid_double_and_int_checks # only useful when targeting JS runtime |
| 60 | - avoid_empty_else |
| 61 | - avoid_field_initializers_in_const_classes |
| 62 | - avoid_function_literals_in_foreach_calls |
| 63 | # - avoid_implementing_value_types # not yet tested |
| 64 | - avoid_init_to_null |
| 65 | # - avoid_js_rounded_ints # only useful when targeting JS runtime |
| 66 | - avoid_null_checks_in_equality_operators |
| 67 | # - avoid_positional_boolean_parameters # not yet tested |
| 68 | # - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356) |
| 69 | - avoid_relative_lib_imports |
| 70 | - avoid_renaming_method_parameters |
| 71 | - avoid_return_types_on_setters |
| 72 | # - avoid_returning_null # there are plenty of valid reasons to return null |
| 73 | # - avoid_returning_null_for_future # not yet tested |
| 74 | - avoid_returning_null_for_void |
| 75 | # - avoid_returning_this # there are plenty of valid reasons to return this |
| 76 | # - avoid_setters_without_getters # not yet tested |
| 77 | # - avoid_shadowing_type_parameters # not yet tested |
| 78 | # - avoid_single_cascade_in_expression_statements # not yet tested |
| 79 | - avoid_slow_async_io |
| 80 | - avoid_types_as_parameter_names |
| 81 | # - avoid_types_on_closure_parameters # conflicts with always_specify_types |
| 82 | - avoid_unused_constructor_parameters |
| 83 | - avoid_void_async |
| 84 | - await_only_futures |
| 85 | - camel_case_types |
| 86 | - cancel_subscriptions |
| 87 | # - cascade_invocations # not yet tested |
| 88 | # - close_sinks # not reliable enough |
| 89 | # - comment_references # blocked on https://github.com/flutter/flutter/issues/20765 |
| 90 | # - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204 |
| 91 | - control_flow_in_finally |
| 92 | # - curly_braces_in_flow_control_structures # not yet tested |
Alexandre Ardhuin | 9a3a749 | 2019-06-25 15:59:15 +0200 | [diff] [blame] | 93 | # - diagnostic_describe_all_properties # not yet tested |
Dan Field | 8af3e48 | 2019-01-11 13:38:02 -0800 | [diff] [blame] | 94 | - directives_ordering |
| 95 | - empty_catches |
| 96 | - empty_constructor_bodies |
| 97 | - empty_statements |
| 98 | # - file_names # not yet tested |
| 99 | - flutter_style_todos |
| 100 | - hash_and_equals |
| 101 | - implementation_imports |
| 102 | # - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811 |
| 103 | - iterable_contains_unrelated_type |
| 104 | # - join_return_with_assignment # not yet tested |
| 105 | - library_names |
| 106 | - library_prefixes |
| 107 | # - lines_longer_than_80_chars # not yet tested |
| 108 | - list_remove_unrelated_type |
| 109 | # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181 |
| 110 | - no_adjacent_strings_in_list |
| 111 | - no_duplicate_case_values |
| 112 | - non_constant_identifier_names |
| 113 | # - null_closures # not yet tested |
| 114 | # - omit_local_variable_types # opposite of always_specify_types |
| 115 | # - one_member_abstracts # too many false positives |
| 116 | # - only_throw_errors # https://github.com/flutter/flutter/issues/5792 |
| 117 | - overridden_fields |
| 118 | - package_api_docs |
| 119 | - package_names |
| 120 | - package_prefixed_library_names |
| 121 | # - parameter_assignments # we do this commonly |
| 122 | - prefer_adjacent_string_concatenation |
| 123 | - prefer_asserts_in_initializer_lists |
Alexandre Ardhuin | 9a3a749 | 2019-06-25 15:59:15 +0200 | [diff] [blame] | 124 | # - prefer_asserts_with_message # not yet tested |
Phil Quitslund | 802eca2 | 2019-03-06 11:05:16 -0800 | [diff] [blame] | 125 | - prefer_collection_literals |
Dan Field | 8af3e48 | 2019-01-11 13:38:02 -0800 | [diff] [blame] | 126 | - prefer_conditional_assignment |
Dan Field | fe9512f | 2019-04-29 16:02:42 -0700 | [diff] [blame] | 127 | - prefer_const_constructors |
Dan Field | 8af3e48 | 2019-01-11 13:38:02 -0800 | [diff] [blame] | 128 | - prefer_const_constructors_in_immutables |
| 129 | - prefer_const_declarations |
| 130 | - prefer_const_literals_to_create_immutables |
| 131 | # - prefer_constructors_over_static_methods # not yet tested |
| 132 | - prefer_contains |
Alexandre Ardhuin | 9a3a749 | 2019-06-25 15:59:15 +0200 | [diff] [blame] | 133 | # - prefer_double_quotes # opposite of prefer_single_quotes |
Dan Field | 8af3e48 | 2019-01-11 13:38:02 -0800 | [diff] [blame] | 134 | - prefer_equal_for_default_values |
| 135 | # - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods |
| 136 | - prefer_final_fields |
Alexandre Ardhuin | 9a3a749 | 2019-06-25 15:59:15 +0200 | [diff] [blame] | 137 | # - prefer_final_in_for_each # not yet tested |
Dan Field | 8af3e48 | 2019-01-11 13:38:02 -0800 | [diff] [blame] | 138 | - prefer_final_locals |
Alexandre Ardhuin | 9a3a749 | 2019-06-25 15:59:15 +0200 | [diff] [blame] | 139 | # - prefer_for_elements_to_map_fromIterable # not yet tested |
Dan Field | 8af3e48 | 2019-01-11 13:38:02 -0800 | [diff] [blame] | 140 | - prefer_foreach |
| 141 | # - prefer_function_declarations_over_variables # not yet tested |
| 142 | - prefer_generic_function_type_aliases |
Alexandre Ardhuin | df4bf45 | 2019-09-17 16:23:44 +0200 | [diff] [blame] | 143 | - prefer_if_elements_to_conditional_expressions |
Alexandre Ardhuin | b041a58 | 2019-07-09 10:53:35 +0200 | [diff] [blame] | 144 | - prefer_if_null_operators |
Dan Field | 8af3e48 | 2019-01-11 13:38:02 -0800 | [diff] [blame] | 145 | - prefer_initializing_formals |
Alexandre Ardhuin | 919dcf5 | 2019-06-27 21:23:16 +0200 | [diff] [blame] | 146 | - prefer_inlined_adds |
Dan Field | 8af3e48 | 2019-01-11 13:38:02 -0800 | [diff] [blame] | 147 | # - prefer_int_literals # not yet tested |
| 148 | # - prefer_interpolation_to_compose_strings # not yet tested |
| 149 | - prefer_is_empty |
Alexandre Ardhuin | c0125cb | 2019-05-20 17:00:45 +0200 | [diff] [blame] | 150 | - prefer_is_not_empty |
Dan Field | 8af3e48 | 2019-01-11 13:38:02 -0800 | [diff] [blame] | 151 | - prefer_iterable_whereType |
| 152 | # - prefer_mixin # https://github.com/dart-lang/language/issues/32 |
Alexandre Ardhuin | c0125cb | 2019-05-20 17:00:45 +0200 | [diff] [blame] | 153 | # - prefer_null_aware_operators # disable until NNBD, see https://github.com/flutter/flutter/pull/32711#issuecomment-492930932 |
Dan Field | 8af3e48 | 2019-01-11 13:38:02 -0800 | [diff] [blame] | 154 | - prefer_single_quotes |
Alexandre Ardhuin | 919dcf5 | 2019-06-27 21:23:16 +0200 | [diff] [blame] | 155 | - prefer_spread_collections |
Dan Field | 8af3e48 | 2019-01-11 13:38:02 -0800 | [diff] [blame] | 156 | - prefer_typing_uninitialized_variables |
| 157 | - prefer_void_to_null |
Alexandre Ardhuin | 9a3a749 | 2019-06-25 15:59:15 +0200 | [diff] [blame] | 158 | # - provide_deprecation_message # not yet tested |
Dan Field | 8af3e48 | 2019-01-11 13:38:02 -0800 | [diff] [blame] | 159 | # - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml |
| 160 | - recursive_getters |
| 161 | - slash_for_doc_comments |
Alexandre Ardhuin | 9a3a749 | 2019-06-25 15:59:15 +0200 | [diff] [blame] | 162 | # - sort_child_properties_last # not yet tested |
Dan Field | 8af3e48 | 2019-01-11 13:38:02 -0800 | [diff] [blame] | 163 | - sort_constructors_first |
| 164 | - sort_pub_dependencies |
| 165 | - sort_unnamed_constructors_first |
Dan Field | 8af3e48 | 2019-01-11 13:38:02 -0800 | [diff] [blame] | 166 | - test_types_in_equals |
| 167 | - throw_in_finally |
| 168 | # - type_annotate_public_apis # subset of always_specify_types |
| 169 | - type_init_formals |
| 170 | # - unawaited_futures # too many false positives |
| 171 | # - unnecessary_await_in_return # not yet tested |
| 172 | - unnecessary_brace_in_string_interps |
| 173 | - unnecessary_const |
| 174 | - unnecessary_getters_setters |
| 175 | # - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498 |
| 176 | - unnecessary_new |
| 177 | - unnecessary_null_aware_assignments |
| 178 | - unnecessary_null_in_if_null_operators |
| 179 | - unnecessary_overrides |
| 180 | - unnecessary_parenthesis |
| 181 | - unnecessary_statements |
| 182 | - unnecessary_this |
| 183 | - unrelated_type_equality_checks |
Alexandre Ardhuin | 9a3a749 | 2019-06-25 15:59:15 +0200 | [diff] [blame] | 184 | # - unsafe_html # not yet tested |
Alexandre Ardhuin | b5ce061 | 2019-06-25 17:58:19 +0200 | [diff] [blame] | 185 | - use_full_hex_values_for_flutter_colors |
Dan Field | 8af3e48 | 2019-01-11 13:38:02 -0800 | [diff] [blame] | 186 | # - use_function_type_syntax_for_parameters # not yet tested |
| 187 | - use_rethrow_when_possible |
| 188 | # - use_setters_to_change_properties # not yet tested |
| 189 | # - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182 |
| 190 | # - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review |
| 191 | - valid_regexps |
| 192 | # - void_checks # not yet tested |