Commit 2f5e5b1
authored
chore(linter): declare @nx/jest as optional peer dependency (#35377)
## Current Behavior
`packages/eslint/src/generators/workspace-rules-project/workspace-rules-project.ts:37`
calls `ensurePackage<typeof import('@nx/jest')>('@nx/jest', nxVersion)`.
This runtime-optional reference (type-only import plus a string
argument) is invisible to Nx's static project-graph analysis, so the
graph has no `@nx/eslint → @nx/jest` edge today.
Combined with the custom jest resolver in
`scripts/patched-jest-resolver.js` — which maps `@nx/jest` subpaths to
workspace source — the `eslint:test` task ends up reading
`packages/jest/index.ts` and 19 files under `packages/jest/src/**` at
module-load time. Those reads are undeclared inputs and are flagged as
sandbox violations by the staging sandbox reports.
## Expected Behavior
Declaring `@nx/jest` as an **optional** `peerDependency` of `@nx/eslint`
materializes the missing edge in Nx's project graph (the graph reader in
`explicit-package-json-dependencies.ts` walks `peerDependencies`
alongside `dependencies`). The inferred test-task input `^production` is
transitive, so `packages/jest/**` production source is then covered as
declared inputs of `eslint:test` and the 20 violations disappear.
`peerDependenciesMeta.@nx/jest.optional: true` keeps `@nx/jest` off the
user's install surface — package managers don't auto-install it and
don't warn about missing optional peers. Users who invoke the
`workspace-rules-project` generator with jest scaffolding still get
`@nx/jest` via the existing `ensurePackage` runtime install path,
unchanged.1 parent 2a3b0e5 commit 2f5e5b1
3 files changed
Lines changed: 13 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | 18 | | |
22 | 19 | | |
23 | 20 | | |
24 | 21 | | |
25 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments