9
9
10
10
# Specify analysis options.
11
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
12
# For a list of lints, see: http://dart-lang.github.io/linter/lints/
16
13
# 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
18
15
#
19
16
# There are other similar analysis options files in the flutter repos,
20
17
# which should be kept in sync with this file:
21
18
#
22
19
# - analysis_options.yaml (this file)
23
20
# - 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
26
24
#
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 .
29
27
30
28
analyzer :
31
29
strong-mode :
@@ -36,7 +34,7 @@ analyzer:
36
34
missing_required_param : warning
37
35
# treat missing returns as a warning (not a hint)
38
36
missing_return : warning
39
- # allow having TODOs in the code
37
+ # allow having TODO comments in the code
40
38
todo : ignore
41
39
# allow self-reference to deprecated members (we do this because otherwise we have
42
40
# to annotate every member in every test, assert, etc, when we deprecate something)
@@ -45,9 +43,10 @@ analyzer:
45
43
# Stream and not importing dart:async
46
44
# Please see https://github.com/flutter/flutter/pull/24528 for details.
47
45
sdk_version_async_exported_from_core : ignore
46
+ # Turned off until null-safe rollout is complete.
47
+ unnecessary_null_comparison : ignore
48
48
# ## Local flutter/plugins changes ###
49
49
# Allow null checks for as long as mixed mode is officially supported.
50
- unnecessary_null_comparison : false
51
50
always_require_non_null_named_parameters : false # not needed with nnbd
52
51
exclude :
53
52
# Ignore generated files
@@ -58,8 +57,7 @@ analyzer:
58
57
59
58
linter :
60
59
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
63
61
# https://github.com/dart-lang/linter/blob/master/example/all.yaml
64
62
- always_declare_return_types
65
63
- always_put_control_body_on_new_line
@@ -69,62 +67,68 @@ linter:
69
67
# - always_use_package_imports # we do this commonly
70
68
- annotate_overrides
71
69
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
72
- # - avoid_as # required for implicit-casts: true
73
70
- 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
76
73
- 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.
78
76
- avoid_empty_else
79
77
- avoid_equals_and_hash_code_on_mutable_classes
80
- # - avoid_escaping_inner_quotes # not yet tested
78
+ - avoid_escaping_inner_quotes
81
79
- avoid_field_initializers_in_const_classes
80
+ # - avoid_final_parameters # incompatible with prefer_final_parameters
82
81
- 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.
84
83
- 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
86
86
- 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.
89
89
# - 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.
91
91
- avoid_relative_lib_imports
92
92
- avoid_renaming_method_parameters
93
93
- 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
96
96
- 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
99
99
- avoid_shadowing_type_parameters
100
100
- avoid_single_cascade_in_expression_statements
101
101
- avoid_slow_async_io
102
- # - avoid_type_to_string # we do this commonly
102
+ - avoid_type_to_string
103
103
- avoid_types_as_parameter_names
104
104
# - avoid_types_on_closure_parameters # conflicts with always_specify_types
105
- # - avoid_unnecessary_containers # not yet tested
105
+ - avoid_unnecessary_containers
106
106
- avoid_unused_constructor_parameters
107
107
- 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
109
109
- await_only_futures
110
110
- camel_case_extensions
111
111
- camel_case_types
112
112
- cancel_subscriptions
113
- # - cascade_invocations # not yet tested
113
+ # - cascade_invocations # doesn't match the typical style of this repo
114
114
- cast_nullable_to_non_nullable
115
115
# - 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
117
118
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
118
119
- control_flow_in_finally
119
120
# - 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)
121
124
- 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
123
126
- empty_catches
124
127
- empty_constructor_bodies
125
128
- empty_statements
129
+ - eol_at_end_of_file
126
130
- exhaustive_cases
127
- # - file_names # not yet tested
131
+ - file_names
128
132
- flutter_style_todos
129
133
- hash_and_equals
130
134
- implementation_imports
@@ -137,22 +141,25 @@ linter:
137
141
- library_private_types_in_public_api
138
142
# - lines_longer_than_80_chars # not required by flutter style
139
143
- list_remove_unrelated_type
140
- # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk /issues/34181
141
- # - 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
142
146
- no_adjacent_strings_in_list
143
- # - no_default_cases # too many false positives
147
+ # - no_default_cases # LOCAL CHANGE - Needs to be enabled and violations fixed.
144
148
- 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.
145
151
- no_logic_in_create_state
146
152
# - no_runtimeType_toString # ok in tests; we enable this only in packages/
147
153
- non_constant_identifier_names
154
+ - noop_primitive_operations
148
155
- null_check_on_nullable_type_parameter
149
- # - null_closures # not required by flutter style
156
+ - null_closures
150
157
# - omit_local_variable_types # opposite of always_specify_types
151
158
# - one_member_abstracts # too many false positives
152
- # - 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.
153
160
- overridden_fields
154
161
- package_api_docs
155
- # - package_names # non conforming packages in sdk
162
+ - package_names
156
163
- package_prefixed_library_names
157
164
# - parameter_assignments # we do this commonly
158
165
- prefer_adjacent_string_concatenation
@@ -172,74 +179,90 @@ linter:
172
179
- prefer_final_fields
173
180
- prefer_final_in_for_each
174
181
- 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
175
183
- prefer_for_elements_to_map_fromIterable
176
184
- prefer_foreach
177
- # - prefer_function_declarations_over_variables # not yet tested
185
+ - prefer_function_declarations_over_variables
178
186
- prefer_generic_function_type_aliases
179
187
- prefer_if_elements_to_conditional_expressions
180
188
- prefer_if_null_operators
181
189
- prefer_initializing_formals
182
190
- prefer_inlined_adds
183
- # - prefer_int_literals # not yet tested
184
- # - 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
185
193
- prefer_is_empty
186
194
- prefer_is_not_empty
187
195
- prefer_is_not_operator
188
196
- prefer_iterable_whereType
189
- # - prefer_mixin # https://github.com/dart-lang/language/issues/32
190
- # - prefer_null_aware_operators # disable until NNBD, see https://github.com/flutter/flutter/pull/32711#issuecomment-492930932
191
- # - 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.
192
201
- prefer_single_quotes
193
202
- prefer_spread_collections
194
203
- prefer_typing_uninitialized_variables
195
204
- prefer_void_to_null
196
- # - provide_deprecation_message # not yet tested
205
+ - provide_deprecation_message
197
206
# - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
198
207
- recursive_getters
199
- # - 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
200
212
- slash_for_doc_comments
201
213
- sort_child_properties_last
202
214
- sort_constructors_first
215
+ # - sort_pub_dependencies # prevents separating pinned transitive dependencies
203
216
- sort_unnamed_constructors_first
204
217
- test_types_in_equals
205
218
- throw_in_finally
206
219
- tighten_type_of_initializing_formals
207
220
# - type_annotate_public_apis # subset of always_specify_types
208
221
- type_init_formals
209
- # - unawaited_futures # too many false positives
210
- # - 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.
211
224
- unnecessary_brace_in_string_interps
212
225
- unnecessary_const
226
+ - unnecessary_constructor_name
213
227
# - unnecessary_final # conflicts with prefer_final_locals
214
228
- unnecessary_getters_setters
215
229
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
230
+ - unnecessary_late
216
231
- unnecessary_new
217
232
- unnecessary_null_aware_assignments
218
- # - unnecessary_null_checks # not yet tested
233
+ - unnecessary_null_checks
219
234
- unnecessary_null_in_if_null_operators
220
235
- unnecessary_nullable_for_final_variable_declarations
221
236
- unnecessary_overrides
222
237
- unnecessary_parenthesis
223
- # - 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
224
239
- unnecessary_statements
225
240
- unnecessary_string_escapes
226
241
- unnecessary_string_interpolations
227
242
- unnecessary_this
228
243
- unrelated_type_equality_checks
229
- # - 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
230
249
- use_full_hex_values_for_flutter_colors
231
- # - 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
232
252
- use_is_even_rather_than_modulo
233
253
- use_key_in_widget_constructors
234
254
- use_late_for_private_fields_and_variables
255
+ # - use_named_constants # LOCAL CHANGE - Needs to be enabled and violations fixed.
235
256
- use_raw_strings
236
257
- use_rethrow_when_possible
237
- # - use_setters_to_change_properties # not yet tested
258
+ - use_setters_to_change_properties
238
259
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
260
+ - use_super_parameters
261
+ - use_test_throws_matchers
239
262
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
240
263
- valid_regexps
241
264
- void_checks
242
- # ## Local flutter/plugins changes ###
265
+ # ## Local flutter/plugins additions ###
243
266
# These are from flutter/flutter/packages, so will need to be preserved
244
267
# separately when moving to a shared file.
245
268
- no_runtimeType_toString # use objectRuntimeType from package:foundation
0 commit comments