Skip to content

Commit 649e4b4

Browse files
committed
style: 格式化代码并更新依赖项
统一代码格式,优化多行表达式为单行以提高可读性 更新pubspec.lock中的依赖版本 调整analysis_options.yaml中的lint规则
1 parent 0950df0 commit 649e4b4

17 files changed

+202
-237
lines changed

analysis_options.yaml

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,54 @@
11
# Specify analysis options.
22
#
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
3+
# For a list of lints, see: https://dart.dev/tools/linter-rules
4+
# For guidelines on configuring static analysis, see:
5+
# https://dart.dev/tools/analysis
66
#
77
# There are other similar analysis options files in the flutter repos,
88
# which should be kept in sync with this file:
99
#
1010
# - 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
11+
# - https://github.com/flutter/packages/blob/main/analysis_options.yaml
1412
#
1513
# This file contains the analysis options used for code in the flutter/flutter
1614
# repository.
1715

1816
analyzer:
1917
language:
2018
strict-casts: true
19+
strict-inference: true
2120
strict-raw-types: true
2221
errors:
23-
# allow self-reference to deprecated members (we do this because otherwise we have
24-
# to annotate every member in every test, assert, etc, when we deprecate something)
22+
# allow deprecated members (we do this because otherwise we have to annotate
23+
# every member in every test, assert, etc, when we or the Dart SDK deprecates
24+
# something (https://github.com/flutter/flutter/issues/143312)
25+
deprecated_member_use: ignore
2526
deprecated_member_use_from_same_package: ignore
2627
exclude:
2728
- "bin/cache/**"
2829
# Ignore protoc generated files
2930
- "dev/conductor/lib/proto/*"
31+
- "engine/**"
32+
33+
formatter:
34+
page_width: 100
3035

3136
linter:
3237
rules:
3338
# 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
39+
# https://github.com/dart-lang/sdk/blob/main/pkg/linter/example/all.yaml
3540
- always_declare_return_types
3641
- always_put_control_body_on_new_line
3742
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
3843
- always_specify_types
3944
# - always_use_package_imports # we do this commonly
4045
- annotate_overrides
46+
- annotate_redeclares
4147
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
4248
- avoid_bool_literals_in_conditional_expressions
4349
# - 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
45-
# avoid_classes_with_only_static_members # # we do this commonly for `abstract final class`es
50+
# - avoid_catching_errors # blocked on https://github.com/dart-lang/linter/issues/4998
51+
# - avoid_classes_with_only_static_members # we do this commonly for `abstract final class`es
4652
- avoid_double_and_int_checks
4753
- avoid_dynamic_calls
4854
- avoid_empty_else
@@ -51,7 +57,8 @@ linter:
5157
- avoid_field_initializers_in_const_classes
5258
# - avoid_final_parameters # incompatible with prefer_final_parameters
5359
- avoid_function_literals_in_foreach_calls
54-
- avoid_implementing_value_types
60+
# - avoid_futureor_void # not yet tested
61+
# - avoid_implementing_value_types # see https://github.com/dart-lang/linter/issues/4558
5562
- avoid_init_to_null
5663
- avoid_js_rounded_ints
5764
# - avoid_multiple_declarations_per_line # seems to be a stylistic choice we don't subscribe to
@@ -93,10 +100,12 @@ linter:
93100
- dangling_library_doc_comments
94101
- depend_on_referenced_packages
95102
- deprecated_consistency
103+
# - deprecated_member_use_from_same_package # we allow self-references to deprecated members
96104
# - diagnostic_describe_all_properties # enabled only at the framework level (packages/flutter/lib)
97105
- directives_ordering
98106
# - discarded_futures # too many false positives, similar to unawaited_futures
99107
# - do_not_use_environment # there are appropriate times to use the environment, especially in our tests and build logic
108+
# - document_ignores # not yet tested
100109
- empty_catches
101110
- empty_constructor_bodies
102111
- empty_statements
@@ -107,32 +116,40 @@ linter:
107116
- hash_and_equals
108117
- implementation_imports
109118
- implicit_call_tearoffs
119+
- implicit_reopen
110120
- invalid_case_patterns
121+
- invalid_runtime_check_with_js_interop_types
111122
# - join_return_with_assignment # not required by flutter style
112123
- leading_newlines_in_multiline_strings
113124
- library_annotations
114125
- library_names
115126
- library_prefixes
116127
- library_private_types_in_public_api
117128
# - lines_longer_than_80_chars # not required by flutter style
118-
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/linter/issues/453
129+
- literal_only_boolean_expressions
130+
# - matching_super_parameters # blocked on https://github.com/dart-lang/language/issues/2509
131+
- missing_code_block_language_in_doc_comment
119132
- missing_whitespace_between_adjacent_strings
120133
- no_adjacent_strings_in_list
121134
- no_default_cases
122135
- no_duplicate_case_values
123136
- no_leading_underscores_for_library_prefixes
124137
- no_leading_underscores_for_local_identifiers
138+
- no_literal_bool_comparisons
125139
- no_logic_in_create_state
126140
# - no_runtimeType_toString # ok in tests; we enable this only in packages/
141+
- no_self_assignments
142+
- no_wildcard_variable_uses
127143
- non_constant_identifier_names
128144
- noop_primitive_operations
129145
- null_check_on_nullable_type_parameter
130146
- null_closures
131147
# - omit_local_variable_types # opposite of always_specify_types
148+
# - omit_obvious_local_variable_types # not yet tested
149+
# - omit_obvious_property_types # not yet tested
132150
# - one_member_abstracts # too many false positives
133151
- only_throw_errors # this does get disabled in a few places where we have legacy code that uses strings et al
134152
- overridden_fields
135-
- package_api_docs
136153
- package_names
137154
- package_prefixed_library_names
138155
# - parameter_assignments # we do this commonly
@@ -148,11 +165,11 @@ linter:
148165
# - prefer_constructors_over_static_methods # far too many false positives
149166
- prefer_contains
150167
# - prefer_double_quotes # opposite of prefer_single_quotes
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
168+
# - prefer_expression_function_bodies # conflicts with ./docs/contributing/Style-guide-for-Flutter-repo.md#consider-using--for-short-functions-and-methods
152169
- prefer_final_fields
153170
- prefer_final_in_for_each
154171
- 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
172+
# - prefer_final_parameters # adds too much verbosity
156173
- prefer_for_elements_to_map_fromIterable
157174
- prefer_foreach
158175
- prefer_function_declarations_over_variables
@@ -161,7 +178,7 @@ linter:
161178
- prefer_if_null_operators
162179
- prefer_initializing_formals
163180
- 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
181+
# - prefer_int_literals # conflicts with ./docs/contributing/Style-guide-for-Flutter-repo.md#use-double-literals-for-double-constants
165182
- prefer_interpolation_to_compose_strings
166183
- prefer_is_empty
167184
- prefer_is_not_empty
@@ -187,22 +204,30 @@ linter:
187204
- sort_constructors_first
188205
# - sort_pub_dependencies # prevents separating pinned transitive dependencies
189206
- sort_unnamed_constructors_first
207+
# - specify_nonobvious_local_variable_types # not yet tested
208+
# - specify_nonobvious_property_types # not yet tested
209+
- strict_top_level_inference
190210
- test_types_in_equals
191211
- throw_in_finally
192212
- tighten_type_of_initializing_formals
193213
# - type_annotate_public_apis # subset of always_specify_types
194214
- type_init_formals
215+
- type_literal_in_constant_pattern
195216
# - unawaited_futures # too many false positives, especially with the way AnimationController works
217+
# - unintended_html_in_doc_comment # blocked on https://github.com/dart-lang/linter/issues/5065
218+
# - unnecessary_async # not yet tested
196219
- unnecessary_await_in_return
197220
- unnecessary_brace_in_string_interps
198221
- unnecessary_breaks
199222
- unnecessary_const
200223
- unnecessary_constructor_name
201224
# - unnecessary_final # conflicts with prefer_final_locals
202225
- unnecessary_getters_setters
226+
# - unnecessary_ignore # Disabled by default to simplify migrations; should be periodically enabled locally to clean up offenders
203227
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
204228
- unnecessary_late
205229
- unnecessary_library_directive
230+
# - unnecessary_library_name # blocked on https://github.com/dart-lang/dartdoc/issues/3882
206231
- unnecessary_new
207232
- unnecessary_null_aware_assignments
208233
- unnecessary_null_aware_operator_on_extension_on_nullable
@@ -217,9 +242,10 @@ linter:
217242
- unnecessary_string_interpolations
218243
- unnecessary_this
219244
- unnecessary_to_list_in_spreads
220-
# - unreachable_from_main # Do not enable this rule until it is un-marked as "experimental" and carefully re-evaluated.
245+
- unnecessary_underscores
246+
- unreachable_from_main
221247
- unrelated_type_equality_checks
222-
- unsafe_html
248+
# - unsafe_variance # not yet tested
223249
- use_build_context_synchronously
224250
- use_colored_box
225251
# - use_decorated_box # leads to bugs: DecoratedBox and Container are not equivalent (Container inserts extra padding)
@@ -239,5 +265,6 @@ linter:
239265
- use_super_parameters
240266
- use_test_throws_matchers
241267
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
268+
- use_truncating_division
242269
- valid_regexps
243270
- void_checks

0 commit comments

Comments
 (0)