Skip to content

Commit

Permalink
Don't trigger provider scoped lints in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Lockie Richter committed Oct 29, 2023
1 parent e23f769 commit c3fc922
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ extension SimpleIdentifierX on SimpleIdentifier {
return libraryUri.scheme == 'package' &&
libraryUri.pathSegments.first == 'flutter';
}

bool get isPumpWidget {
if (name != 'pumpWidget') return false;

final library = staticElement?.library;
if (library == null) return false;
final libraryUri = Uri.tryParse(library.identifier);
if (libraryUri == null) return false;

return libraryUri.scheme == 'package' &&
libraryUri.pathSegments.first == 'flutter_test';
}
}

class ScopedProvidersShouldSpecifyDependencies extends RiverpodLintRule {
Expand Down Expand Up @@ -90,6 +102,7 @@ class ScopedProvidersShouldSpecifyDependencies extends RiverpodLintRule {

// If the ProviderScope isn't directly as a child of runApp, it is scoped
return enclosingExpression is! MethodInvocation ||
!enclosingExpression.methodName.isFlutterRunApp;
!enclosingExpression.methodName.isFlutterRunApp ||
!enclosingExpression.methodName.isPumpWidget;
}
}

0 comments on commit c3fc922

Please sign in to comment.