bloc icon indicating copy to clipboard operation
bloc copied to clipboard

feat(lint): add avoid_async_emit rule with tests and documentation

Open Katekko opened this issue 5 months ago • 6 comments

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

Katekko avatar Aug 01 '25 00:08 Katekko

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.

Katekko avatar Aug 01 '25 00:08 Katekko

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!

Katekko avatar Aug 01 '25 01:08 Katekko

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.

codecov[bot] avatar Aug 01 '25 04:08 codecov[bot]

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.

euclidesgc avatar Aug 01 '25 13:08 euclidesgc

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! 💙

felangel avatar Aug 04 '25 02:08 felangel

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.

felangel avatar Sep 22 '25 02:09 felangel