• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Specify analysis options.
2#
3# Until there are meta linter rules, each desired lint must be explicitly enabled.
4# See: https://github.com/dart-lang/linter/issues/288
5#
6# For a list of lints, see: http://dart-lang.github.io/linter/lints/
7# See the configuration guide for more
8# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
9#
10# There are other similar analysis options files in the flutter repos,
11# which should be kept in sync with this file:
12#
13#   - analysis_options.yaml
14#   - tools/licenses/analysis_options.yaml (this file)
15#   - https://github.com/flutter/flutter/blob/master/analysis_options_user.yaml
16#   - https://github.com/flutter/flutter/blob/master/packages/flutter/lib/analysis_options_user.yaml
17#   - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
18#
19# This file contains the analysis options used by Flutter tools, such as IntelliJ,
20# Android Studio, and the `flutter analyze` command.
21
22analyzer:
23  strong-mode:
24    implicit-dynamic: false
25  errors:
26    # allow having TODOs in the code
27    todo: ignore
28
29linter:
30  rules:
31    # these rules are documented on and in the same order as
32    # the Dart Lint rules page to make maintenance easier
33    # https://github.com/dart-lang/linter/blob/master/example/all.yaml
34    - always_declare_return_types
35    - always_put_control_body_on_new_line
36    - always_put_required_named_parameters_first
37    - always_require_non_null_named_parameters
38    - always_specify_types
39    - annotate_overrides
40    # - avoid_annotating_with_dynamic # conflicts with always_specify_types
41    - avoid_as
42    - avoid_bool_literals_in_conditional_expressions
43    # - avoid_catches_without_on_clauses # we do this commonly
44    # - avoid_catching_errors # we do this commonly
45    - avoid_classes_with_only_static_members
46    # - avoid_double_and_int_checks # only useful when targeting JS runtime
47    - avoid_empty_else
48    - avoid_field_initializers_in_const_classes
49    - avoid_function_literals_in_foreach_calls
50    - avoid_implementing_value_types
51    - avoid_init_to_null
52    # - avoid_js_rounded_ints # only useful when targeting JS runtime
53    - avoid_null_checks_in_equality_operators
54    - avoid_positional_boolean_parameters
55    # - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
56    - avoid_relative_lib_imports
57    - avoid_renaming_method_parameters
58    - avoid_return_types_on_setters
59    # - avoid_returning_null # there are plenty of valid reasons to return null
60    - avoid_returning_null_for_void
61    # - avoid_returning_this # there are plenty of valid reasons to return this
62    - avoid_setters_without_getters
63    - avoid_single_cascade_in_expression_statements
64    - avoid_slow_async_io
65    - avoid_types_as_parameter_names
66    # - avoid_types_on_closure_parameters # conflicts with always_specify_types
67    - avoid_unused_constructor_parameters
68    - avoid_void_async
69    - await_only_futures
70    - camel_case_types
71    - cancel_subscriptions
72    # - cascade_invocations # not yet tested
73    # - close_sinks # not reliable enough
74    # - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
75    # - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
76    - control_flow_in_finally
77    # - curly_braces_in_flow_control_structures # not yet tested
78    - directives_ordering
79    - empty_catches
80    - empty_constructor_bodies
81    - empty_statements
82    - file_names
83    - flutter_style_todos
84    - hash_and_equals
85    - implementation_imports
86    # - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811
87    - iterable_contains_unrelated_type
88    # - join_return_with_assignment # not yet tested
89    - library_names
90    - library_prefixes
91    # - lines_longer_than_80_chars # not yet tested
92    - list_remove_unrelated_type
93    # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
94    - no_adjacent_strings_in_list
95    - no_duplicate_case_values
96    - non_constant_identifier_names
97    - null_closures
98    # - omit_local_variable_types # opposite of always_specify_types
99    # - one_member_abstracts # too many false positives
100    # - only_throw_errors # https://github.com/flutter/flutter/issues/5792
101    - overridden_fields
102    - package_api_docs
103    - package_names
104    - package_prefixed_library_names
105    # - parameter_assignments # we do this commonly
106    - prefer_adjacent_string_concatenation
107    - prefer_asserts_in_initializer_lists
108    - prefer_collection_literals
109    - prefer_conditional_assignment
110    - prefer_const_constructors
111    - prefer_const_constructors_in_immutables
112    - prefer_const_declarations
113    - prefer_const_literals_to_create_immutables
114    # - prefer_constructors_over_static_methods # not yet tested
115    - prefer_contains
116    - prefer_equal_for_default_values
117    # - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
118    - prefer_final_fields
119    - prefer_final_locals
120    - prefer_foreach
121    - prefer_function_declarations_over_variables # not yet tested
122    - prefer_generic_function_type_aliases
123    - prefer_initializing_formals
124    - prefer_int_literals
125    # - prefer_interpolation_to_compose_strings # not yet tested
126    - prefer_is_empty
127    - prefer_is_not_empty
128    - prefer_iterable_whereType
129    # - prefer_mixin # https://github.com/dart-lang/language/issues/32
130    - prefer_single_quotes
131    - prefer_typing_uninitialized_variables
132    - prefer_void_to_null
133    # - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
134    - recursive_getters
135    - slash_for_doc_comments
136    - sort_constructors_first
137    - sort_pub_dependencies
138    - sort_unnamed_constructors_first
139    - test_types_in_equals
140    - throw_in_finally
141    # - type_annotate_public_apis # subset of always_specify_types
142    - type_init_formals
143    # - unawaited_futures # too many false positives
144    - unnecessary_brace_in_string_interps
145    - unnecessary_const
146    - unnecessary_getters_setters
147    # - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
148    - unnecessary_new
149    - unnecessary_null_aware_assignments
150    - unnecessary_null_in_if_null_operators
151    - unnecessary_overrides
152    - unnecessary_parenthesis
153    - unnecessary_statements
154    - unnecessary_this
155    - unrelated_type_equality_checks
156    - use_rethrow_when_possible
157    - use_setters_to_change_properties
158    # - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
159    # - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
160    - valid_regexps
161    - void_checks
162