99
1010# Specify analysis options.
1111#
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- #
1512# For a list of lints, see: http://dart-lang.github.io/linter/lints/
1613# See the configuration guide for more
17- # https://github.com/dart-lang/sdk/tree/master /pkg/analyzer#configuring-the-analyzer
14+ # https://github.com/dart-lang/sdk/tree/main /pkg/analyzer#configuring-the-analyzer
1815#
1916# There are other similar analysis options files in the flutter repos,
2017# which should be kept in sync with this file:
2118#
2219# - analysis_options.yaml (this file)
2320# - 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
21+ # - https://github.com/flutter/flutter/blob/master/analysis_options.yaml
22+ # - https://github.com/flutter/engine/blob/main/analysis_options.yaml
23+ # - https://github.com/flutter/packages/blob/main/analysis_options.yaml
2624#
27- # This file contains the analysis options used by Flutter tools, such as IntelliJ,
28- # Android Studio, and the `flutter analyze` command .
25+ # This file contains the analysis options used for code in the flutter/plugins
26+ # repository .
2927
3028analyzer :
3129 strong-mode :
@@ -36,7 +34,7 @@ analyzer:
3634 missing_required_param : warning
3735 # treat missing returns as a warning (not a hint)
3836 missing_return : warning
39- # allow having TODOs in the code
37+ # allow having TODO comments in the code
4038 todo : ignore
4139 # allow self-reference to deprecated members (we do this because otherwise we have
4240 # to annotate every member in every test, assert, etc, when we deprecate something)
@@ -45,9 +43,10 @@ analyzer:
4543 # Stream and not importing dart:async
4644 # Please see https://github.com/flutter/flutter/pull/24528 for details.
4745 sdk_version_async_exported_from_core : ignore
46+ # Turned off until null-safe rollout is complete.
47+ unnecessary_null_comparison : ignore
4848 # ## Local flutter/plugins changes ###
4949 # Allow null checks for as long as mixed mode is officially supported.
50- unnecessary_null_comparison : false
5150 always_require_non_null_named_parameters : false # not needed with nnbd
5251 exclude :
5352 # Ignore generated files
@@ -58,8 +57,7 @@ analyzer:
5857
5958linter :
6059 rules :
61- # these rules are documented on and in the same order as
62- # the Dart Lint rules page to make maintenance easier
60+ # This list is derived from the list of all available lints located at
6361 # https://github.com/dart-lang/linter/blob/master/example/all.yaml
6462 - always_declare_return_types
6563 - always_put_control_body_on_new_line
@@ -69,62 +67,68 @@ linter:
6967 # - always_use_package_imports # we do this commonly
7068 - annotate_overrides
7169 # - avoid_annotating_with_dynamic # conflicts with always_specify_types
72- # - avoid_as # required for implicit-casts: true
7370 - avoid_bool_literals_in_conditional_expressions
74- # - avoid_catches_without_on_clauses # we do this commonly
75- # - avoid_catching_errors # we do this commonly
71+ # - avoid_catches_without_on_clauses # blocked on https://github.com/dart-lang/linter/issues/3023
72+ # - avoid_catching_errors # blocked on https://github.com/dart-lang/linter/issues/3023
7673 - avoid_classes_with_only_static_members
77- # - avoid_double_and_int_checks # only useful when targeting JS runtime
74+ - avoid_double_and_int_checks
75+ # - avoid_dynamic_calls # LOCAL CHANGE - Needs to be enabled and violations fixed.
7876 - avoid_empty_else
7977 - avoid_equals_and_hash_code_on_mutable_classes
80- # - avoid_escaping_inner_quotes # not yet tested
78+ - avoid_escaping_inner_quotes
8179 - avoid_field_initializers_in_const_classes
80+ # - avoid_final_parameters # incompatible with prefer_final_parameters
8281 - avoid_function_literals_in_foreach_calls
83- # - avoid_implementing_value_types # not yet tested
82+ # - avoid_implementing_value_types # LOCAL CHANGE - Needs to be enabled and violations fixed.
8483 - avoid_init_to_null
85- # - avoid_js_rounded_ints # only useful when targeting JS runtime
84+ - avoid_js_rounded_ints
85+ # - avoid_multiple_declarations_per_line # seems to be a stylistic choice we don't subscribe to
8686 - avoid_null_checks_in_equality_operators
87- # - avoid_positional_boolean_parameters # not yet tested
88- # - avoid_print # not yet tested
87+ # - avoid_positional_boolean_parameters # would have been nice to enable this but by now there's too many places that break it
88+ # - avoid_print # LOCAL CHANGE - Needs to be enabled and violations fixed.
8989 # - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
90- # - avoid_redundant_argument_values # not yet tested
90+ # - avoid_redundant_argument_values # LOCAL CHANGE - Needs to be enabled and violations fixed.
9191 - avoid_relative_lib_imports
9292 - avoid_renaming_method_parameters
9393 - avoid_return_types_on_setters
94- # - avoid_returning_null # there are plenty of valid reasons to return null
95- # - avoid_returning_null_for_future # not yet tested
94+ # - avoid_returning_null # still violated by some pre-nnbd code that we haven't yet migrated
95+ - avoid_returning_null_for_future
9696 - avoid_returning_null_for_void
97- # - avoid_returning_this # there are plenty of valid reasons to return this
98- # - avoid_setters_without_getters # not yet tested
97+ # - avoid_returning_this # there are enough valid reasons to return ` this` that this lint ends up with too many false positives
98+ - avoid_setters_without_getters
9999 - avoid_shadowing_type_parameters
100100 - avoid_single_cascade_in_expression_statements
101101 - avoid_slow_async_io
102- # - avoid_type_to_string # we do this commonly
102+ - avoid_type_to_string
103103 - avoid_types_as_parameter_names
104104 # - avoid_types_on_closure_parameters # conflicts with always_specify_types
105- # - avoid_unnecessary_containers # not yet tested
105+ - avoid_unnecessary_containers
106106 - avoid_unused_constructor_parameters
107107 - avoid_void_async
108- # - avoid_web_libraries_in_flutter # not yet tested
108+ # - avoid_web_libraries_in_flutter # we use web libraries in web-specific code, and our tests prevent us from using them elsewhere
109109 - await_only_futures
110110 - camel_case_extensions
111111 - camel_case_types
112112 - cancel_subscriptions
113- # - cascade_invocations # not yet tested
113+ # - cascade_invocations # doesn't match the typical style of this repo
114114 - cast_nullable_to_non_nullable
115115 # - close_sinks # not reliable enough
116- # - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
116+ # - comment_references # blocked on https://github.com/dart-lang/linter/issues/1142
117+ # - conditional_uri_does_not_exist # not yet tested
117118 # - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
118119 - control_flow_in_finally
119120 # - curly_braces_in_flow_control_structures # not required by flutter style
120- # - diagnostic_describe_all_properties # not yet tested
121+ # - depend_on_referenced_packages # LOCAL CHANGE - Needs to be enabled and violations fixed.
122+ - deprecated_consistency
123+ # - diagnostic_describe_all_properties # enabled only at the framework level (packages/flutter/lib)
121124 - directives_ordering
122- # - do_not_use_environment # we do this commonly
125+ # - do_not_use_environment # there are appropriate times to use the environment, especially in our tests and build logic
123126 - empty_catches
124127 - empty_constructor_bodies
125128 - empty_statements
129+ - eol_at_end_of_file
126130 - exhaustive_cases
127- # - file_names # not yet tested
131+ - file_names
128132 - flutter_style_todos
129133 - hash_and_equals
130134 - implementation_imports
@@ -134,24 +138,28 @@ linter:
134138 - leading_newlines_in_multiline_strings
135139 - library_names
136140 - library_prefixes
141+ - library_private_types_in_public_api
137142 # - lines_longer_than_80_chars # not required by flutter style
138143 - list_remove_unrelated_type
139- # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk /issues/34181
140- # - missing_whitespace_between_adjacent_strings # not yet tested
144+ # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/linter /issues/453
145+ - missing_whitespace_between_adjacent_strings
141146 - no_adjacent_strings_in_list
142- # - no_default_cases # too many false positives
147+ # - no_default_cases # LOCAL CHANGE - Needs to be enabled and violations fixed.
143148 - no_duplicate_case_values
149+ - no_leading_underscores_for_library_prefixes
150+ # - no_leading_underscores_for_local_identifiers # LOCAL CHANGE - Needs to be enabled and violations fixed.
144151 - no_logic_in_create_state
145152 # - no_runtimeType_toString # ok in tests; we enable this only in packages/
146153 - non_constant_identifier_names
154+ - noop_primitive_operations
147155 - null_check_on_nullable_type_parameter
148- # - null_closures # not required by flutter style
156+ - null_closures
149157 # - omit_local_variable_types # opposite of always_specify_types
150158 # - one_member_abstracts # too many false positives
151- # - only_throw_errors # https://github.com/flutter/flutter/issues/5792
159+ # - only_throw_errors # this does get disabled in a few places where we have legacy code that uses strings et al # LOCAL CHANGE - Needs to be enabled and violations fixed.
152160 - overridden_fields
153161 - package_api_docs
154- # - package_names # non conforming packages in sdk
162+ - package_names
155163 - package_prefixed_library_names
156164 # - parameter_assignments # we do this commonly
157165 - prefer_adjacent_string_concatenation
@@ -171,74 +179,90 @@ linter:
171179 - prefer_final_fields
172180 - prefer_final_in_for_each
173181 - prefer_final_locals
182+ # - prefer_final_parameters # we should enable this one day when it can be auto-fixed (https://github.com/dart-lang/linter/issues/3104), see also parameter_assignments
174183 - prefer_for_elements_to_map_fromIterable
175184 - prefer_foreach
176- # - prefer_function_declarations_over_variables # not yet tested
185+ - prefer_function_declarations_over_variables
177186 - prefer_generic_function_type_aliases
178187 - prefer_if_elements_to_conditional_expressions
179188 - prefer_if_null_operators
180189 - prefer_initializing_formals
181190 - prefer_inlined_adds
182- # - prefer_int_literals # not yet tested
183- # - prefer_interpolation_to_compose_strings # not yet tested
191+ # - prefer_int_literals # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#use-double-literals-for-double-constants
192+ - prefer_interpolation_to_compose_strings
184193 - prefer_is_empty
185194 - prefer_is_not_empty
186195 - prefer_is_not_operator
187196 - prefer_iterable_whereType
188- # - prefer_mixin # https://github.com/dart-lang/language/issues/32
189- # - prefer_null_aware_operators # disable until NNBD, see https://github.com/flutter/flutter/pull/32711#issuecomment-492930932
190- # - prefer_relative_imports # not yet tested
197+ # - prefer_mixin # Has false positives, see https://github.com/dart-lang/linter/issues/3018
198+ # - prefer_null_aware_method_calls # "call()" is confusing to people new to the language since it's not documented anywhere
199+ - prefer_null_aware_operators
200+ # - prefer_relative_imports # LOCAL CHANGE - Needs to be enabled and violations fixed.
191201 - prefer_single_quotes
192202 - prefer_spread_collections
193203 - prefer_typing_uninitialized_variables
194204 - prefer_void_to_null
195- # - provide_deprecation_message # not yet tested
205+ - provide_deprecation_message
196206 # - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
197207 - recursive_getters
198- # - sized_box_for_whitespace # not yet tested
208+ # - require_trailing_commas # blocked on https://github.com/dart-lang/sdk/issues/47441
209+ - secure_pubspec_urls
210+ # - sized_box_for_whitespace # LOCAL CHANGE - Needs to be enabled and violations fixed.
211+ # - sized_box_shrink_expand # not yet tested
199212 - slash_for_doc_comments
200- # - sort_child_properties_last # not yet tested
213+ - sort_child_properties_last
201214 - sort_constructors_first
215+ # - sort_pub_dependencies # prevents separating pinned transitive dependencies
202216 - sort_unnamed_constructors_first
203217 - test_types_in_equals
204218 - throw_in_finally
205219 - tighten_type_of_initializing_formals
206220 # - type_annotate_public_apis # subset of always_specify_types
207221 - type_init_formals
208- # - unawaited_futures # too many false positives
209- # - unnecessary_await_in_return # not yet tested
222+ # - unawaited_futures # too many false positives, especially with the way AnimationController works
223+ # - unnecessary_await_in_return # LOCAL CHANGE - Needs to be enabled and violations fixed.
210224 - unnecessary_brace_in_string_interps
211225 - unnecessary_const
226+ - unnecessary_constructor_name
212227 # - unnecessary_final # conflicts with prefer_final_locals
213228 - unnecessary_getters_setters
214229 # - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
230+ - unnecessary_late
215231 - unnecessary_new
216232 - unnecessary_null_aware_assignments
217- # - unnecessary_null_checks # not yet tested
233+ - unnecessary_null_checks
218234 - unnecessary_null_in_if_null_operators
219235 - unnecessary_nullable_for_final_variable_declarations
220236 - unnecessary_overrides
221237 - unnecessary_parenthesis
222- # - unnecessary_raw_strings # not yet tested
238+ # - unnecessary_raw_strings # what's "necessary" is a matter of opinion; consistency across strings can help readability more than this lint
223239 - unnecessary_statements
224240 - unnecessary_string_escapes
225241 - unnecessary_string_interpolations
226242 - unnecessary_this
227243 - unrelated_type_equality_checks
228- # - unsafe_html # not yet tested
244+ - unsafe_html
245+ # - use_build_context_synchronously # LOCAL CHANGE - Needs to be enabled and violations fixed.
246+ # - use_colored_box # not yet tested
247+ # - use_decorated_box # not yet tested
248+ # - use_enums # not yet tested
229249 - use_full_hex_values_for_flutter_colors
230- # - use_function_type_syntax_for_parameters # not yet tested
250+ - use_function_type_syntax_for_parameters
251+ - use_if_null_to_convert_nulls_to_bools
231252 - use_is_even_rather_than_modulo
232- # - use_key_in_widget_constructors # not yet tested
253+ - use_key_in_widget_constructors
233254 - use_late_for_private_fields_and_variables
255+ # - use_named_constants # LOCAL CHANGE - Needs to be enabled and violations fixed.
234256 - use_raw_strings
235257 - use_rethrow_when_possible
236- # - use_setters_to_change_properties # not yet tested
258+ - use_setters_to_change_properties
237259 # - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
260+ - use_super_parameters
261+ - use_test_throws_matchers
238262 # - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
239263 - valid_regexps
240264 - void_checks
241- # ## Local flutter/plugins changes ###
265+ # ## Local flutter/plugins additions ###
242266 # These are from flutter/flutter/packages, so will need to be preserved
243267 # separately when moving to a shared file.
244268 - no_runtimeType_toString # use objectRuntimeType from package:foundation
0 commit comments