lint_quido 0.3.5 lint_quido: ^0.3.5 copied to clipboard
Collection of Flutter lints that we use and follow in Miquido
lint_quido #
This is collection of Flutter lints that we use and follow in Miquido Software development company.
This is strict, large and robust collection because we strive for high quality code, good practices and we want follow the same coding style in all our mobile apps.
And we just looooove lots of lints. 💙
Getting started #
We tested current configuration with this environment:
environment:
sdk: ">=2.18.0 <3.0.0"
flutter: ^3.3.5
so it is required to update your flutter project to meet this conditions.
Installation
Reference this package in your pubspec.yaml
in dev_dependencies section.
Until we are not published in pub.dev, reference it like this
dev_dependencies:
lint_quido:
git:
url: https://github.com/miquido/lint_quido.git
ref: main
or
you can copy content of this file to your analysis_options.yaml
. In this approach remember that you need to depend on dart_code_metrics: 4.21.2
, and you will need to add that package to your pubspec.yaml
as well. Also you will need to visit this repository from time to time to check for changes!
Also if you star this repo, that would be nice.
Usage #
After you add lint_quido
package as a dev_dependency, we recommend to copy code from below to analysis_options.yaml
file which is in root of your flutter project folder.
include: package:lint_quido/miquido_lints.yaml
analyzer:
errors:
# Those are handy, but annoying lints. Remember to change `ignore` to `info` once per two weeks or before app release.
prefer_const_constructors: ignore
prefer_const_constructors_in_immutables: ignore
And that is all folks! You are good to go!
Excluding and suppressing rules
Not recommended... 😉
If for some reason you don't agree with some linters, or you heavily oppose some approaches you can exclude or suppress lints.
Excluding
To completely exclude rule from linter, modify analysis_options.yaml
:
analyzer:
errors: #linters from flutter sdk
unawaited_futures: ignore
dart_code_metrics:
rules-exclude: #linters from dart_code_metrics
- prefer-last
Suppressing
In code add ignore comments
- at line level (comment directly above the specific line of code):
// ignore: public_member_api_docs
- at file level (comment at the top of the file):
// ignore: public_member_api_docs
Commands
To analyze your code in terminal use this commands:
# Default flutter analyze, mandatory to pass!
flutter analyze
# Find unused files in your code! Nice to keep eye on this one.
dart run dart_code_metrics:metrics check-unused-files lib
# Dart metrics analyze, not mandatory to pass!
# Also it calculate total technical debt of your project.
dart run dart_code_metrics:metrics analyze lib
Here you can find documentation about dart metrics command.
Additional information #
This is set of sources from which we are getting our linters and about good practices in Dart/Flutter:
- All Dart lints
- All Dart lints, but this time linter source code
- Customizing static analysis in Dart
- Effective Dart: Usage
- Flutter lints
- Dart metrics
- Dart language type system