The strictest linting rules for Dart code. Perfect for perfectionists, whether solo developers or entire teams striving for flawless code.
- Versioning system
- Installation
- Upgrading to the latest lints
- Usage
- Badges
- Changelog
- Issues
- Contributing
- License
Lintorium is fully compatible with both Dart and Flutter projects.
The first digit of Lintorium's version number corresponds to the minimum required Dart SDK version.
| Dart SDK version | Lintorium version |
|---|---|
| >=3.10.0 | ✅ >=310.0.0 |
| >=3.9.0 | ✅ >=309.0.0 |
| >=3.8.0 | ✅ >=308.0.0 |
| >=3.7.0 | ✅ >=307.0.0 |
| >=3.6.0 | ✅ >=306.0.0 |
| >=3.5.0 | ✅ >=305.0.0 |
| >=3.4.0 | ✅ >=304.0.0 |
| >=3.3.0 | ✅ >=303.0.0 |
| >=3.2.0 | ✅ >=302.0.0 |
| >=3.1.0 | ✅ >=301.0.0 |
| >=3.0.0 | ✅ >=300.0.0 |
| <3.0.0 | ❌ Not supported |
When adding Lintorium to your project, it's highly recommended to use the greater than or equal to (>=) operator:
# pubspec.yaml
dev_dependencies:
lintorium: >=300.0.0 # Replace with your required versionThis approach allows the dart pub get and dart pub upgrade commands to automatically select the latest Lintorium version that's compatible with your project's Dart SDK, ensuring you always get the latest rules optimized for your Dart SDK version.
Unlike many other linting packages, Lintorium actively maintains and supports rules for all Dart SDK versions starting from Dart SDK 3.0.0. This means:
- Rules are continuously updated and optimized for each supported Dart SDK version
- Improvements are applied across all supported versions
- You can confidently use Lintorium regardless of your current Dart SDK version
-
In a terminal, located at the root of your package, run this command:
dart pub add dev:lintorium
-
Create an
analysis_options.yamlfile 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:lintoriumIssues 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 analyzeFor Flutter projects, use:
flutter analyzeThese commands can also be used for running analysis on CI.
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
include: package:lintorium/analysis_options.yaml
analyzer:
exclude:
- "**/.generated/**" # Excludes all files in the ".generated" directory and its subdirectories
- "**/generated/**" # Excludes all files in the "generated" directory and its subdirectories
- "**/*.freezed.dart" # Excludes all files ending with ".freezed.dart"
- "**/*.g.dart" # Excludes all files ending with ".g.dart"
- "**/*.gen.dart" # Excludes all files ending with ".gen.dart"
- "**/*.generated.dart" # Excludes all files ending with ".generated.dart"
- "**/*.gr.dart" # Excludes all files ending with ".gr.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 hereTo 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 ruleThe 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 ruleFor 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)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.
By participating in this project, you agree to abide by our Code of Conduct.
This project is licensed under the BSD-3-Clause License.