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.addMethodInvocation((MethodInvocation node) {
final Expression? target = node.target;
if (target is SimpleIdentifier && target.name == 'Navigator') {
final String methodName = node.methodName.name;
if (methodName == 'push' ||
methodName == 'pushReplacement' ||
methodName == 'pushAndRemoveUntil') {
reporter.atNode(node.methodName, code);
}
}
});
}