style library
Custom style rules for inspectra style.
A package writes its own rules against the syntax tree of the Dart
analyzer, declares them in a top level styleRules and lists the file
in style.custom_rules:
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:inspectra/style.dart';
final styleRules = <StyleRule>[const NoPrintRule()];
final class NoPrintRule extends StyleRule {
const NoPrintRule();
@override
String get id => 'no_print';
@override
String get description => 'Use a logger instead of print.';
@override
void check(StyleFile file, StyleReporter reporter) =>
file.unit.accept(_PrintFinder(reporter));
}
StyleChecker runs rules on source text, which is how their tests
work.
Classes
- StyleChecker
- Runs style rules over Dart source.
- StyleFile
- A parsed Dart file that style rules inspect.
- StyleReporter
- Collects the violations one rule finds in one file.
- StyleRule
- A style rule: a check of one Dart file that reports violations.
- StyleViolation
- One place where a Dart file breaks a style rule.