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
@@ -134,24 +138,28 @@ linter:
134
138
- leading_newlines_in_multiline_strings
135
139
- library_names
136
140
- library_prefixes
141
+ - library_private_types_in_public_api
137
142
# - lines_longer_than_80_chars # not required by flutter style
138
143
- 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
141
146
- 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.
143
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.
144
151
- no_logic_in_create_state
145
152
# - no_runtimeType_toString # ok in tests; we enable this only in packages/
146
153
- non_constant_identifier_names
154
+ - noop_primitive_operations
147
155
- null_check_on_nullable_type_parameter
148
- # - null_closures # not required by flutter style
156
+ - null_closures
149
157
# - omit_local_variable_types # opposite of always_specify_types
150
158
# - 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.
152
160
- overridden_fields
153
161
- package_api_docs
154
- # - package_names # non conforming packages in sdk
162
+ - package_names
155
163
- package_prefixed_library_names
156
164
# - parameter_assignments # we do this commonly
157
165
- prefer_adjacent_string_concatenation
@@ -171,74 +179,90 @@ linter:
171
179
- prefer_final_fields
172
180
- prefer_final_in_for_each
173
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
174
183
- prefer_for_elements_to_map_fromIterable
175
184
- prefer_foreach
176
- # - prefer_function_declarations_over_variables # not yet tested
185
+ - prefer_function_declarations_over_variables
177
186
- prefer_generic_function_type_aliases
178
187
- prefer_if_elements_to_conditional_expressions
179
188
- prefer_if_null_operators
180
189
- prefer_initializing_formals
181
190
- 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
184
193
- prefer_is_empty
185
194
- prefer_is_not_empty
186
195
- prefer_is_not_operator
187
196
- 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.
191
201
- prefer_single_quotes
192
202
- prefer_spread_collections
193
203
- prefer_typing_uninitialized_variables
194
204
- prefer_void_to_null
195
- # - provide_deprecation_message # not yet tested
205
+ - provide_deprecation_message
196
206
# - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
197
207
- 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
199
212
- slash_for_doc_comments
200
- # - sort_child_properties_last # not yet tested
213
+ - sort_child_properties_last
201
214
- sort_constructors_first
215
+ # - sort_pub_dependencies # prevents separating pinned transitive dependencies
202
216
- sort_unnamed_constructors_first
203
217
- test_types_in_equals
204
218
- throw_in_finally
205
219
- tighten_type_of_initializing_formals
206
220
# - type_annotate_public_apis # subset of always_specify_types
207
221
- 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.
210
224
- unnecessary_brace_in_string_interps
211
225
- unnecessary_const
226
+ - unnecessary_constructor_name
212
227
# - unnecessary_final # conflicts with prefer_final_locals
213
228
- unnecessary_getters_setters
214
229
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
230
+ - unnecessary_late
215
231
- unnecessary_new
216
232
- unnecessary_null_aware_assignments
217
- # - unnecessary_null_checks # not yet tested
233
+ - unnecessary_null_checks
218
234
- unnecessary_null_in_if_null_operators
219
235
- unnecessary_nullable_for_final_variable_declarations
220
236
- unnecessary_overrides
221
237
- 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
223
239
- unnecessary_statements
224
240
- unnecessary_string_escapes
225
241
- unnecessary_string_interpolations
226
242
- unnecessary_this
227
243
- 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
229
249
- 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
231
252
- use_is_even_rather_than_modulo
232
- # - use_key_in_widget_constructors # not yet tested
253
+ - use_key_in_widget_constructors
233
254
- use_late_for_private_fields_and_variables
255
+ # - use_named_constants # LOCAL CHANGE - Needs to be enabled and violations fixed.
234
256
- use_raw_strings
235
257
- use_rethrow_when_possible
236
- # - use_setters_to_change_properties # not yet tested
258
+ - use_setters_to_change_properties
237
259
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
260
+ - use_super_parameters
261
+ - use_test_throws_matchers
238
262
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
239
263
- valid_regexps
240
264
- void_checks
241
- # ## Local flutter/plugins changes ###
265
+ # ## Local flutter/plugins additions ###
242
266
# These are from flutter/flutter/packages, so will need to be preserved
243
267
# separately when moving to a shared file.
244
268
- no_runtimeType_toString # use objectRuntimeType from package:foundation
0 commit comments