fix: resolve workspace root correctly in parsePackageConfig#378
fix: resolve workspace root correctly in parsePackageConfig#378julienzarka wants to merge 1 commit intoinvertase:mainfrom
Conversation
Fix plugin discovery failure in Dart workspace setups with path dependencies. The issue was that parsePackageConfig() did not properly resolve workspace root paths when workspace_ref.json contained relative paths like '../../..'. Additionally, it lacked validation for workspace_ref.json existence and the resolved workspace root's package_config.json. Changes: - Add existence check for workspace_ref.json before reading - Use absolute() to properly resolve relative paths in workspaceRoot - Add validation that resolved workspace root has package_config.json - Improve error messages with context for better debugging Fixes workspace plugin discovery in monorepo setups (e.g., Melos) where plugins are path dependencies and only exist in workspace root's package_config.json. Tests: - Add unit tests for workspace resolution scenarios - All existing tests pass (34/34) - All new tests pass (4/4)
|
Someone is attempting to deploy a commit to the Invertase Team on Vercel. A member of the Team first needs to authorize it. |
|
To view this pull requests documentation preview, visit the following URL: docs.page/invertase/dart_custom_lint~378 Documentation is deployed and generated using docs.page. |
|
Julien Zarka seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Code Quality ReviewChangesFixes Quality AssessmentPositives:
Minor observations:
VerdictAPPROVE -- This is a clean, well-tested bug fix that addresses a real issue with workspace resolution in Dart monorepo setups. The error handling improvements are a welcome addition. The only note is to ensure the CLA is signed (the CLA bot flagged it as pending). |
Fork Maintainer Review (dart_custom_lint)Reviewing on behalf of SummaryFixes plugin discovery failure in Dart workspace setups with path dependencies. The issue was that
Upstream StatusOpen on upstream (invertase/dart_custom_lint), not yet merged. This is a community contribution by @julienzarka. AssessmentHigh-quality PR and directly relevant to our fork. This is a real bug fix for monorepo/workspace setups -- exactly the kind of environment we use. The code change in
The only minor observation: the test file creates temp directories and cleans up properly with RecommendationSYNC_FROM_UPSTREAM (once merged upstream) -- This is a valuable bug fix we want in our fork. If upstream is slow to merge, consider cherry-picking directly. The change is isolated to |
Compatibility Review (Monorepo Impact)Reviewer context: We maintain the open-runtime/dart_custom_lint fork, consumed as a workspace member in our Dart monorepo ( Monorepo ImpactCRITICAL FIX FOR US. This PR directly addresses a bug we are affected by. Our monorepo uses Dart native pub workspaces, which means:
The three improvements are all valuable for us:
Dependency ConcernsNone. This PR modifies only RecommendationMERGE -- This is a high-priority fix for any monorepo using Dart native workspaces with Note: The CLA check is currently pending for this contributor. That needs to be resolved before merge. |
Fix: Resolve workspace root correctly in parsePackageConfig
Summary
Fixes plugin discovery failure in Dart workspace setups with path dependencies. The issue was that
parsePackageConfig()did not properly resolve workspace root paths whenworkspace_ref.jsoncontained relative paths like"../../..". Additionally, it lacked validation forworkspace_ref.jsonexistence and the resolved workspace root'spackage_config.json.Problem
When using Dart workspace resolution (common in Melos monorepos),
custom_lintfails to discover plugins that are path dependencies, even when:dev_dependencieswith a path referencepackage_config.jsonworkspace_ref.jsonexists and correctly points to the workspace rootThe plugin discovery fails silently without any error messages.
Solution
workspace_ref.jsonbefore readingabsolute()to properly resolve relative paths inworkspaceRootpackage_config.jsonChanges
Modified:
packages/custom_lint_core/lib/src/package_utils.dartabsolute()for relative pathsAdded:
packages/custom_lint_core/test/package_utils_test.dartTesting
flutter analyzepasses with no warnings/errorsImpact
This fix enables
custom_lintto work correctly in monorepo setups that use Dart workspace resolution, allowing plugins to be discovered from the workspace root'spackage_config.jsonwhen they're path dependencies.Related
Fixes the issue described in: https://github.com/julienzarka/dart_custom_lint/issues (if applicable)
Code Review Notes
FileSystemExceptionlike existing error classes)