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.addClassDeclaration((ClassDeclaration node) {
final ExtendsClause? extendsClause = node.extendsClause;
if (extendsClause == null) return;
final String superName = extendsClause.superclass.name.lexeme;
// Check if this class extends something that ends with Event
// but this class itself doesn't end with Event
if (superName.endsWith('Event')) {
final String className = node.nameToken.lexeme;
if (!className.endsWith('Event')) {
reporter.atNode(node);
}
}
});
}