run method
void
run(
- CustomLintResolver resolver,
- ErrorReporter reporter,
- CustomLintContext context
Emits lints for a given file.
run will only be invoked with files respecting filesToAnalyze
Implementation
@override
void run(
CustomLintResolver resolver,
ErrorReporter reporter,
CustomLintContext context,
) {
final projectName = context.pubspec.name;
final absoluteImportPrefix = "package:$projectName";
context.registry.addImportDirective((node) {
final element = node.element;
if (element == null) return;
final importedLibrary = element.importedLibrary;
if (importedLibrary == null) return;
final identifier = importedLibrary.identifier;
if (identifier.startsWith(absoluteImportPrefix) &&
importedLibrary.name.isEmpty &&
importedLibrary.source.exists()) {
reporter.reportErrorForNode(code, node);
}
});
}