Skip to content

Commit 773d51f

Browse files
committed
style(functions): update lint rules and analysis options
1 parent 928202d commit 773d51f

File tree

2 files changed

+276
-0
lines changed

2 files changed

+276
-0
lines changed
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
# Copyright 2021 The Chromium Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# in the LICENSE file.
4+
5+
linter:
6+
rules:
7+
- always_declare_return_types
8+
- always_put_control_body_on_new_line
9+
- always_put_required_named_parameters_first
10+
- always_require_non_null_named_parameters
11+
- always_specify_types
12+
- always_use_package_imports
13+
- annotate_overrides
14+
- avoid_annotating_with_dynamic
15+
- avoid_as
16+
- avoid_bool_literals_in_conditional_expressions
17+
- avoid_catches_without_on_clauses
18+
- avoid_catching_errors
19+
- avoid_classes_with_only_static_members
20+
- avoid_double_and_int_checks
21+
- avoid_empty_else
22+
- avoid_equals_and_hash_code_on_mutable_classes
23+
- avoid_escaping_inner_quotes
24+
- avoid_field_initializers_in_const_classes
25+
- avoid_function_literals_in_foreach_calls
26+
- avoid_implementing_value_types
27+
- avoid_init_to_null
28+
- avoid_js_rounded_ints
29+
- avoid_null_checks_in_equality_operators
30+
- avoid_positional_boolean_parameters
31+
- avoid_print
32+
- avoid_private_typedef_functions
33+
- avoid_redundant_argument_values
34+
- avoid_relative_lib_imports
35+
- avoid_renaming_method_parameters
36+
- avoid_return_types_on_setters
37+
- avoid_returning_null
38+
- avoid_returning_null_for_future
39+
- avoid_returning_null_for_void
40+
- avoid_returning_this
41+
- avoid_setters_without_getters
42+
- avoid_shadowing_type_parameters
43+
- avoid_single_cascade_in_expression_statements
44+
- avoid_slow_async_io
45+
- avoid_type_to_string
46+
- avoid_types_as_parameter_names
47+
- avoid_types_on_closure_parameters
48+
- avoid_unnecessary_containers
49+
- avoid_unused_constructor_parameters
50+
- avoid_void_async
51+
- avoid_web_libraries_in_flutter
52+
- await_only_futures
53+
- camel_case_extensions
54+
- camel_case_types
55+
- cancel_subscriptions
56+
- cascade_invocations
57+
- cast_nullable_to_non_nullable
58+
- close_sinks
59+
- comment_references
60+
- constant_identifier_names
61+
- control_flow_in_finally
62+
- curly_braces_in_flow_control_structures
63+
- diagnostic_describe_all_properties
64+
- directives_ordering
65+
- do_not_use_environment
66+
- empty_catches
67+
- empty_constructor_bodies
68+
- empty_statements
69+
- exhaustive_cases
70+
- file_names
71+
- flutter_style_todos
72+
- hash_and_equals
73+
- implementation_imports
74+
- invariant_booleans
75+
- iterable_contains_unrelated_type
76+
- join_return_with_assignment
77+
- leading_newlines_in_multiline_strings
78+
- library_names
79+
- library_prefixes
80+
- lines_longer_than_80_chars
81+
- list_remove_unrelated_type
82+
- literal_only_boolean_expressions
83+
- missing_whitespace_between_adjacent_strings
84+
- no_adjacent_strings_in_list
85+
- no_default_cases
86+
- no_duplicate_case_values
87+
- no_logic_in_create_state
88+
- no_runtimeType_toString
89+
- non_constant_identifier_names
90+
- null_check_on_nullable_type_parameter
91+
- null_closures
92+
- omit_local_variable_types
93+
- one_member_abstracts
94+
- only_throw_errors
95+
- overridden_fields
96+
- package_api_docs
97+
- package_names
98+
- package_prefixed_library_names
99+
- parameter_assignments
100+
- prefer_adjacent_string_concatenation
101+
- prefer_asserts_in_initializer_lists
102+
- prefer_asserts_with_message
103+
- prefer_collection_literals
104+
- prefer_conditional_assignment
105+
- prefer_const_constructors
106+
- prefer_const_constructors_in_immutables
107+
- prefer_const_declarations
108+
- prefer_const_literals_to_create_immutables
109+
- prefer_constructors_over_static_methods
110+
- prefer_contains
111+
- prefer_double_quotes
112+
- prefer_equal_for_default_values
113+
- prefer_expression_function_bodies
114+
- prefer_final_fields
115+
- prefer_final_in_for_each
116+
- prefer_final_locals
117+
- prefer_for_elements_to_map_fromIterable
118+
- prefer_foreach
119+
- prefer_function_declarations_over_variables
120+
- prefer_generic_function_type_aliases
121+
- prefer_if_elements_to_conditional_expressions
122+
- prefer_if_null_operators
123+
- prefer_initializing_formals
124+
- prefer_inlined_adds
125+
- prefer_int_literals
126+
- prefer_interpolation_to_compose_strings
127+
- prefer_is_empty
128+
- prefer_is_not_empty
129+
- prefer_is_not_operator
130+
- prefer_iterable_whereType
131+
- prefer_mixin
132+
- prefer_null_aware_operators
133+
- prefer_relative_imports
134+
- prefer_single_quotes
135+
- prefer_spread_collections
136+
- prefer_typing_uninitialized_variables
137+
- prefer_void_to_null
138+
- provide_deprecation_message
139+
- public_member_api_docs
140+
- recursive_getters
141+
- sized_box_for_whitespace
142+
- slash_for_doc_comments
143+
- sort_child_properties_last
144+
- sort_constructors_first
145+
- sort_pub_dependencies
146+
- sort_unnamed_constructors_first
147+
- test_types_in_equals
148+
- throw_in_finally
149+
- tighten_type_of_initializing_formals
150+
- type_annotate_public_apis
151+
- type_init_formals
152+
- unawaited_futures
153+
- unnecessary_await_in_return
154+
- unnecessary_brace_in_string_interps
155+
- unnecessary_const
156+
- unnecessary_final
157+
- unnecessary_getters_setters
158+
- unnecessary_lambdas
159+
- unnecessary_new
160+
- unnecessary_null_aware_assignments
161+
- unnecessary_null_checks
162+
- unnecessary_null_in_if_null_operators
163+
- unnecessary_nullable_for_final_variable_declarations
164+
- unnecessary_overrides
165+
- unnecessary_parenthesis
166+
- unnecessary_raw_strings
167+
- unnecessary_statements
168+
- unnecessary_string_escapes
169+
- unnecessary_string_interpolations
170+
- unnecessary_this
171+
- unrelated_type_equality_checks
172+
- unsafe_html
173+
- use_full_hex_values_for_flutter_colors
174+
- use_function_type_syntax_for_parameters
175+
- use_is_even_rather_than_modulo
176+
- use_key_in_widget_constructors
177+
- use_late_for_private_fields_and_variables
178+
- use_raw_strings
179+
- use_rethrow_when_possible
180+
- use_setters_to_change_properties
181+
- use_string_buffers
182+
- use_to_and_as_if_applicable
183+
- valid_regexps
184+
- void_checks
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Copyright 2021 The Chromium Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# in the LICENSE file.
4+
5+
include: all_lint_rules.yaml
6+
analyzer:
7+
# TODO(rrousselGit): disable implicit-cast/implicit-dynamic
8+
errors:
9+
# Otherwise cause the import of all_lint_rules to warn because of some rules conflicts.
10+
# We explicitly enabled even conflicting rules and are fixing the conflict
11+
# in this file
12+
included_file_warning: ignore
13+
14+
linter:
15+
rules:
16+
## Disabled rules because the repository doesn't respect them (yet)
17+
18+
always_put_control_body_on_new_line: false
19+
comment_references: false
20+
prefer_constructors_over_static_methods: false
21+
prefer_final_fields: false
22+
prefer_final_locals: false
23+
omit_local_variable_types: false
24+
avoid_equals_and_hash_code_on_mutable_classes: false
25+
26+
#############
27+
28+
# Personal preference. I don't find it more readable
29+
cascade_invocations: false
30+
31+
# Conflicts with `prefer_single_quotes`
32+
# Single quotes are easier to type and don't compromise on readability.
33+
prefer_double_quotes: false
34+
35+
# Conflicts with `omit_local_variable_types` and other rules.
36+
# As per Dart guidelines, we want to avoid unnecessary types to make the code
37+
# more readable.
38+
# See https://dart.dev/guides/language/effective-dart/design#avoid-type-annotating-initialized-local-variables
39+
always_specify_types: false
40+
41+
# Incompatible with `prefer_final_locals`
42+
# Having immutable local variables makes larger functions more predictible
43+
# so we will use `prefer_final_locals` instead.
44+
unnecessary_final: false
45+
46+
# Not quite suitable for Flutter, which may have a `build` method with a single
47+
# return, but that return is still complex enough that a "body" is worth it.
48+
prefer_expression_function_bodies: false
49+
50+
# Conflicts with the convention used by flutter, which puts `Key key`
51+
# and `@required Widget child` last.
52+
always_put_required_named_parameters_first: false
53+
54+
# `as` is not that bad (especially with the upcoming non-nullable types).
55+
# Explicit exceptions is better than implicit exceptions.
56+
avoid_as: false
57+
58+
# This project doesn't use Flutter-style todos
59+
flutter_style_todos: false
60+
61+
# There are situations where we voluntarily want to catch everything,
62+
# especially as a library.
63+
avoid_catches_without_on_clauses: false
64+
65+
# Boring as it sometimes force a line of 81 characters to be split in two.
66+
# As long as we try to respect that 80 characters limit, going slightly
67+
# above is fine.
68+
lines_longer_than_80_chars: false
69+
70+
# Conflicts with disabling `implicit-dynamic`
71+
avoid_annotating_with_dynamic: false
72+
73+
# conflicts with `prefer_relative_imports`
74+
always_use_package_imports: false
75+
76+
# Disabled for now until we have NNBD as it otherwise conflicts with `missing_return`
77+
no_default_cases: false
78+
79+
# False positive, null checks don't need a message
80+
prefer_asserts_with_message: false
81+
82+
# Cumbersome with `context.select`
83+
avoid_types_on_closure_parameters: false
84+
85+
# Too many false positive (builders)
86+
diagnostic_describe_all_properties: false
87+
88+
# false positives (setter-like functions)
89+
avoid_positional_boolean_parameters: false
90+
91+
# Does not apply to providers
92+
prefer_const_constructors_in_immutables: false

0 commit comments

Comments
 (0)