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,
) {
// Skip test files
final String path = context.filePath;
if (path.contains('_test.dart') || path.contains('/test/')) return;
context.addMethodInvocation((MethodInvocation node) {
if (node.methodName.name != 'print') return;
// Check if it's the top-level print function
if (node.target == null) {
reporter.atNode(node);
}
});
}