run method

  1. @override
void run(
  1. CustomLintResolver resolver,
  2. ErrorReporter reporter,
  3. 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 inUi = resolver.path.contains('/lib/ui/');

  if (!inUi) return;

  context.registry.addImportDirective((node) {
    final element = node.element;

    final lib = element?.uri;
    if (lib is DirectiveUriWithLibrary) {
      final path = lib.source.toString();
      if (inUi && path.contains('/data/')) {
        reporter.reportErrorForNode(code, node);
      }
    }
  });
}