|
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 |
| 1 | +includes: package:flutter_lints/flutter.yaml |
29 | 2 |
|
30 | 3 | linter:
|
31 | 4 | rules:
|
32 |
| - # these rules are documented on and in the same order as |
33 |
| - # the Dart Lint rules page to make maintenance easier |
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 # we do this commonly |
45 |
| - # - avoid_catching_errors # we do this commonly |
46 |
| - - avoid_classes_with_only_static_members |
47 |
| - # - avoid_double_and_int_checks # only useful when targeting JS runtime |
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_function_literals_in_foreach_calls |
54 |
| - # - avoid_implementing_value_types # not yet tested |
55 |
| - - avoid_init_to_null |
56 |
| - # - avoid_js_rounded_ints # only useful when targeting JS runtime |
57 |
| - - avoid_null_checks_in_equality_operators |
58 |
| - # - avoid_positional_boolean_parameters # not yet tested |
59 |
| - # - avoid_print # not yet tested |
60 |
| - # - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356) |
61 |
| - - avoid_redundant_argument_values |
62 |
| - - avoid_relative_lib_imports |
63 |
| - - avoid_renaming_method_parameters |
64 |
| - - avoid_return_types_on_setters |
65 |
| - # - avoid_returning_null # there are plenty of valid reasons to return null |
66 |
| - # - avoid_returning_null_for_future # not yet tested |
67 |
| - - avoid_returning_null_for_void |
68 |
| - # - avoid_returning_this # there are plenty of valid reasons to return this |
69 |
| - # - avoid_setters_without_getters # not yet tested |
70 |
| - - avoid_shadowing_type_parameters |
71 |
| - - avoid_single_cascade_in_expression_statements |
72 |
| - - avoid_slow_async_io |
73 |
| - - avoid_type_to_string |
74 |
| - - avoid_types_as_parameter_names |
75 |
| - # - avoid_types_on_closure_parameters # conflicts with always_specify_types |
76 |
| - - avoid_unnecessary_containers |
77 |
| - - avoid_unused_constructor_parameters |
78 |
| - - avoid_void_async |
79 |
| - # - avoid_web_libraries_in_flutter # not yet tested |
80 |
| - - await_only_futures |
81 |
| - - camel_case_extensions |
82 |
| - - camel_case_types |
83 |
| - - cancel_subscriptions |
84 |
| - # - cascade_invocations # not yet tested |
85 |
| - # - close_sinks # not reliable enough |
86 |
| - # - comment_references # blocked on https://github.com/dart-lang/linter/issues/1142 |
87 |
| - # - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204 |
88 |
| - - control_flow_in_finally |
89 |
| - # - curly_braces_in_flow_control_structures # not required by flutter style |
90 |
| - - deprecated_consistency |
91 |
| - # - diagnostic_describe_all_properties # not yet tested |
92 |
| - - directives_ordering |
93 |
| - # - do_not_use_environment # we do this commonly |
94 |
| - - empty_catches |
95 |
| - - empty_constructor_bodies |
96 |
| - - empty_statements |
97 |
| - - exhaustive_cases |
98 |
| - - file_names |
99 |
| - - flutter_style_todos |
100 |
| - - hash_and_equals |
101 |
| - - implementation_imports |
102 |
| - # - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811 |
103 |
| - - iterable_contains_unrelated_type |
104 |
| - # - join_return_with_assignment # not required by flutter style |
105 |
| - - leading_newlines_in_multiline_strings |
106 |
| - - library_names |
107 |
| - - library_prefixes |
108 |
| - # - lines_longer_than_80_chars # not required by flutter style |
109 |
| - - list_remove_unrelated_type |
110 |
| - # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181 |
111 |
| - - missing_whitespace_between_adjacent_strings |
112 |
| - - no_adjacent_strings_in_list |
113 |
| - # - no_default_cases # too many false positives |
114 |
| - - no_duplicate_case_values |
115 |
| - - no_logic_in_create_state |
116 |
| - # - no_runtimeType_toString # ok in tests; we enable this only in packages/ |
117 |
| - - noop_primitive_operations |
118 |
| - - non_constant_identifier_names |
119 |
| - - null_check_on_nullable_type_parameter |
120 |
| - - null_closures |
121 |
| - # - omit_local_variable_types # opposite of always_specify_types |
122 |
| - # - one_member_abstracts # too many false positives |
123 |
| - # - only_throw_errors # https://github.com/flutter/flutter/issues/5792 |
124 |
| - - overridden_fields |
125 |
| - - package_api_docs |
126 |
| - - package_names |
127 |
| - - package_prefixed_library_names |
128 |
| - # - parameter_assignments # we do this commonly |
129 |
| - - prefer_adjacent_string_concatenation |
130 |
| - - prefer_asserts_in_initializer_lists |
131 |
| - # - prefer_asserts_with_message # not required by flutter style |
132 |
| - - prefer_collection_literals |
133 |
| - - prefer_conditional_assignment |
134 |
| - - prefer_const_constructors |
135 |
| - - prefer_const_constructors_in_immutables |
136 |
| - - prefer_const_declarations |
137 |
| - - prefer_const_literals_to_create_immutables |
138 |
| - # - prefer_constructors_over_static_methods # far too many false positives |
139 |
| - - prefer_contains |
140 |
| - # - prefer_double_quotes # opposite of prefer_single_quotes |
141 |
| - # - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods |
142 |
| - - prefer_final_fields |
143 |
| - - prefer_final_in_for_each |
144 |
| - - prefer_final_locals |
145 |
| - - prefer_for_elements_to_map_fromIterable |
146 |
| - - prefer_foreach |
147 |
| - - prefer_function_declarations_over_variables |
148 |
| - - prefer_generic_function_type_aliases |
149 |
| - - prefer_if_elements_to_conditional_expressions |
150 |
| - - prefer_if_null_operators |
151 |
| - - prefer_initializing_formals |
152 |
| - - prefer_inlined_adds |
153 |
| - # - prefer_int_literals # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#use-double-literals-for-double-constants |
154 |
| - - prefer_interpolation_to_compose_strings |
155 |
| - - prefer_is_empty |
156 |
| - - prefer_is_not_empty |
157 |
| - - prefer_is_not_operator |
158 |
| - - prefer_iterable_whereType |
159 |
| - # - prefer_mixin # https://github.com/dart-lang/language/issues/32 |
160 |
| - - prefer_null_aware_operators |
161 |
| - # - prefer_relative_imports # incompatible with sub-package imports |
162 |
| - - prefer_single_quotes |
163 |
| - - prefer_spread_collections |
164 |
| - - prefer_typing_uninitialized_variables |
165 |
| - - prefer_void_to_null |
166 |
| - - provide_deprecation_message |
167 |
| - # - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml |
168 |
| - - recursive_getters |
169 |
| - - require_trailing_commas |
170 |
| - - sized_box_for_whitespace |
171 |
| - - slash_for_doc_comments |
172 |
| - # - sort_child_properties_last # not yet tested |
173 |
| - - sort_constructors_first |
174 |
| - # - sort_pub_dependencies # prevents separating pinned transitive dependencies |
175 |
| - - sort_unnamed_constructors_first |
176 |
| - - test_types_in_equals |
177 |
| - - throw_in_finally |
178 |
| - - tighten_type_of_initializing_formals |
179 |
| - # - type_annotate_public_apis # subset of always_specify_types |
180 |
| - - type_init_formals |
181 |
| - # - unawaited_futures # too many false positives |
182 |
| - - unnecessary_await_in_return |
183 |
| - - unnecessary_brace_in_string_interps |
184 |
| - - unnecessary_const |
185 |
| - # - unnecessary_final # conflicts with prefer_final_locals |
186 |
| - - unnecessary_getters_setters |
187 |
| - # - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498 |
188 |
| - - unnecessary_new |
189 |
| - - unnecessary_null_aware_assignments |
190 |
| - - unnecessary_null_checks |
191 |
| - - unnecessary_null_in_if_null_operators |
192 |
| - - unnecessary_nullable_for_final_variable_declarations |
193 |
| - - unnecessary_overrides |
194 |
| - - unnecessary_parenthesis |
195 |
| - # - unnecessary_raw_strings # not yet tested |
196 |
| - - unnecessary_statements |
197 |
| - - unnecessary_string_escapes |
198 |
| - - unnecessary_string_interpolations |
199 |
| - - unnecessary_this |
200 |
| - - unrelated_type_equality_checks |
201 |
| - # - unsafe_html # not yet tested |
202 |
| - - use_full_hex_values_for_flutter_colors |
203 |
| - - use_function_type_syntax_for_parameters |
204 |
| - # - use_if_null_to_convert_nulls_to_bools # not yet tested |
205 |
| - - use_is_even_rather_than_modulo |
206 |
| - - use_key_in_widget_constructors |
207 |
| - - use_late_for_private_fields_and_variables |
208 |
| - - use_named_constants |
209 |
| - - use_raw_strings |
210 |
| - - use_rethrow_when_possible |
211 |
| - # - use_setters_to_change_properties # not yet tested |
212 |
| - # - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182 |
213 |
| - - use_test_throws_matchers |
214 |
| - # - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review |
215 |
| - - valid_regexps |
216 |
| - - 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