Skip to content

Commit 160142b

Browse files
committed
Add analysis_options for linting
1 parent c3e1057 commit 160142b

File tree

1 file changed

+133
-0
lines changed

1 file changed

+133
-0
lines changed

analysis_options.yaml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
analyzer:
2+
language:
3+
enableSuperMixins: true
4+
strong-mode:
5+
implicit-dynamic: false
6+
errors:
7+
# treat missing required parameters as a warning (not a hint)
8+
missing_required_param: warning
9+
# treat missing returns as a warning (not a hint)
10+
missing_return: warning
11+
# allow having TODOs in the code
12+
todo: ignore
13+
14+
linter:
15+
rules:
16+
# these rules are documented on and in the same order as
17+
# the Dart Lint rules page to make maintenance easier
18+
# https://github.com/dart-lang/linter/blob/master/example/all.yaml
19+
- always_declare_return_types
20+
- always_put_control_body_on_new_line
21+
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
22+
- always_require_non_null_named_parameters
23+
- always_specify_types
24+
- annotate_overrides
25+
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
26+
- avoid_as
27+
# - avoid_bool_literals_in_conditional_expressions # not yet tested
28+
# - avoid_catches_without_on_clauses # we do this commonly
29+
# - avoid_catching_errors # we do this commonly
30+
- avoid_classes_with_only_static_members
31+
# - avoid_double_and_int_checks # only useful when targeting JS runtime
32+
- avoid_empty_else
33+
- avoid_field_initializers_in_const_classes
34+
- avoid_function_literals_in_foreach_calls
35+
- avoid_init_to_null
36+
# - avoid_js_rounded_ints # only useful when targeting JS runtime
37+
- avoid_null_checks_in_equality_operators
38+
# - avoid_positional_boolean_parameters # not yet tested
39+
# - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
40+
- avoid_relative_lib_imports
41+
- avoid_renaming_method_parameters
42+
- avoid_return_types_on_setters
43+
# - avoid_returning_null # there are plenty of valid reasons to return null
44+
# - avoid_returning_this # there are plenty of valid reasons to return this
45+
# - avoid_setters_without_getters # not yet tested
46+
# - avoid_single_cascade_in_expression_statements # not yet tested
47+
- avoid_slow_async_io
48+
- avoid_types_as_parameter_names
49+
# - avoid_types_on_closure_parameters # conflicts with always_specify_types
50+
- avoid_unused_constructor_parameters
51+
- await_only_futures
52+
- camel_case_types
53+
- cancel_subscriptions
54+
# - cascade_invocations # not yet tested
55+
# - close_sinks # not reliable enough
56+
# - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
57+
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
58+
- control_flow_in_finally
59+
- directives_ordering
60+
- empty_catches
61+
- empty_constructor_bodies
62+
- empty_statements
63+
- hash_and_equals
64+
- implementation_imports
65+
# - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811
66+
- iterable_contains_unrelated_type
67+
# - join_return_with_assignment # not yet tested
68+
- library_names
69+
- library_prefixes
70+
- list_remove_unrelated_type
71+
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
72+
- no_adjacent_strings_in_list
73+
- no_duplicate_case_values
74+
- non_constant_identifier_names
75+
# - omit_local_variable_types # opposite of always_specify_types
76+
# - one_member_abstracts # too many false positives
77+
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792
78+
- overridden_fields
79+
- package_api_docs
80+
- package_names
81+
- package_prefixed_library_names
82+
# - parameter_assignments # we do this commonly
83+
- prefer_adjacent_string_concatenation
84+
- prefer_asserts_in_initializer_lists
85+
- prefer_bool_in_asserts
86+
- prefer_collection_literals
87+
- prefer_conditional_assignment
88+
- prefer_const_constructors
89+
- prefer_const_constructors_in_immutables
90+
- prefer_const_declarations
91+
- prefer_const_literals_to_create_immutables
92+
# - prefer_constructors_over_static_methods # not yet tested
93+
- prefer_contains
94+
- prefer_equal_for_default_values
95+
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
96+
- prefer_final_fields
97+
- prefer_final_locals
98+
- prefer_foreach
99+
# - prefer_function_declarations_over_variables # not yet tested
100+
- prefer_initializing_formals
101+
# - prefer_interpolation_to_compose_strings # not yet tested
102+
- prefer_iterable_whereType
103+
- prefer_is_empty
104+
- prefer_is_not_empty
105+
- prefer_single_quotes
106+
- prefer_typing_uninitialized_variables
107+
# - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
108+
- recursive_getters
109+
- slash_for_doc_comments
110+
- sort_constructors_first
111+
- sort_unnamed_constructors_first
112+
- super_goes_last
113+
- test_types_in_equals
114+
- throw_in_finally
115+
# - type_annotate_public_apis # subset of always_specify_types
116+
- type_init_formals
117+
# - unawaited_futures # too many false positives
118+
- unnecessary_brace_in_string_interps
119+
- unnecessary_const
120+
- unnecessary_getters_setters
121+
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
122+
- unnecessary_null_aware_assignments
123+
- unnecessary_null_in_if_null_operators
124+
- unnecessary_overrides
125+
- unnecessary_parenthesis
126+
- unnecessary_statements
127+
- unnecessary_this
128+
- unrelated_type_equality_checks
129+
- use_rethrow_when_possible
130+
# - use_setters_to_change_properties # not yet tested
131+
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
132+
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
133+
- valid_regexps

0 commit comments

Comments
 (0)