.analysis_options 4.07 KB
Newer Older
1
# Specify analysis options.
2 3 4 5 6 7 8 9
#
# Until there are meta linter rules, each desired lint must be explicitly enabled.
# See: https://github.com/dart-lang/linter/issues/288
#
# For a list of lints, see: http://dart-lang.github.io/linter/lints/
# See the configuration guide for more
# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
#
10 11 12 13 14
# There are three similar analysis options files in the flutter repo:
#   - .analysis_options (this file)
#   - .analysis_options_repo
#   - packages/flutter/lib/analysis_options_user.yaml
#
15
# This file contains the analysis options used by Flutter editors, such as Atom.
16
# It is very similar to the .analysis_options_repo file in this same directory;
17 18
# the only difference (currently) is the public_member_api_docs option,
# which triggers too many messages to be used in editors.
19 20 21 22 23

analyzer:
  language:
    enableStrictCallChecks: true
    enableSuperMixins: true
24
    enableAssertInitializer: true
25 26
  strong-mode:
    implicit-dynamic: false
27
  errors:
28 29
    # treat missing required parameters as a warning (not a hint)
    missing_required_param: warning
30 31
    # treat missing returns as a warning (not a hint)
    missing_return: warning
32
    # allow overriding fields (if they use super, ideally...)
33
    strong_mode_invalid_field_override: ignore
34
    # allow having TODOs in the code
35
    todo: ignore
36
  exclude:
37
    - 'bin/cache/**'
38 39 40 41
    # the following two are relative to the stocks example and the flutter package respectively
    # see https://github.com/dart-lang/sdk/issues/28463
    - 'lib/i18n/stock_messages_*.dart'
    - 'lib/src/http/**'
42

43 44
linter:
  rules:
45 46 47
    # these rules are documented on and in the same order as
    # the Dart Lint rules page to make maintenance easier
    # http://dart-lang.github.io/linter/lints/
48

49
    # === error rules ===
50
    - avoid_empty_else
51
    - avoid_slow_async_io
52
    - cancel_subscriptions
53
    # - close_sinks # https://github.com/flutter/flutter/issues/5789
54
    # - comment_references # blocked on https://github.com/dart-lang/dartdoc/issues/1153
55
    - control_flow_in_finally
56
    - empty_statements
57
    - hash_and_equals
58
    # - invariant_booleans # https://github.com/flutter/flutter/issues/5790
59
    # - iterable_contains_unrelated_type
60 61
    - list_remove_unrelated_type
    # - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791
62 63 64
    - test_types_in_equals
    - throw_in_finally
    - unrelated_type_equality_checks
65
    - valid_regexps
66

67
    # === style rules ===
68 69 70 71 72
    - always_declare_return_types
    - always_specify_types
    - annotate_overrides
    - avoid_as
    - avoid_init_to_null
73 74
    - avoid_return_types_on_setters
    - await_only_futures
75
    - camel_case_types
76
    # - constant_identifier_names # https://github.com/dart-lang/linter/issues/204
77
    - directives_ordering
78
    - empty_catches
79
    - empty_constructor_bodies
80
    - implementation_imports
81 82
    - library_names
    - library_prefixes
83 84
    - no_adjacent_strings_in_list
    - no_duplicate_case_values
85
    - non_constant_identifier_names
86
    # - one_member_abstracts # too many false positives
87
    # - only_throw_errors # https://github.com/flutter/flutter/issues/5792
88
    # - overridden_fields
89 90
    - package_api_docs
    - package_prefixed_library_names
91 92
    # - parameter_assignments # we do this commonly
    # - prefer_final_fields # https://github.com/dart-lang/sdk/issues/29197
93 94 95
    - prefer_collection_literals
    - prefer_const_constructors
    - prefer_contains
96
    - prefer_final_locals
97 98
    - prefer_initializing_formals
    - prefer_is_empty
99
    - prefer_is_not_empty
100
    # - public_member_api_docs # this is the only difference from .analysis_options_repo
101 102 103 104
    - slash_for_doc_comments
    - sort_constructors_first
    - sort_unnamed_constructors_first
    - super_goes_last
105
    # - type_annotate_public_apis # subset of always_specify_types
106
    - type_init_formals
107
    # - unawaited_futures # https://github.com/flutter/flutter/issues/5793
108 109
    - unnecessary_brace_in_string_interp
    - unnecessary_getters_setters
110 111
    - unnecessary_null_aware_assignments
    - unnecessary_null_in_if_null_operators
112

113
    # === pub rules ===
114
    - package_names