The strictest linting rules for Dart code. Perfect for perfectionists, whether solo developers or entire teams striving for flawless code.
Lintorium requires Dart 3.4.0
or later.
Fully compatible with both Dart and Flutter projects.
-
In a terminal, located at the root of your package, run this command:
dart pub add dev:lintorium
-
Create an
analysis_options.yaml
file in the root directory of your project (next to pubspec.yaml) and add the following line:include: package:lintorium/analysis_options.yaml
Now the Dart analyzer will use the rules from Lintorium.
To upgrade to the latest version of the lint set, run:
dart pub add dev:lintorium
Issues detected by the analyzer will automatically appear in the interface of Dart-compatible IDEs.
The analyzer can also be run manually from the command line.
For Dart projects, use:
dart analyze
For Flutter projects, use:
flutter analyze
You can exclude specific files or directories from analysis by using the analyzer.exclude
section in your analysis_options.yaml
file.
This is useful for automatically generated files.
Example:
# analysis_options.yaml
analyzer:
exclude:
- "**/generated/**" # Excludes all files in the "generated" directory and its subdirectories
- "**/*.g.dart" # Excludes all files ending with ".g.dart"
For more details, refer to the official Dart documentation.
Sometimes, you may need to suppress specific linting rules for certain sections of your code. Dart allows you to do this by using comments in your code.
You can suppress a rule by adding a comment above the line of code you want to exclude:
// ignore: avoid_print
print('This is ignored by the linter');
To suppress multiple rules, list them separated by commas:
// ignore: avoid_print, avoid_dynamic_calls
print(dynamicVariable.callMethod());
To suppress rules for a block of code, you can use ignore comments around the block:
// ignore: avoid_print
void someFunction() {
print('This will not trigger a lint warning');
}
// Linting resumes here
To suppress rules for an entire file, add a comment at the top of the file:
// ignore_for_file: avoid_print
import 'dart:io';
...
For more details, refer to the official Dart documentation.
You can also customize the rules manually using the linter.rules
or analyzer.errors
sections in your analysis_options.yaml
file.
This allows you to enable or disable specific rules to suit your needs.
For a complete list of all available linting rules, you can refer to the official Dart documentation.
The linter.rules
section lets you enable or disable specific lint rules.
Example:
# analysis_options.yaml
linter:
rules:
avoid_print: true # Enables the avoid_print rule
prefer_single_quotes: false # Disables the prefer_single_quotes rule
The analyzer.errors
section allows you to define the severity level for diagnostic messages reported by the analyzer.
Example:
# analysis_options.yaml
analyzer:
errors:
package_api_docs: info # Shows an informational message
prefer_is_empty: warning # Shows a warning
avoid_print: error # Raises an error
prefer_single_quotes: ignore # Completely disables the rule
For details on customizing static analysis, check out the official Dart documentation.
Use these badges to highlight your project's adherence to Lintorium's high standards of linting and code style.
Example:
Markdown:
[](https://pub.dev/packages/lintorium)
[](https://pub.dev/packages/lintorium)
[](https://pub.dev/packages/lintorium)
To include a badge in your project:
- Copy the Markdown code snippet for the badge you want.
- Paste it into your project’s README.md or documentation file where you want the badge to appear.
For a full list of changes and updates, see the CHANGELOG.md.
If you encounter any issues or have suggestions for improvements, please create an issue on GitHub.
When reporting a bug or requesting a fix, please provide as much detail as possible to help understand the problem or idea.
Including the following information is highly appreciated:
- Steps to reproduce the issue
- Expected behavior
- Any error messages or logs
- Your environment (operating system, Dart version, etc.)
Your feedback is valuable and will help improve the package!
Contributions are welcome!
Please fork this repository and submit pull requests.
This project is licensed under the BSD-3-Clause License.