1
1
# Specify analysis options.
2
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
3
# For a list of lints, see: http://dart-lang.github.io/linter/lints/
7
4
# See the configuration guide for more
8
- # https://github.com/dart-lang/sdk/tree/master /pkg/analyzer#configuring-the-analyzer
5
+ # https://github.com/dart-lang/sdk/tree/main /pkg/analyzer#configuring-the-analyzer
9
6
#
10
7
# There are other similar analysis options files in the flutter repos,
11
8
# which should be kept in sync with this file:
12
9
#
13
10
# - analysis_options.yaml (this file)
14
- # - packages/flutter/lib/analysis_options_user.yaml
15
11
# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
16
12
# - https://github.com/flutter/engine/blob/master/analysis_options.yaml
13
+ # - https://github.com/flutter/packages/blob/master/analysis_options.yaml
17
14
#
18
- # This file contains the analysis options used by Flutter tools, such as IntelliJ,
19
- # Android Studio, and the `flutter analyze` command .
15
+ # This file contains the analysis options used for code in the flutter/flutter
16
+ # repository .
20
17
21
18
analyzer :
22
- strong-mode :
23
- implicit -casts : false
24
- implicit-dynamic : false
19
+ language :
20
+ strict -casts : true
21
+ strict-raw-types : true
25
22
errors :
26
23
# treat missing required parameters as a warning (not a hint)
27
24
missing_required_param : warning
28
25
# treat missing returns as a warning (not a hint)
29
26
missing_return : warning
30
- # allow having TODOs in the code
27
+ # allow having TODO comments in the code
31
28
todo : ignore
32
29
33
30
linter :
34
31
rules :
35
- # these rules are documented on and in the same order as
36
- # the Dart Lint rules page to make maintenance easier
32
+ # This list is derived from the list of all available lints located at
37
33
# https://github.com/dart-lang/linter/blob/master/example/all.yaml
38
34
- always_declare_return_types
39
35
- always_put_control_body_on_new_line
@@ -43,62 +39,68 @@ linter:
43
39
# - always_use_package_imports # we do this commonly
44
40
- annotate_overrides
45
41
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
46
- # - avoid_as # required for implicit-casts: true
47
42
- avoid_bool_literals_in_conditional_expressions
48
- # - avoid_catches_without_on_clauses # we do this commonly
49
- # - avoid_catching_errors # we do this commonly
43
+ # - avoid_catches_without_on_clauses # blocked on https://github.com/dart-lang/linter/issues/3023
44
+ # - avoid_catching_errors # blocked on https://github.com/dart-lang/linter/issues/3023
50
45
- avoid_classes_with_only_static_members
51
- # - avoid_double_and_int_checks # only useful when targeting JS runtime
46
+ - avoid_double_and_int_checks
47
+ - avoid_dynamic_calls
52
48
- avoid_empty_else
53
49
- avoid_equals_and_hash_code_on_mutable_classes
54
- # - avoid_escaping_inner_quotes # not yet tested
50
+ - avoid_escaping_inner_quotes
55
51
- avoid_field_initializers_in_const_classes
52
+ # - avoid_final_parameters # incompatible with prefer_final_parameters
56
53
- avoid_function_literals_in_foreach_calls
57
- # - avoid_implementing_value_types # not yet tested
54
+ - avoid_implementing_value_types
58
55
- avoid_init_to_null
59
- # - avoid_js_rounded_ints # only useful when targeting JS runtime
56
+ - avoid_js_rounded_ints
57
+ # - avoid_multiple_declarations_per_line # seems to be a stylistic choice we don't subscribe to
60
58
- avoid_null_checks_in_equality_operators
61
- # - avoid_positional_boolean_parameters # not yet tested
62
- # - avoid_print # not yet tested
59
+ # - avoid_positional_boolean_parameters # would have been nice to enable this but by now there's too many places that break it
60
+ - avoid_print
63
61
# - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
64
- # - avoid_redundant_argument_values # not yet tested
62
+ - avoid_redundant_argument_values
65
63
- avoid_relative_lib_imports
66
64
- avoid_renaming_method_parameters
67
65
- avoid_return_types_on_setters
68
- # - avoid_returning_null # there are plenty of valid reasons to return null
69
- # - avoid_returning_null_for_future # not yet tested
66
+ # - avoid_returning_null # still violated by some pre-nnbd code that we haven't yet migrated
67
+ - avoid_returning_null_for_future
70
68
- avoid_returning_null_for_void
71
- # - avoid_returning_this # there are plenty of valid reasons to return this
72
- # - avoid_setters_without_getters # not yet tested
69
+ # - avoid_returning_this # there are enough valid reasons to return ` this` that this lint ends up with too many false positives
70
+ - avoid_setters_without_getters
73
71
- avoid_shadowing_type_parameters
74
72
- avoid_single_cascade_in_expression_statements
75
73
- avoid_slow_async_io
76
- # - avoid_type_to_string # we do this commonly
74
+ - avoid_type_to_string
77
75
- avoid_types_as_parameter_names
78
76
# - avoid_types_on_closure_parameters # conflicts with always_specify_types
79
- # - avoid_unnecessary_containers # not yet tested
77
+ - avoid_unnecessary_containers
80
78
- avoid_unused_constructor_parameters
81
79
- avoid_void_async
82
- # - avoid_web_libraries_in_flutter # not yet tested
80
+ # - avoid_web_libraries_in_flutter # we use web libraries in web-specific code, and our tests prevent us from using them elsewhere
83
81
- await_only_futures
84
82
- camel_case_extensions
85
83
- camel_case_types
86
84
- cancel_subscriptions
87
- # - cascade_invocations # not yet tested
85
+ # - cascade_invocations # doesn't match the typical style of this repo
88
86
- cast_nullable_to_non_nullable
89
87
# - close_sinks # not reliable enough
90
- # - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
88
+ # - comment_references # blocked on https://github.com/dart-lang/linter/issues/1142
89
+ # - conditional_uri_does_not_exist # not yet tested
91
90
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
92
91
- control_flow_in_finally
93
92
# - curly_braces_in_flow_control_structures # not required by flutter style
94
- # - diagnostic_describe_all_properties # not yet tested
93
+ - depend_on_referenced_packages
94
+ - deprecated_consistency
95
+ # - diagnostic_describe_all_properties # enabled only at the framework level (packages/flutter/lib)
95
96
- directives_ordering
96
- # - do_not_use_environment # we do this commonly
97
+ # - do_not_use_environment # there are appropriate times to use the environment, especially in our tests and build logic
97
98
- empty_catches
98
99
- empty_constructor_bodies
99
100
- empty_statements
101
+ - eol_at_end_of_file
100
102
- exhaustive_cases
101
- # - file_names # not yet tested
103
+ - file_names
102
104
- flutter_style_todos
103
105
- hash_and_equals
104
106
- implementation_imports
@@ -108,24 +110,28 @@ linter:
108
110
- leading_newlines_in_multiline_strings
109
111
- library_names
110
112
- library_prefixes
113
+ - library_private_types_in_public_api
111
114
# - lines_longer_than_80_chars # not required by flutter style
112
115
- list_remove_unrelated_type
113
- # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk /issues/34181
114
- # - missing_whitespace_between_adjacent_strings # not yet tested
116
+ # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/linter /issues/453
117
+ - missing_whitespace_between_adjacent_strings
115
118
- no_adjacent_strings_in_list
116
- # - no_default_cases # too many false positives
119
+ - no_default_cases
117
120
- no_duplicate_case_values
121
+ - no_leading_underscores_for_library_prefixes
122
+ - no_leading_underscores_for_local_identifiers
118
123
- no_logic_in_create_state
119
124
# - no_runtimeType_toString # ok in tests; we enable this only in packages/
120
125
- non_constant_identifier_names
126
+ - noop_primitive_operations
121
127
- null_check_on_nullable_type_parameter
122
- # - null_closures # not required by flutter style
128
+ - null_closures
123
129
# - omit_local_variable_types # opposite of always_specify_types
124
130
# - one_member_abstracts # too many false positives
125
- # - only_throw_errors # https://github.com/flutter/flutter/issues/5792
131
+ - only_throw_errors # this does get disabled in a few places where we have legacy code that uses strings et al
126
132
- overridden_fields
127
133
- package_api_docs
128
- # - package_names # non conforming packages in sdk
134
+ - package_names
129
135
- package_prefixed_library_names
130
136
# - parameter_assignments # we do this commonly
131
137
- prefer_adjacent_string_concatenation
@@ -145,34 +151,38 @@ linter:
145
151
- prefer_final_fields
146
152
- prefer_final_in_for_each
147
153
- prefer_final_locals
154
+ # - 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
148
155
- prefer_for_elements_to_map_fromIterable
149
156
- prefer_foreach
150
- # - prefer_function_declarations_over_variables # not yet tested
157
+ - prefer_function_declarations_over_variables
151
158
- prefer_generic_function_type_aliases
152
159
- prefer_if_elements_to_conditional_expressions
153
160
- prefer_if_null_operators
154
161
- prefer_initializing_formals
155
162
- prefer_inlined_adds
156
- # - prefer_int_literals # not yet tested
157
- # - prefer_interpolation_to_compose_strings # not yet tested
163
+ # - prefer_int_literals # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#use-double-literals-for-double-constants
164
+ - prefer_interpolation_to_compose_strings
158
165
- prefer_is_empty
159
166
- prefer_is_not_empty
160
167
- prefer_is_not_operator
161
168
- prefer_iterable_whereType
162
- # - prefer_mixin # https://github.com/dart-lang/language/issues/32
163
- # - prefer_null_aware_operators # disable until NNBD, see https://github.com/flutter/flutter/pull/32711#issuecomment-492930932
164
- # - prefer_relative_imports # not yet tested
169
+ # - prefer_mixin # Has false positives, see https://github.com/dart-lang/linter/issues/3018
170
+ # - prefer_null_aware_method_calls # "call()" is confusing to people new to the language since it's not documented anywhere
171
+ - prefer_null_aware_operators
172
+ - prefer_relative_imports
165
173
- prefer_single_quotes
166
174
- prefer_spread_collections
167
175
- prefer_typing_uninitialized_variables
168
176
- prefer_void_to_null
169
- # - provide_deprecation_message # not yet tested
177
+ - provide_deprecation_message
170
178
# - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
171
179
- recursive_getters
172
- - require_trailing_commas
173
- # - sized_box_for_whitespace # not yet tested
180
+ # - require_trailing_commas # blocked on https://github.com/dart-lang/sdk/issues/47441
181
+ - secure_pubspec_urls
182
+ - sized_box_for_whitespace
183
+ # - sized_box_shrink_expand # not yet tested
174
184
- slash_for_doc_comments
175
- # - sort_child_properties_last # not yet tested
185
+ - sort_child_properties_last
176
186
- sort_constructors_first
177
187
# - sort_pub_dependencies # prevents separating pinned transitive dependencies
178
188
- sort_unnamed_constructors_first
@@ -181,36 +191,46 @@ linter:
181
191
- tighten_type_of_initializing_formals
182
192
# - type_annotate_public_apis # subset of always_specify_types
183
193
- type_init_formals
184
- # - unawaited_futures # too many false positives
185
- # - unnecessary_await_in_return # not yet tested
194
+ # - unawaited_futures # too many false positives, especially with the way AnimationController works
195
+ - unnecessary_await_in_return
186
196
- unnecessary_brace_in_string_interps
187
197
- unnecessary_const
198
+ - unnecessary_constructor_name
188
199
# - unnecessary_final # conflicts with prefer_final_locals
189
200
- unnecessary_getters_setters
190
201
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
202
+ - unnecessary_late
191
203
- unnecessary_new
192
204
- unnecessary_null_aware_assignments
193
- # - unnecessary_null_checks # not yet tested
205
+ - unnecessary_null_checks
194
206
- unnecessary_null_in_if_null_operators
195
207
- unnecessary_nullable_for_final_variable_declarations
196
208
- unnecessary_overrides
197
209
- unnecessary_parenthesis
198
- # - unnecessary_raw_strings # not yet tested
210
+ # - unnecessary_raw_strings # what's "necessary" is a matter of opinion; consistency across strings can help readability more than this lint
199
211
- unnecessary_statements
200
212
- unnecessary_string_escapes
201
213
- unnecessary_string_interpolations
202
214
- unnecessary_this
203
215
- unrelated_type_equality_checks
204
- # - unsafe_html # not yet tested
216
+ - unsafe_html
217
+ # - use_build_context_synchronously
218
+ # - use_colored_box # not yet tested
219
+ # - use_decorated_box # not yet tested
220
+ # - use_enums # not yet tested
205
221
- use_full_hex_values_for_flutter_colors
206
- # - use_function_type_syntax_for_parameters # not yet tested
222
+ - use_function_type_syntax_for_parameters
223
+ - use_if_null_to_convert_nulls_to_bools
207
224
- use_is_even_rather_than_modulo
208
- # - use_key_in_widget_constructors # not yet tested
225
+ - use_key_in_widget_constructors
209
226
- use_late_for_private_fields_and_variables
227
+ - use_named_constants
210
228
- use_raw_strings
211
229
- use_rethrow_when_possible
212
- # - use_setters_to_change_properties # not yet tested
230
+ - use_setters_to_change_properties
213
231
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
232
+ - use_super_parameters
233
+ - use_test_throws_matchers
214
234
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
215
235
- valid_regexps
216
- - void_checks
236
+ - void_checks
0 commit comments