|
1 |
| -include: package:pedantic/analysis_options.1.8.0.yaml |
| 1 | +# This is a copy (as of March 2021) of flutter/flutter's analysis_options file, |
| 2 | +# with minimal changes for this repository. The goal is to move toward using a |
| 3 | +# shared set of analysis options as much as possible, and eventually a shared |
| 4 | +# file. |
| 5 | +# |
| 6 | +# Plugins that have not yet switched from the previous set of options have a |
| 7 | +# local analysis_options.yaml that points to analysis_options_legacy.yaml |
| 8 | +# instead. |
| 9 | + |
| 10 | +# Specify analysis options. |
| 11 | +# |
| 12 | +# Until there are meta linter rules, each desired lint must be explicitly enabled. |
| 13 | +# See: https://github.com/dart-lang/linter/issues/288 |
| 14 | +# |
| 15 | +# For a list of lints, see: http://dart-lang.github.io/linter/lints/ |
| 16 | +# See the configuration guide for more |
| 17 | +# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer |
| 18 | +# |
| 19 | +# There are other similar analysis options files in the flutter repos, |
| 20 | +# which should be kept in sync with this file: |
| 21 | +# |
| 22 | +# - analysis_options.yaml (this file) |
| 23 | +# - packages/flutter/lib/analysis_options_user.yaml |
| 24 | +# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml |
| 25 | +# - https://github.com/flutter/engine/blob/master/analysis_options.yaml |
| 26 | +# |
| 27 | +# This file contains the analysis options used by Flutter tools, such as IntelliJ, |
| 28 | +# Android Studio, and the `flutter analyze` command. |
| 29 | + |
2 | 30 | analyzer:
|
| 31 | + strong-mode: |
| 32 | + implicit-casts: false |
| 33 | + implicit-dynamic: false |
| 34 | + errors: |
| 35 | + # treat missing required parameters as a warning (not a hint) |
| 36 | + missing_required_param: warning |
| 37 | + # treat missing returns as a warning (not a hint) |
| 38 | + missing_return: warning |
| 39 | + # allow having TODOs in the code |
| 40 | + todo: ignore |
| 41 | + # allow self-reference to deprecated members (we do this because otherwise we have |
| 42 | + # to annotate every member in every test, assert, etc, when we deprecate something) |
| 43 | + deprecated_member_use_from_same_package: ignore |
| 44 | + # Ignore analyzer hints for updating pubspecs when using Future or |
| 45 | + # Stream and not importing dart:async |
| 46 | + # Please see https://github.com/flutter/flutter/pull/24528 for details. |
| 47 | + sdk_version_async_exported_from_core: ignore |
| 48 | + ### Local flutter/plugins changes ### |
| 49 | + # Allow null checks for as long as mixed mode is officially supported. |
| 50 | + unnecessary_null_comparison: false |
| 51 | + always_require_non_null_named_parameters: false # not needed with nnbd |
3 | 52 | exclude:
|
4 | 53 | # Ignore generated files
|
5 | 54 | - '**/*.g.dart'
|
6 | 55 | - 'lib/src/generated/*.dart'
|
7 | 56 | - '**/*.mocks.dart' # Mockito @GenerateMocks
|
8 |
| - errors: |
9 |
| - always_require_non_null_named_parameters: false # not needed with nnbd |
10 |
| - unnecessary_null_comparison: false # Turned as long as nnbd mix-mode is supported. |
| 57 | + |
11 | 58 | linter:
|
12 | 59 | rules:
|
13 |
| - - public_member_api_docs |
| 60 | + # these rules are documented on and in the same order as |
| 61 | + # the Dart Lint rules page to make maintenance easier |
| 62 | + # https://github.com/dart-lang/linter/blob/master/example/all.yaml |
| 63 | + - always_declare_return_types |
| 64 | + - always_put_control_body_on_new_line |
| 65 | + # - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219 |
| 66 | + - always_require_non_null_named_parameters |
| 67 | + - always_specify_types |
| 68 | + # - always_use_package_imports # we do this commonly |
| 69 | + - annotate_overrides |
| 70 | + # - avoid_annotating_with_dynamic # conflicts with always_specify_types |
| 71 | + # - avoid_as # required for implicit-casts: true |
| 72 | + - avoid_bool_literals_in_conditional_expressions |
| 73 | + # - avoid_catches_without_on_clauses # we do this commonly |
| 74 | + # - avoid_catching_errors # we do this commonly |
| 75 | + - avoid_classes_with_only_static_members |
| 76 | + # - avoid_double_and_int_checks # only useful when targeting JS runtime |
| 77 | + - avoid_empty_else |
| 78 | + - avoid_equals_and_hash_code_on_mutable_classes |
| 79 | + # - avoid_escaping_inner_quotes # not yet tested |
| 80 | + - avoid_field_initializers_in_const_classes |
| 81 | + - avoid_function_literals_in_foreach_calls |
| 82 | + # - avoid_implementing_value_types # not yet tested |
| 83 | + - avoid_init_to_null |
| 84 | + # - avoid_js_rounded_ints # only useful when targeting JS runtime |
| 85 | + - avoid_null_checks_in_equality_operators |
| 86 | + # - avoid_positional_boolean_parameters # not yet tested |
| 87 | + # - avoid_print # not yet tested |
| 88 | + # - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356) |
| 89 | + # - avoid_redundant_argument_values # not yet tested |
| 90 | + - avoid_relative_lib_imports |
| 91 | + - avoid_renaming_method_parameters |
| 92 | + - avoid_return_types_on_setters |
| 93 | + # - avoid_returning_null # there are plenty of valid reasons to return null |
| 94 | + # - avoid_returning_null_for_future # not yet tested |
| 95 | + - avoid_returning_null_for_void |
| 96 | + # - avoid_returning_this # there are plenty of valid reasons to return this |
| 97 | + # - avoid_setters_without_getters # not yet tested |
| 98 | + - avoid_shadowing_type_parameters |
| 99 | + - avoid_single_cascade_in_expression_statements |
| 100 | + - avoid_slow_async_io |
| 101 | + # - avoid_type_to_string # we do this commonly |
| 102 | + - avoid_types_as_parameter_names |
| 103 | + # - avoid_types_on_closure_parameters # conflicts with always_specify_types |
| 104 | + # - avoid_unnecessary_containers # not yet tested |
| 105 | + - avoid_unused_constructor_parameters |
| 106 | + - avoid_void_async |
| 107 | + # - avoid_web_libraries_in_flutter # not yet tested |
| 108 | + - await_only_futures |
| 109 | + - camel_case_extensions |
| 110 | + - camel_case_types |
| 111 | + - cancel_subscriptions |
| 112 | + # - cascade_invocations # not yet tested |
| 113 | + - cast_nullable_to_non_nullable |
| 114 | + # - close_sinks # not reliable enough |
| 115 | + # - comment_references # blocked on https://github.com/flutter/flutter/issues/20765 |
| 116 | + # - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204 |
| 117 | + - control_flow_in_finally |
| 118 | + # - curly_braces_in_flow_control_structures # not required by flutter style |
| 119 | + # - diagnostic_describe_all_properties # not yet tested |
| 120 | + - directives_ordering |
| 121 | + # - do_not_use_environment # we do this commonly |
| 122 | + - empty_catches |
| 123 | + - empty_constructor_bodies |
| 124 | + - empty_statements |
| 125 | + - exhaustive_cases |
| 126 | + # - file_names # not yet tested |
| 127 | + - flutter_style_todos |
| 128 | + - hash_and_equals |
| 129 | + - implementation_imports |
| 130 | + # - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811 |
| 131 | + - iterable_contains_unrelated_type |
| 132 | + # - join_return_with_assignment # not required by flutter style |
| 133 | + - leading_newlines_in_multiline_strings |
| 134 | + - library_names |
| 135 | + - library_prefixes |
| 136 | + # - lines_longer_than_80_chars # not required by flutter style |
| 137 | + - list_remove_unrelated_type |
| 138 | + # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181 |
| 139 | + # - missing_whitespace_between_adjacent_strings # not yet tested |
| 140 | + - no_adjacent_strings_in_list |
| 141 | + # - no_default_cases # too many false positives |
| 142 | + - no_duplicate_case_values |
| 143 | + - no_logic_in_create_state |
| 144 | + # - no_runtimeType_toString # ok in tests; we enable this only in packages/ |
| 145 | + - non_constant_identifier_names |
| 146 | + - null_check_on_nullable_type_parameter |
| 147 | + # - null_closures # not required by flutter style |
| 148 | + # - omit_local_variable_types # opposite of always_specify_types |
| 149 | + # - one_member_abstracts # too many false positives |
| 150 | + # - only_throw_errors # https://github.com/flutter/flutter/issues/5792 |
| 151 | + - overridden_fields |
| 152 | + - package_api_docs |
| 153 | + # - package_names # non conforming packages in sdk |
| 154 | + - package_prefixed_library_names |
| 155 | + # - parameter_assignments # we do this commonly |
| 156 | + - prefer_adjacent_string_concatenation |
| 157 | + - prefer_asserts_in_initializer_lists |
| 158 | + # - prefer_asserts_with_message # not required by flutter style |
| 159 | + - prefer_collection_literals |
| 160 | + - prefer_conditional_assignment |
| 161 | + - prefer_const_constructors |
| 162 | + - prefer_const_constructors_in_immutables |
| 163 | + - prefer_const_declarations |
| 164 | + - prefer_const_literals_to_create_immutables |
| 165 | + # - prefer_constructors_over_static_methods # far too many false positives |
| 166 | + - prefer_contains |
| 167 | + # - prefer_double_quotes # opposite of prefer_single_quotes |
| 168 | + - prefer_equal_for_default_values |
| 169 | + # - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods |
| 170 | + - prefer_final_fields |
| 171 | + - prefer_final_in_for_each |
| 172 | + - prefer_final_locals |
| 173 | + - prefer_for_elements_to_map_fromIterable |
| 174 | + - prefer_foreach |
| 175 | + # - prefer_function_declarations_over_variables # not yet tested |
| 176 | + - prefer_generic_function_type_aliases |
| 177 | + - prefer_if_elements_to_conditional_expressions |
| 178 | + - prefer_if_null_operators |
| 179 | + - prefer_initializing_formals |
| 180 | + - prefer_inlined_adds |
| 181 | + # - prefer_int_literals # not yet tested |
| 182 | + # - prefer_interpolation_to_compose_strings # not yet tested |
| 183 | + - prefer_is_empty |
| 184 | + - prefer_is_not_empty |
| 185 | + - prefer_is_not_operator |
| 186 | + - prefer_iterable_whereType |
| 187 | + # - prefer_mixin # https://github.com/dart-lang/language/issues/32 |
| 188 | + # - prefer_null_aware_operators # disable until NNBD, see https://github.com/flutter/flutter/pull/32711#issuecomment-492930932 |
| 189 | + # - prefer_relative_imports # not yet tested |
| 190 | + - prefer_single_quotes |
| 191 | + - prefer_spread_collections |
| 192 | + - prefer_typing_uninitialized_variables |
| 193 | + - prefer_void_to_null |
| 194 | + # - provide_deprecation_message # not yet tested |
| 195 | + # - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml |
| 196 | + - recursive_getters |
| 197 | + # - sized_box_for_whitespace # not yet tested |
| 198 | + - slash_for_doc_comments |
| 199 | + # - sort_child_properties_last # not yet tested |
| 200 | + - sort_constructors_first |
| 201 | + # - sort_pub_dependencies # prevents separating pinned transitive dependencies |
| 202 | + - sort_unnamed_constructors_first |
| 203 | + - test_types_in_equals |
| 204 | + - throw_in_finally |
| 205 | + - tighten_type_of_initializing_formals |
| 206 | + # - type_annotate_public_apis # subset of always_specify_types |
| 207 | + - type_init_formals |
| 208 | + # - unawaited_futures # too many false positives |
| 209 | + # - unnecessary_await_in_return # not yet tested |
| 210 | + - unnecessary_brace_in_string_interps |
| 211 | + - unnecessary_const |
| 212 | + # - unnecessary_final # conflicts with prefer_final_locals |
| 213 | + - unnecessary_getters_setters |
| 214 | + # - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498 |
| 215 | + - unnecessary_new |
| 216 | + - unnecessary_null_aware_assignments |
| 217 | + # - unnecessary_null_checks # not yet tested |
| 218 | + - unnecessary_null_in_if_null_operators |
| 219 | + - unnecessary_nullable_for_final_variable_declarations |
| 220 | + - unnecessary_overrides |
| 221 | + - unnecessary_parenthesis |
| 222 | + # - unnecessary_raw_strings # not yet tested |
| 223 | + - unnecessary_statements |
| 224 | + - unnecessary_string_escapes |
| 225 | + - unnecessary_string_interpolations |
| 226 | + - unnecessary_this |
| 227 | + - unrelated_type_equality_checks |
| 228 | + # - unsafe_html # not yet tested |
| 229 | + - use_full_hex_values_for_flutter_colors |
| 230 | + # - use_function_type_syntax_for_parameters # not yet tested |
| 231 | + - use_is_even_rather_than_modulo |
| 232 | + # - use_key_in_widget_constructors # not yet tested |
| 233 | + - use_late_for_private_fields_and_variables |
| 234 | + - use_raw_strings |
| 235 | + - use_rethrow_when_possible |
| 236 | + # - use_setters_to_change_properties # not yet tested |
| 237 | + # - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182 |
| 238 | + # - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review |
| 239 | + - valid_regexps |
| 240 | + - void_checks |
| 241 | + ### Local flutter/plugins changes ### |
| 242 | + # These are from flutter/flutter/packages, so will need to be preserved |
| 243 | + # separately when moving to a shared file. |
| 244 | + - no_runtimeType_toString # use objectRuntimeType from package:foundation |
| 245 | + - public_member_api_docs # see https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#documentation-dartdocs-javadocs-etc |
0 commit comments