Skip to content

Commit 51030b0

Browse files
committed
chore: update lint rules
This commit updates the lint rules in `all_lint_rules.yaml` and adjusts the `analysis_options.yaml` files accordingly. The following changes were made: - **Enabled new lint rules:** A significant number of new lint rules from the Flutter and Dart linters have been added to `all_lint_rules.yaml`. - **Removed deprecated/conflicting lint rules:** - `always_require_non_null_named_parameters` - `avoid_returning_null` - `avoid_returning_null_for_future` - `iterable_contains_unrelated_type` (replaced by stricter checks) - `list_remove_unrelated_type` (replaced by stricter checks) - `package_api_docs` - `prefer_equal_for_default_values` - **Adjusted `analysis_options.yaml`:** - Added `packages/*/lib/**/*.freezed.dart` to the exclude list. - Disabled `document_ignores` as it's considered redundant. - Disabled `specify_nonobvious_local_variable_types` and `specify_nonobvious_property_types` due to conflict with `omit_local_variable_types`. - Temporarily disabled `public_member_api_docs` (moved from `avoid_print`). - **Adjusted `sample_app/analysis_options.yaml`:** - Added `lib/**/*.g.dart` and `lib/**/*.freezed.dart` to the exclude list (as a temporary workaround for an issue with root analysis file exclusion).
1 parent 7fde7d1 commit 51030b0

File tree

3 files changed

+50
-13
lines changed

3 files changed

+50
-13
lines changed

all_lint_rules.yaml

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ linter:
33
- always_declare_return_types
44
- always_put_control_body_on_new_line
55
- always_put_required_named_parameters_first
6-
- always_require_non_null_named_parameters
76
- always_specify_types
87
- always_use_package_imports
98
- annotate_overrides
9+
- annotate_redeclares
1010
- avoid_annotating_with_dynamic
1111
- avoid_bool_literals_in_conditional_expressions
1212
- avoid_catches_without_on_clauses
@@ -20,6 +20,7 @@ linter:
2020
- avoid_field_initializers_in_const_classes
2121
- avoid_final_parameters
2222
- avoid_function_literals_in_foreach_calls
23+
- avoid_futureor_void
2324
- avoid_implementing_value_types
2425
- avoid_init_to_null
2526
- avoid_js_rounded_ints
@@ -32,8 +33,6 @@ linter:
3233
- avoid_relative_lib_imports
3334
- avoid_renaming_method_parameters
3435
- avoid_return_types_on_setters
35-
- avoid_returning_null
36-
- avoid_returning_null_for_future
3736
- avoid_returning_null_for_void
3837
- avoid_returning_this
3938
- avoid_setters_without_getters
@@ -61,12 +60,15 @@ linter:
6160
- constant_identifier_names
6261
- control_flow_in_finally
6362
- curly_braces_in_flow_control_structures
63+
- dangling_library_doc_comments
6464
- depend_on_referenced_packages
6565
- deprecated_consistency
66+
- deprecated_member_use_from_same_package
6667
- diagnostic_describe_all_properties
6768
- directives_ordering
6869
- discarded_futures
6970
- do_not_use_environment
71+
- document_ignores
7072
- empty_catches
7173
- empty_constructor_bodies
7274
- empty_statements
@@ -76,32 +78,41 @@ linter:
7678
- flutter_style_todos
7779
- hash_and_equals
7880
- implementation_imports
79-
- iterable_contains_unrelated_type
81+
- implicit_call_tearoffs
82+
- implicit_reopen
83+
- invalid_case_patterns
84+
- invalid_runtime_check_with_js_interop_types
8085
- join_return_with_assignment
8186
- leading_newlines_in_multiline_strings
87+
- library_annotations
8288
- library_names
8389
- library_prefixes
8490
- library_private_types_in_public_api
8591
- lines_longer_than_80_chars
86-
- list_remove_unrelated_type
8792
- literal_only_boolean_expressions
93+
- matching_super_parameters
94+
- missing_code_block_language_in_doc_comment
8895
- missing_whitespace_between_adjacent_strings
8996
- no_adjacent_strings_in_list
9097
- no_default_cases
9198
- no_duplicate_case_values
9299
- no_leading_underscores_for_library_prefixes
93100
- no_leading_underscores_for_local_identifiers
101+
- no_literal_bool_comparisons
94102
- no_logic_in_create_state
95103
- no_runtimeType_toString
104+
- no_self_assignments
105+
- no_wildcard_variable_uses
96106
- non_constant_identifier_names
97107
- noop_primitive_operations
98108
- null_check_on_nullable_type_parameter
99109
- null_closures
100110
- omit_local_variable_types
111+
- omit_obvious_local_variable_types
112+
- omit_obvious_property_types
101113
- one_member_abstracts
102114
- only_throw_errors
103115
- overridden_fields
104-
- package_api_docs
105116
- package_names
106117
- package_prefixed_library_names
107118
- parameter_assignments
@@ -117,7 +128,6 @@ linter:
117128
- prefer_constructors_over_static_methods
118129
- prefer_contains
119130
- prefer_double_quotes
120-
- prefer_equal_for_default_values
121131
- prefer_expression_function_bodies
122132
- prefer_final_fields
123133
- prefer_final_in_for_each
@@ -157,20 +167,31 @@ linter:
157167
- sort_constructors_first
158168
- sort_pub_dependencies
159169
- sort_unnamed_constructors_first
170+
- specify_nonobvious_local_variable_types
171+
- specify_nonobvious_property_types
172+
- strict_top_level_inference
173+
- switch_on_type
160174
- test_types_in_equals
161175
- throw_in_finally
162176
- tighten_type_of_initializing_formals
163177
- type_annotate_public_apis
164178
- type_init_formals
179+
- type_literal_in_constant_pattern
165180
- unawaited_futures
181+
- unintended_html_in_doc_comment
182+
- unnecessary_async
166183
- unnecessary_await_in_return
167184
- unnecessary_brace_in_string_interps
185+
- unnecessary_breaks
168186
- unnecessary_const
169187
- unnecessary_constructor_name
170188
- unnecessary_final
171189
- unnecessary_getters_setters
190+
- unnecessary_ignore
172191
- unnecessary_lambdas
173192
- unnecessary_late
193+
- unnecessary_library_directive
194+
- unnecessary_library_name
174195
- unnecessary_new
175196
- unnecessary_null_aware_assignments
176197
- unnecessary_null_aware_operator_on_extension_on_nullable
@@ -185,9 +206,11 @@ linter:
185206
- unnecessary_string_interpolations
186207
- unnecessary_this
187208
- unnecessary_to_list_in_spreads
209+
- unnecessary_unawaited
210+
- unnecessary_underscores
188211
- unreachable_from_main
189212
- unrelated_type_equality_checks
190-
- unsafe_html
213+
- unsafe_variance
191214
- use_build_context_synchronously
192215
- use_colored_box
193216
- use_decorated_box
@@ -199,6 +222,7 @@ linter:
199222
- use_key_in_widget_constructors
200223
- use_late_for_private_fields_and_variables
201224
- use_named_constants
225+
- use_null_aware_elements
202226
- use_raw_strings
203227
- use_rethrow_when_possible
204228
- use_setters_to_change_properties
@@ -207,5 +231,6 @@ linter:
207231
- use_super_parameters
208232
- use_test_throws_matchers
209233
- use_to_and_as_if_applicable
234+
- use_truncating_division
210235
- valid_regexps
211-
- void_checks
236+
- void_checks

analysis_options.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ analyzer:
1010
# We explicitly enabled even conflicting rules and are fixing the conflict
1111
# in this file.
1212
included_file_warning: ignore
13-
14-
todo: ignore
1513
exclude:
1614
# exclude all the generated files
1715
- packages/*/lib/**/*.g.dart
16+
- packages/*/lib/**/*.freezed.dart
1817

1918
linter:
2019
rules:
@@ -93,6 +92,12 @@ linter:
9392
# There are situations where we use default in enums on purpose
9493
no_default_cases: false
9594

96-
# Temporarily disabled to find more important issues
95+
# Redundant and not required
96+
document_ignores: false
97+
98+
# Conflicts with `omit_local_variable_types`
99+
specify_nonobvious_local_variable_types: false
100+
specify_nonobvious_property_types: false
101+
102+
# TODO: Temporarily disabled to find more important issues
97103
public_member_api_docs: false
98-
avoid_print: false

sample_app/analysis_options.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
include: ../analysis_options.yaml
22

3+
analyzer:
4+
# TODO: not working if added on the root analysis file
5+
exclude:
6+
# exclude all the generated files
7+
- lib/**/*.g.dart
8+
- lib/**/*.freezed.dart
9+
310
linter:
411
rules:
512
cascade_invocations: false

0 commit comments

Comments
 (0)