feat(lint): add avoid_async_emit rule with tests and documentation
Status
READY
Breaking Changes
NO
Description
- feat(bloc_lint): avoid_async_emit (closes https://github.com/felangel/bloc/issues/4490)
Type of Change
- [x] ✨ New feature (non-breaking change which adds functionality)
- [ ] 🛠️ Bug fix (non-breaking change which fixes an issue)
- [ ] ❌ Breaking change (fix or feature that would cause existing functionality to change)
- [ ] 🧹 Code refactor
- [ ] ✅ Build configuration change
- [x] 📝 Documentation
- [ ] 🗑️ Chore
Hello @felangel
I've implemented the avoid_async_emit lint rule based on the open issue regarding unguarded emit calls inside async methods. This rule helps ensure emit is properly guarded with isClosed checks to prevent potential runtime issues. Please review and let me know if any adjustments are needed!
ps. This is my first time contributing a lint rule. Please let me know if there are any improvements I can make or if there's a better approach I should follow.
You were right—I needed to include Bloc as well. I updated the condition in handleIdentifier to check for both Cubit and Bloc tokens. Thanks for pointing it out!
Codecov Report
:x: Patch coverage is 95.94595% with 3 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 99.83%. Comparing base (1ff7d61) to head (f688b0f).
:warning: Report is 2 commits behind head on master.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| ...ages/bloc_lint/lib/src/rules/avoid_async_emit.dart | 95.94% | 3 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #4585 +/- ##
===========================================
- Coverage 100.00% 99.83% -0.17%
===========================================
Files 61 62 +1
Lines 1793 1867 +74
===========================================
+ Hits 1793 1864 +71
- Misses 0 3 +3
| Flag | Coverage Δ | |
|---|---|---|
| bloc_lint | 99.50% <95.94%> (-0.50%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
You were right—I needed to include Bloc as well. I updated the condition in handleIdentifier to check for both Cubit and Bloc tokens. Thanks for pointing it out!
Great job, bro, you were amazing. This will help us get the benefits much sooner than we expected. I'm proud of you, and thanks so much for your contribution to this process. I can't wait to use it.
Just wanted to say this is still very much on my radar -- I need to get #4562 merged first and then this is next on my list to review and get merged. Thanks so much for taking the time to contribution! 💙
Sorry for the delay! This is next on my todo list and I'm hoping to get this reviewed and merged in the next few days.