docs: Document and group our linter rules

This commit is contained in:
Nicolas Werner 2023-11-17 14:24:59 +01:00
parent f72d298a0b
commit c44cfaf03e
No known key found for this signature in database
GPG Key ID: B38119FF80087618
1 changed files with 29 additions and 11 deletions

View File

@ -2,24 +2,44 @@ include: package:lints/recommended.yaml
linter: linter:
rules: rules:
always_declare_return_types: true # We enable a few additional rules not in the default and recommended sets.
always_use_package_imports: true # Those in general have low impact on correct code apart from possibly requiring an additional keyword (like async,
avoid_bool_literals_in_conditional_expressions: true # await, final) or asking you to move a statement to a different line. However many of these linter rules make the
avoid_print: true # code either more uniform or avoid bug prone behaviour. For example not awaiting a future usually is a mistake.
# You can always disable a linter warning with a comment like `// ignore: unawaited_futures`. Please add reasoning,
# why you disable the rule in such cases. This helps others understand, that you explicitly want a behaviour, that
# usually would be considered a mistake.
# Performance (or potential bugs)
# Fixing these warnings makes code easier to optimize for the compiler or prevents leaks.
cancel_subscriptions: true cancel_subscriptions: true
discarded_futures: true
no_adjacent_strings_in_list: true
prefer_final_in_for_each: true prefer_final_in_for_each: true
prefer_final_locals: true prefer_final_locals: true
prefer_single_quotes: true
sort_child_properties_last: true # Warn about possible bugs
sort_pub_dependencies: true # Usually code with these warnings indicates a bug.
# Please document if your code explicitly wants such a behaviour.
always_declare_return_types: true
discarded_futures: true
no_adjacent_strings_in_list: true
test_types_in_equals: true test_types_in_equals: true
throw_in_finally: true throw_in_finally: true
unawaited_futures: true unawaited_futures: true
unnecessary_statements: true unnecessary_statements: true
unsafe_html: true unsafe_html: true
# Readability & Style
# These are opinionated choices, where Dart gives us 2 ways to express the same thing.
# This avoids mental overhead by not having to make a choice and making code more uniform to read.
always_use_package_imports: true
avoid_bool_literals_in_conditional_expressions: true
prefer_single_quotes: true
sort_child_properties_last: true
sort_pub_dependencies: true
# Be nice to our users and allow them to configure what gets logged.
avoid_print: true
non_constant_identifier_names: false # seems to wrongly diagnose static const variables non_constant_identifier_names: false # seems to wrongly diagnose static const variables
analyzer: analyzer:
@ -27,6 +47,4 @@ analyzer:
todo: ignore todo: ignore
exclude: exclude:
- example/main.dart - example/main.dart
# needed until crypto packages upgrade
- lib/src/database/database.g.dart
plugins: plugins: