-
-
Notifications
You must be signed in to change notification settings - Fork 974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(riverpod_lint) Add new lint avoid_passing_build_context_to_providers #2928
(riverpod_lint) Add new lint avoid_passing_build_context_to_providers #2928
Conversation
.../riverpod_lint_flutter_test/test/goldens/lints/avoid_passing_build_context_to_providers.dart
Outdated
Show resolved
Hide resolved
TypeChecker buildContextType = | ||
const TypeChecker.fromName('BuildContext', packageName: 'flutter'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TypeChecker buildContextType = | |
const TypeChecker.fromName('BuildContext', packageName: 'flutter'); | |
const buildContextType = TypeChecker.fromName( | |
'BuildContext', | |
packageName: 'flutter', | |
); |
final buildContextParameters = parameters.parameters.where( | ||
(e) => | ||
e.declaredElement?.type != null && | ||
buildContextType.isExactlyType(e.declaredElement!.type), | ||
); | ||
|
||
for (final contextParameter in buildContextParameters) { | ||
reporter.reportErrorForNode(_code, contextParameter); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be refactored with the functional-based bit to avoid the duplicate?
A function which takes the list of parameter and emit warnings should be fine.
Outside of a small DRY thingy, LGTM! Ah yes, one more thing: I'm not sure about the name picked. It's a bit lengthy. |
Definitely. I am not good at naming. |
Perfect. I'll sync with master, check the CI and merge/deploy this |
… pr/charlescyt/2928
Implement a lint for #2187