-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathanalysis_options.yaml
More file actions
86 lines (79 loc) · 2.95 KB
/
Copy pathanalysis_options.yaml
File metadata and controls
86 lines (79 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# Flutter 官方推荐 lint 集合
include: package:flutter_lints/flutter.yaml
analyzer:
# 排除自动生成的文件,避免对生成代码进行无意义检查
exclude:
- "**/*.g.dart"
- "**/*.freezed.dart"
# 严格类型模式:减少隐式 dynamic、raw type 与类型推断缺失
language:
strict-casts: true
strict-raw-types: true
strict-inference: true
# 将部分关键问题提升为 error
errors:
missing_required_param: error
missing_return: error
invalid_assignment: warning
invalid_null_aware_operator: warning
linter:
# 在 flutter_lints 基础上补充对脚手架核心代码影响最大的规则。
# 过于风格化或现有扩展代码中大量存在的规则暂未开启,避免无意义噪音。
rules:
# 类型安全与 API 设计
always_declare_return_types: true
type_annotate_public_apis: true
avoid_dynamic_calls: true
avoid_catches_without_on_clauses: true
avoid_returning_null_for_void: true
avoid_return_types_on_setters: true
avoid_shadowing_type_parameters: true
avoid_type_to_string: true
cancel_subscriptions: true
close_sinks: true
no_runtimeType_toString: true
throw_in_finally: true
tighten_type_of_initializing_formals: true
unawaited_futures: true
use_to_and_as_if_applicable: true
# 代码质量
annotate_overrides: false
avoid_implementing_value_types: true
avoid_private_typedef_functions: true
avoid_slow_async_io: true
avoid_unused_constructor_parameters: false
leading_newlines_in_multiline_strings: true
missing_whitespace_between_adjacent_strings: true
no_adjacent_strings_in_list: true
only_throw_errors: true
overridden_fields: false
parameter_assignments: true
prefer_asserts_in_initializer_lists: true
prefer_const_constructors_in_immutables: false
prefer_final_fields: true
prefer_final_in_for_each: true
prefer_is_empty: true
prefer_is_not_empty: true
prefer_null_aware_method_calls: true
recursive_getters: true
unnecessary_await_in_return: true
unnecessary_breaks: true
unnecessary_getters_setters: true
unnecessary_null_aware_assignments: true
unnecessary_null_checks: true
unnecessary_null_in_if_null_operators: true
unnecessary_nullable_for_final_variable_declarations: true
unnecessary_overrides: true
unnecessary_statements: true
unnecessary_to_list_in_spreads: true
use_named_constants: true
use_rethrow_when_possible: true
use_super_parameters: false
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options