Skip to content

fix(workspaces): packages/** and prefix globs are not matched by workspace expansion #1119

Description

@sonukapoor

Note: this is an in-house item already being handled by the maintainer - not open for contribution. Filed for tracking only.

Surfaced while reviewing #1114. That PR resolves PD001/PD002 declarations against the nearest enclosing workspace member, which fixes the false positives @alamb-hex reported in #966. The fix only reaches workspaces that the existing pattern expansion can enumerate, and two common glob shapes are not among them.

What is not matched

expandWorkspacePattern (src/utils/package-json.ts:107) special-cases a whole-segment * only. Measured against the compiled parser:

workspaces pattern members found
["packages/*"] ["packages/a","packages/b"]
["packages/*/"] ["packages/a"]
["packages/**"] none
["packages/pkg-*"] none
["apps/*","!apps/legacy"] ["apps/legacy","apps/web"] (negation ignored)

packages/** and prefix globs like pkg-* are both common in real pnpm and Yarn monorepos. Those projects still get the full set of PD002 false positives the fix was meant to remove.

Notes

Negation being ignored fails in the safe direction: an excluded workspace is still read, so its declarations still count and no false positive is produced. Worth handling for correctness but not urgent.

This is shared code. resolveWorkspacePackageJsonPaths and readWorkspacePatterns feed workspace resolution generally, not just the PD rules, so the same gap affects anything else relying on member enumeration.

Pre-existing and not introduced by #1114. Filed separately so it does not sit on that PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingin-houseMaintainer-handled internal work - not open for contribution

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions