runWithReporter method
Override this method to implement your lint rule.
Use context to register callbacks for AST node types:
context.addMethodInvocation((node) {
if (condition) {
reporter.atNode(node);
}
});
Implementation
@override
void runWithReporter(
SaropaDiagnosticReporter reporter,
SaropaContext context,
) {
context.addNamedExpression((NamedExpression node) {
if (node.name.label.name != 'markers') return;
// Check if using .map() to create markers from a collection
final Expression value = node.expression;
final String valueSource = value.toSource();
// Look for patterns that suggest many markers
if (valueSource.contains('.map(') && valueSource.contains('Marker')) {
reporter.atNode(node);
}
});
}