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