chore(repo): prefer relative imports inside a package's own lib/ - #2929
chore(repo): prefer relative imports inside a package's own lib/#2929xsahil03x wants to merge 2 commits into
Conversation
Swap `always_use_package_imports` for `prefer_relative_imports` and migrate every self-referencing import in `lib/` with `dart fix`, matching the convention already used by stream_core_flutter and stream_feeds_flutter. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Important Review skippedToo many files! This PR contains 393 files, which is 243 over the limit of 150. To get a review, reduce the PR to 150 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. Usage-priced reviews support at most 300 files. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (393)
You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
`dart fix` skips what the analyzer excludes and no lint covers `export` directives, leaving 16 self-package directives behind in `scrollable_positioned_list/` and two theme/composer barrels. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
@copilot restart the pending github actions |
I checked the runs and confirmed these are currently queued/pending: 32984435170, 32984287247, 32984218067, 32984069649. I don’t have a restart/cancel action available via the current toolset, so please restart them from the Actions UI (or cancel + re-run) and I can re-check status right away. |
Pull request was closed
|
False Alert |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2929 +/- ##
=======================================
Coverage 74.18% 74.18%
=======================================
Files 437 437
Lines 28375 28375
=======================================
Hits 21049 21049
Misses 7326 7326 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🎯 Goal
Move the repo from
always_use_package_importstoprefer_relative_importsfor imports within a package's ownlib/, and migrate every existing directive accordingly.Two reasons:
import '../models.dart', so the generated client tripsalways_use_package_imports— 494 infos, which is a redmelos run analyzeunder--fatal-infos. Silencing that meant either excluding the whole generated tree from analysis (which also hides real errors) or patching anignore_for_fileline into every generated file on every regeneration. Adopting the generator's convention makes both unnecessary.stream_core_flutterandstream_feeds_fluttereach disablealways_use_package_importswith the comment "conflicts withprefer_relative_imports". This aligns chat with core and feeds.📝 Summary
analysis_options.yaml:always_use_package_imports→prefer_relative_imports.avoid_relative_lib_importsstays enabled — it guards against reaching into alib/from outside it, which is still an error.dart fix --apply --code=prefer_relative_importsacross all packages, then--code=directives_orderingto re-sort the sections (package:imports first, then relative, each alphabetical).dart fixcannot reach, done by hand:lib/scrollable_positioned_list/**— vendored and excluded inanalysis_options.yaml, so no lint fires there.export 'package:stream_chat_flutter/…'directives (poll_interactor_theme.dart,stream_attachment_picker_controller.dart) — no lint coversexport.CLAUDE.mdandSTYLE_GUIDE.mdupdated to document the new convention.Scope: every
lib/in the repo. After this,grep -rn "package:<own_package>/" packages/*/libreturns nothing for all five published packages, and all 607 relative directives resolve on disk.test/andexample/keep theirpackage:imports, deliberately:lib/by relative path is an error —avoid_relative_lib_importsflags it ("Can't use a relative path to import a library in 'lib'"), and Dart would treat it as a separate library from thepackage:one.packages/*/exampleare separate packages, sopackage:stream_chat_flutter/…there is a cross-package import and must stay as-is.No CHANGELOG entries: import style is internal, with no client-facing effect.
🧪 Testing
melos run analyze— clean (--fatal-infos, all packages)melos run format— SUCCESSpackages/stream_chat— 1,626 tests passpackages/stream_chat_flutter— compile-checked the vendoredscrollable_positioned_listlibrary graph, whichmelos run analyzecannot see☑️ Contributor Checklist
🤖 Generated with Claude Code