custom_lint
0.8.1, released a year ago by invertase.io
Tool for creating and running custom Dart lint rules
What it does
Provides a framework to write, test, and distribute custom lint rules for Dart projects. It includes a CLI, hot‑reload support, and built‑in testing helpers.
AI-written summary of version 0.8.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need project‑specific lint rules not covered by default lints
- You want to enforce coding standards across a team or CI
- You want to bundle lint rules with a library for consumers
Skip it when
- You only need standard lints
- You prefer a lightweight static analysis tool without plugin support
Strengths
- Easy to write and test lints
- Hot‑reload and debugging support
- Built‑in ignore handling and CI integration
Weaknesses
- Requires Dart SDK 3.0+
- Adds a dev dependency and analysis_options configuration
- Learning curve for plugin API
Setup
- Kind
- Pure Dart
- Effort
- Medium
- Code generation
- Yes (build_runner)
- Direct dependencies
- 18
Add custom_lint to dev_dependencies, create analysis_options.yaml with plugins: - custom_lint, optionally configure rules. No build_runner needed.
// analysis_options.yaml
analyzer:
plugins:
- custom_lint
# In a custom lint package
class MyLint extends DartLintRule {
MyLint() : super(code: _code);
static const _code = LintCode(name: 'my_lint', problemMessage: 'Example lint');
@override
void run(CustomLintResolver resolver, ErrorReporter reporter, CustomLintContext context) {
context.registry.addVariableDeclaration((node) {
reporter.atNode(node, _code);
});
}
}Alternatives
Packages that do the same job and could replace custom_lint.
- flame_lint
A strict and satisfying lint package for Flame, Flutter, or Dart projects.
73Compare - netglade_analysis
Lint rules for Dart and Flutter used internally at netglade
69Compare - surf_lint_rules
Lint rules for Dart and Flutter projects from Surf company.
58Compare - very_good_analysis
Lint rules for Dart and Flutter used internally at Very Good Ventures.
91Compare
Works with
Packages commonly used together with custom_lint: ones it builds on, ones built on it, and its own family.
- analyzercustom_lint depends on itPerforms static analysis of Dart code for tool integration and embedding.
- yamlcustom_lint depends on itA Dart library for parsing YAML documents into Dart data structures.
- pub_semvercustom_lint depends on itVersions and version constraints implementing pub's versioning policy.
- uuidcustom_lint depends on itGenerates and parses RFC‑4122/9562 UUIDs (v1‑v8) for Dart.
- package_configcustom_lint depends on itRead and write Dart package configuration files.
- pubspec_parsecustom_lint depends on itParse pubspec.yaml files with a type‑safe API and detailed error reporting.
- asynccustom_lint depends on itUtility classes and helpers that extend Dart's async library.
- json_annotationcustom_lint depends on itProvides annotations for json_serializable to generate JSON (de)serialization code.