create-stencil-components 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/templates/base/.agents/skills/link-workspace-packages/SKILL.md +127 -0
  2. package/dist/templates/base/.agents/skills/monitor-ci/SKILL.md +301 -0
  3. package/dist/templates/base/.agents/skills/monitor-ci/references/fix-flows.md +108 -0
  4. package/dist/templates/base/.agents/skills/monitor-ci/scripts/ci-poll-decide.mjs +356 -0
  5. package/dist/templates/base/.agents/skills/monitor-ci/scripts/ci-state-update.mjs +152 -0
  6. package/dist/templates/base/.agents/skills/nx-generate/SKILL.md +166 -0
  7. package/dist/templates/base/.agents/skills/nx-import/SKILL.md +238 -0
  8. package/dist/templates/base/.agents/skills/nx-import/references/ESLINT.md +109 -0
  9. package/dist/templates/base/.agents/skills/nx-import/references/GRADLE.md +12 -0
  10. package/dist/templates/base/.agents/skills/nx-import/references/JEST.md +223 -0
  11. package/dist/templates/base/.agents/skills/nx-import/references/NEXT.md +214 -0
  12. package/dist/templates/base/.agents/skills/nx-import/references/TURBOREPO.md +62 -0
  13. package/dist/templates/base/.agents/skills/nx-import/references/VITE.md +393 -0
  14. package/dist/templates/base/.agents/skills/nx-plugins/SKILL.md +9 -0
  15. package/dist/templates/base/.agents/skills/nx-run-tasks/SKILL.md +58 -0
  16. package/dist/templates/base/.agents/skills/nx-workspace/SKILL.md +284 -0
  17. package/dist/templates/base/.agents/skills/nx-workspace/references/AFFECTED.md +27 -0
  18. package/dist/templates/base/.claude/settings.json +13 -0
  19. package/dist/templates/base/.codex/agents/ci-monitor-subagent.toml +46 -0
  20. package/dist/templates/base/.codex/config.toml +10 -0
  21. package/dist/templates/base/.cursor/agents/ci-monitor-subagent.md +51 -0
  22. package/dist/templates/base/.gemini/commands/monitor-ci.toml +298 -0
  23. package/dist/templates/base/.gemini/settings.json +8 -11
  24. package/dist/templates/base/.github/agents/ci-monitor-subagent.agent.md +49 -0
  25. package/dist/templates/base/.github/prompts/monitor-ci.prompt.md +301 -0
  26. package/dist/templates/base/.github/skills/link-workspace-packages/SKILL.md +127 -0
  27. package/dist/templates/base/.github/skills/monitor-ci/SKILL.md +301 -0
  28. package/dist/templates/base/.github/skills/monitor-ci/references/fix-flows.md +108 -0
  29. package/dist/templates/base/.github/skills/monitor-ci/scripts/ci-poll-decide.mjs +356 -0
  30. package/dist/templates/base/.github/skills/monitor-ci/scripts/ci-state-update.mjs +152 -0
  31. package/dist/templates/base/.github/skills/nx-generate/SKILL.md +166 -0
  32. package/dist/templates/base/.github/skills/nx-import/SKILL.md +238 -0
  33. package/dist/templates/base/.github/skills/nx-import/references/ESLINT.md +109 -0
  34. package/dist/templates/base/.github/skills/nx-import/references/GRADLE.md +12 -0
  35. package/dist/templates/base/.github/skills/nx-import/references/JEST.md +223 -0
  36. package/dist/templates/base/.github/skills/nx-import/references/NEXT.md +214 -0
  37. package/dist/templates/base/.github/skills/nx-import/references/TURBOREPO.md +62 -0
  38. package/dist/templates/base/.github/skills/nx-import/references/VITE.md +393 -0
  39. package/dist/templates/base/.github/skills/nx-plugins/SKILL.md +9 -0
  40. package/dist/templates/base/.github/skills/nx-run-tasks/SKILL.md +58 -0
  41. package/dist/templates/base/.github/skills/nx-workspace/SKILL.md +284 -0
  42. package/dist/templates/base/.github/skills/nx-workspace/references/AFFECTED.md +27 -0
  43. package/dist/templates/base/.opencode/agents/ci-monitor-subagent.md +50 -0
  44. package/dist/templates/base/.opencode/commands/monitor-ci.md +301 -0
  45. package/dist/templates/base/.opencode/skills/link-workspace-packages/SKILL.md +127 -0
  46. package/dist/templates/base/.opencode/skills/monitor-ci/SKILL.md +301 -0
  47. package/dist/templates/base/.opencode/skills/monitor-ci/references/fix-flows.md +108 -0
  48. package/dist/templates/base/.opencode/skills/monitor-ci/scripts/ci-poll-decide.mjs +356 -0
  49. package/dist/templates/base/.opencode/skills/monitor-ci/scripts/ci-state-update.mjs +152 -0
  50. package/dist/templates/base/.opencode/skills/nx-generate/SKILL.md +166 -0
  51. package/dist/templates/base/.opencode/skills/nx-import/SKILL.md +238 -0
  52. package/dist/templates/base/.opencode/skills/nx-import/references/ESLINT.md +109 -0
  53. package/dist/templates/base/.opencode/skills/nx-import/references/GRADLE.md +12 -0
  54. package/dist/templates/base/.opencode/skills/nx-import/references/JEST.md +223 -0
  55. package/dist/templates/base/.opencode/skills/nx-import/references/NEXT.md +214 -0
  56. package/dist/templates/base/.opencode/skills/nx-import/references/TURBOREPO.md +62 -0
  57. package/dist/templates/base/.opencode/skills/nx-import/references/VITE.md +393 -0
  58. package/dist/templates/base/.opencode/skills/nx-plugins/SKILL.md +9 -0
  59. package/dist/templates/base/.opencode/skills/nx-run-tasks/SKILL.md +58 -0
  60. package/dist/templates/base/.opencode/skills/nx-workspace/SKILL.md +284 -0
  61. package/dist/templates/base/.opencode/skills/nx-workspace/references/AFFECTED.md +27 -0
  62. package/dist/templates/base/AGENTS.md +46 -36
  63. package/dist/templates/base/CLAUDE.md +15 -5
  64. package/dist/templates/base/package.json +3 -3
  65. package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-core/package.json +3 -3
  66. package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-react/package.json +2 -2
  67. package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-react/tsconfig.json +5 -1
  68. package/dist/templates/variants/angular/packages/components-{{PROJECT_NAME_KEBAB}}-core/package.json +2 -2
  69. package/dist/templates/variants/react/packages/components-{{PROJECT_NAME_KEBAB}}-core/package.json +2 -2
  70. package/dist/templates/variants/react/packages/components-{{PROJECT_NAME_KEBAB}}-react/package.json +2 -2
  71. package/dist/templates/variants/react/packages/components-{{PROJECT_NAME_KEBAB}}-react/tsconfig.json +5 -1
  72. package/dist/templates/variants/vue/packages/components-{{PROJECT_NAME_KEBAB}}-core/package.json +1 -1
  73. package/dist/templates/variants/web-components/packages/components-{{PROJECT_NAME_KEBAB}}-core/package.json +1 -1
  74. package/package.json +1 -1
@@ -0,0 +1,238 @@
1
+ ---
2
+ name: nx-import
3
+ description: Import, merge, or combine repositories into an Nx workspace using nx import. USE WHEN the user asks to adopt Nx across repos, move projects into a monorepo, or bring code/history from another repository.
4
+ ---
5
+
6
+ ## Quick Start
7
+
8
+ - `nx import` brings code from a source repository or folder into the current workspace, preserving commit history.
9
+ - After nx `22.6.0`, `nx import` responds with .ndjson outputs and follow-up questions. For earlier versions, always run with `--no-interactive` and specify all flags directly.
10
+ - Run `nx import --help` for available options.
11
+ - Make sure the destination directory is empty before importing.
12
+ EXAMPLE: target has `libs/utils` and `libs/models`; source has `libs/ui` and `libs/data-access` — you cannot import `libs/` into `libs/` directly. Import each source library individually.
13
+
14
+ Primary docs:
15
+
16
+ - https://nx.dev/docs/guides/adopting-nx/import-project
17
+ - https://nx.dev/docs/guides/adopting-nx/preserving-git-histories
18
+
19
+ Read the nx docs if you have the tools for it.
20
+
21
+ ## Import Strategy
22
+
23
+ **Subdirectory-at-a-time** (`nx import <source> apps --source=apps`):
24
+
25
+ - **Recommended for monorepo sources** — files land at top level, no redundant config
26
+ - Caveats: multiple import commands (separate merge commits each); dest must not have conflicting directories; root configs (deps, plugins, targetDefaults) not imported
27
+ - **Directory conflicts**: Import into alternate-named dir (e.g. `imported-apps/`), then rename
28
+
29
+ **Whole repo** (`nx import <source> imported --source=.`):
30
+
31
+ - **Only for non-monorepo sources** (single-project repos)
32
+ - For monorepos, creates messy nested config (`imported/nx.json`, `imported/tsconfig.base.json`, etc.)
33
+ - If you must: keep imported `tsconfig.base.json` (projects extend it), prefix workspace globs and executor paths
34
+
35
+ ### Directory Conventions
36
+
37
+ - **Always prefer the destination's existing conventions.** Source uses `libs/`but dest uses `packages/`? Import into `packages/` (`nx import <source> packages/foo --source=libs/foo`).
38
+ - If dest has no convention (empty workspace), ask the user.
39
+
40
+ ### Application vs Library Detection
41
+
42
+ Before importing, identify whether the source is an **application** or a **library**:
43
+
44
+ - **Applications**: Deployable end products. Common indicators:
45
+ - _Frontend_: `next.config.*`, `vite.config.*` with a build entry point, framework-specific app scaffolding (CRA, Angular CLI app, etc.)
46
+ - _Backend (Node.js)_: Express/Fastify/NestJS server entrypoint, no `"exports"` field in `package.json`
47
+ - _JVM_: Maven `pom.xml` with `<packaging>jar</packaging>` or `<packaging>war</packaging>` and a `main` class; Gradle `application` plugin or `mainClass` setting
48
+ - _.NET_: `.csproj`/`.fsproj` with `<OutputType>Exe</OutputType>` or `<OutputType>WinExe</OutputType>`
49
+ - _General_: Dockerfile, a runnable entrypoint, no public API surface intended for import by other projects
50
+ - **Libraries**: Reusable packages consumed by other projects. Common indicators: `"main"`/`"exports"` in `package.json`, Maven/Gradle packaging as a library jar, .NET `<OutputType>Library</OutputType>`, named exports intended for import by other packages.
51
+
52
+ **Destination directory rules**:
53
+
54
+ - Applications → `apps/<name>`. Check workspace globs (e.g. `pnpm-workspace.yaml`, `workspaces` in root `package.json`) for an existing `apps/*` entry.
55
+ - If `apps/*` is **not** present, add it before importing: update the workspace glob config and commit (or stage) the change.
56
+ - Example: `nx import <source> apps/my-app --source=packages/my-app`
57
+ - Libraries → follow the dest's existing convention (`packages/`, `libs/`, etc.).
58
+
59
+ ## Common Issues
60
+
61
+ ### pnpm Workspace Globs (Critical)
62
+
63
+ `nx import` adds the imported directory itself (e.g. `apps`) to `pnpm-workspace.yaml`, **NOT** glob patterns for packages within it. Cross-package imports will fail with `Cannot find module`.
64
+
65
+ **Fix**: Replace with proper globs from the source config (e.g. `apps/*`, `libs/shared/*`), then `pnpm install`.
66
+
67
+ ### Root Dependencies and Config Not Imported (Critical)
68
+
69
+ `nx import` does **NOT** merge from the source's root:
70
+
71
+ - `dependencies`/`devDependencies` from `package.json`
72
+ - `targetDefaults` from `nx.json` (e.g. `"@nx/esbuild:esbuild": { "dependsOn": ["^build"] }` — critical for build ordering)
73
+ - `namedInputs` from `nx.json` (e.g. `production` exclusion patterns for test files)
74
+ - Plugin configurations from `nx.json`
75
+
76
+ **Fix**: Diff source and dest `package.json` + `nx.json`. Add missing deps, merge relevant `targetDefaults` and `namedInputs`.
77
+
78
+ ### TypeScript Project References
79
+
80
+ After import, run `nx sync --yes`. If it reports nothing but typecheck still fails, `nx reset` first, then `nx sync --yes` again.
81
+
82
+ ### Explicit Executor Path Fixups
83
+
84
+ Inferred targets (via Nx plugins) resolve config relative to project root — no changes needed. Explicit executor targets (e.g. `@nx/esbuild:esbuild`) have workspace-root-relative paths (`main`, `outputPath`, `tsConfig`, `assets`, `sourceRoot`) that must be prefixed with the import destination directory.
85
+
86
+ ### Plugin Detection
87
+
88
+ - **Whole-repo import**: `nx import` detects and offers to install plugins. Accept them.
89
+ - **Subdirectory import**: Plugins NOT auto-detected. Manually add with `npx nx add @nx/PLUGIN`. Check `include`/`exclude` patterns — defaults won't match alternate directories (e.g. `apps-beta/`).
90
+ - Run `npx nx reset` after any plugin config changes.
91
+
92
+ ### Redundant Root Files (Whole-Repo Only)
93
+
94
+ Whole-repo import brings ALL source root files into the dest subdirectory. Clean up:
95
+
96
+ - `pnpm-lock.yaml` — stale; dest has its own lockfile
97
+ - `pnpm-workspace.yaml` — source workspace config; conflicts with dest
98
+ - `node_modules/` — stale symlinks pointing to source filesystem
99
+ - `.gitignore` — redundant with dest root `.gitignore`
100
+ - `nx.json` — source Nx config; dest has its own
101
+ - `README.md` — optional; keep or remove
102
+
103
+ **Don't blindly delete** `tsconfig.base.json` — imported projects may extend it via relative paths.
104
+
105
+ ### Root ESLint Config Missing (Subdirectory Import)
106
+
107
+ Subdirectory import doesn't bring the source's root `eslint.config.mjs`, but project configs reference `../../eslint.config.mjs`.
108
+
109
+ **Fix order**:
110
+
111
+ 1. Install ESLint deps first: `pnpm add -wD eslint@^9 @nx/eslint-plugin typescript-eslint` (plus framework-specific plugins)
112
+ 2. Create root `eslint.config.mjs` (copy from source or create with `@nx/eslint-plugin` base rules)
113
+ 3. Then `npx nx add @nx/eslint` to register the plugin in `nx.json`
114
+
115
+ Install `typescript-eslint` explicitly — pnpm's strict hoisting won't auto-resolve this transitive dep of `@nx/eslint-plugin`.
116
+
117
+ ### ESLint Version Pinning (Critical)
118
+
119
+ **Pin ESLint to v9** (`eslint@^9.0.0`). ESLint 10 breaks `@nx/eslint` and many plugins with cryptic errors like `Cannot read properties of undefined (reading 'version')`.
120
+
121
+ `@nx/eslint` may peer-depend on ESLint 8, causing the wrong version to resolve. If lint fails with `Cannot read properties of undefined (reading 'allow')`, add `pnpm.overrides`:
122
+
123
+ ```json
124
+ { "pnpm": { "overrides": { "eslint": "^9.0.0" } } }
125
+ ```
126
+
127
+ ### Dependency Version Conflicts
128
+
129
+ After import, compare key deps (`typescript`, `eslint`, framework-specific). If dest uses newer versions, upgrade imported packages to match (usually safe). If source is newer, may need to upgrade dest first. Use `pnpm.overrides` to enforce single-version policy if desired.
130
+
131
+ ### Module Boundaries
132
+
133
+ Imported projects may lack `tags`. Add tags or update `@nx/enforce-module-boundaries` rules.
134
+
135
+ ### Project Name Collisions (Multi-Import)
136
+
137
+ Same `name` in `package.json` across source and dest causes `MultipleProjectsWithSameNameError`. **Fix**: Rename conflicting names (e.g. `@org/api` → `@org/teama-api`), update all dep references and import statements, `pnpm install`. The root `package.json` of each imported repo also becomes a project — rename those too.
138
+
139
+ ### Workspace Dep Import Ordering
140
+
141
+ `pnpm install` fails during `nx import` if a `"workspace:*"` dependency hasn't been imported yet. File operations still succeed. **Fix**: Import all projects first, then `pnpm install --no-frozen-lockfile`.
142
+
143
+ ### `.gitkeep` Blocking Subdirectory Import
144
+
145
+ The TS preset creates `packages/.gitkeep`. Remove it and commit before importing.
146
+
147
+ ### Frontend tsconfig Base Settings (Critical)
148
+
149
+ The TS preset defaults (`module: "nodenext"`, `moduleResolution: "nodenext"`, `lib: ["es2022"]`) are incompatible with frontend frameworks (React, Next.js, Vue, Vite). After importing frontend projects, verify the dest root `tsconfig.base.json`:
150
+
151
+ - **`moduleResolution`**: Must be `"bundler"` (not `"nodenext"`)
152
+ - **`module`**: Must be `"esnext"` (not `"nodenext"`)
153
+ - **`lib`**: Must include `"dom"` and `"dom.iterable"` (frontend projects need these)
154
+ - **`jsx`**: `"react-jsx"` for React-only workspaces, per-project for mixed frameworks
155
+
156
+ For **subdirectory imports**, the dest root tsconfig is authoritative — update it. For **whole-repo imports**, imported projects may extend their own nested `tsconfig.base.json`, making this less critical.
157
+
158
+ If the dest also has backend projects needing `nodenext`, use per-project overrides instead of changing the root.
159
+
160
+ **Gotcha**: TypeScript does NOT merge `lib` arrays — a project-level override **replaces** the base array entirely. Always include all needed entries (e.g. `es2022`, `dom`, `dom.iterable`) in any project-level `lib`.
161
+
162
+ ### `@nx/react` Typings for Libraries
163
+
164
+ React libraries generated with `@nx/react:library` reference `@nx/react/typings/cssmodule.d.ts` and `@nx/react/typings/image.d.ts` in their tsconfig `types`. These fail with `Cannot find type definition file` unless `@nx/react` is installed in the dest workspace.
165
+
166
+ **Fix**: `pnpm add -wD @nx/react`
167
+
168
+ ### Jest Preset Missing (Subdirectory Import)
169
+
170
+ Nx presets create `jest.preset.js` at the workspace root, and project jest configs reference it (e.g. `../../jest.preset.js`). Subdirectory import does NOT bring this file.
171
+
172
+ **Fix**:
173
+
174
+ 1. Run `npx nx add @nx/jest` — registers `@nx/jest/plugin` in `nx.json` and updates `namedInputs`
175
+ 2. Create `jest.preset.js` at workspace root (see `references/JEST.md` for content) — `nx add` only creates this when a generator runs, not on bare `nx add`
176
+ 3. Install test runner deps: `pnpm add -wD jest jest-environment-jsdom ts-jest @types/jest`
177
+ 4. Install framework-specific test deps as needed (see `references/JEST.md`)
178
+
179
+ For deeper Jest issues (tsconfig.spec.json, Babel transforms, CI atomization, Jest vs Vitest coexistence), see `references/JEST.md`.
180
+
181
+ ### Target Name Prefixing (Whole-Repo Import)
182
+
183
+ When importing a project with existing npm scripts (`build`, `dev`, `start`, `lint`), Nx plugins auto-prefix inferred target names to avoid conflicts: e.g. `next:build`, `vite:build`, `eslint:lint`.
184
+
185
+ **Fix**: Remove the Nx-rewritten npm scripts from the imported `package.json`, then either:
186
+
187
+ - Accept the prefixed names (e.g. `nx run app:next:build`)
188
+ - Rename plugin target names in `nx.json` to use unprefixed names
189
+
190
+ ## Non-Nx Source Issues
191
+
192
+ When the source is a plain pnpm/npm workspace without `nx.json`.
193
+
194
+ ### npm Script Rewriting (Critical)
195
+
196
+ Nx rewrites `package.json` scripts during init, creating broken commands (e.g. `vitest run` → `nx test run`). **Fix**: Remove all rewritten scripts — Nx plugins infer targets from config files.
197
+
198
+ ### `noEmit` → `composite` + `emitDeclarationOnly` (Critical)
199
+
200
+ Plain TS projects use `"noEmit": true`, incompatible with Nx project references.
201
+
202
+ **Symptoms**: "typecheck target is disabled because one or more project references set 'noEmit: true'" or TS6310.
203
+
204
+ **Fix** in **all** imported tsconfigs:
205
+
206
+ 1. Remove `"noEmit": true`. If inherited via extends chain, set `"noEmit": false` explicitly.
207
+ 2. Add `"composite": true`, `"emitDeclarationOnly": true`, `"declarationMap": true`
208
+ 3. Add `"outDir": "dist"` and `"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"`
209
+ 4. Add `"extends": "../../tsconfig.base.json"` if missing. Remove settings now inherited from base.
210
+
211
+ ### Stale node_modules and Lockfiles
212
+
213
+ `nx import` may bring `node_modules/` (pnpm symlinks pointing to the source filesystem) and `pnpm-lock.yaml` from the source. Both are stale.
214
+
215
+ **Fix**: `rm -rf imported/node_modules imported/pnpm-lock.yaml imported/pnpm-workspace.yaml imported/.gitignore`, then `pnpm install`.
216
+
217
+ ### ESLint Config Handling
218
+
219
+ - **Legacy `.eslintrc.json` (ESLint 8)**: Delete all `.eslintrc.*`, remove v8 deps, create flat `eslint.config.mjs`.
220
+ - **Flat config (`eslint.config.js`)**: Self-contained configs can often be left as-is.
221
+ - **No ESLint**: Create both root and project-level configs from scratch.
222
+
223
+ ### TypeScript `paths` Aliases
224
+
225
+ Nx uses `package.json` `"exports"` + pnpm workspace linking instead of tsconfig `"paths"`. If packages have proper `"exports"`, paths are redundant. Otherwise, update paths for the new directory structure.
226
+
227
+ ## Technology-specific Guidance
228
+
229
+ Identify technologies in the source repo, then read and apply the matching reference file(s).
230
+
231
+ Available references:
232
+
233
+ - `references/ESLINT.md` — ESLint projects: duplicate `lint`/`eslint:lint` targets, legacy `.eslintrc.*` linting generated files, flat config `.cjs` self-linting, `typescript-eslint` v7/v9 peer dep conflict, mixed ESLint v8+v9 in one workspace.
234
+ - `references/GRADLE.md`
235
+ - `references/JEST.md` — Jest testing: `@nx/jest/plugin` setup, jest.preset.js, testing deps by framework, tsconfig.spec.json, Jest vs Vitest coexistence, Babel transforms, CI atomization.
236
+ - `references/NEXT.md` — Next.js projects: `@nx/next/plugin` targets, `withNx`, Next.js TS config (`noEmit`, `jsx: "preserve"`), auto-installing deps via wrong PM, non-Nx `create-next-app` imports, mixed Next.js+Vite coexistence.
237
+ - `references/TURBOREPO.md`
238
+ - `references/VITE.md` — Vite projects (React, Vue, or both): `@nx/vite/plugin` typecheck target, `resolve.alias`/`__dirname` fixes, framework deps, Vue-specific setup, mixed React+Vue coexistence.
@@ -0,0 +1,109 @@
1
+ ## ESLint
2
+
3
+ ESLint-specific guidance for `nx import`. For generic import issues (root deps, pnpm globs, project references), see `SKILL.md`.
4
+
5
+ ---
6
+
7
+ ### How `@nx/eslint/plugin` Works
8
+
9
+ `@nx/eslint/plugin` scans for ESLint config files and creates a lint target for each project. It detects **both** flat config files (`eslint.config.{js,mjs,cjs,ts,mts,cts}`) and legacy config files (`.eslintrc.{json,js,cjs,mjs,yml,yaml}`).
10
+
11
+ **Plugin options (set during `nx add @nx/eslint`):**
12
+
13
+ ```json
14
+ {
15
+ "plugin": "@nx/eslint/plugin",
16
+ "options": {
17
+ "targetName": "eslint:lint"
18
+ }
19
+ }
20
+ ```
21
+
22
+ **Auto-installation**: `nx import` auto-detects ESLint config files and offers to install `@nx/eslint`. Accept the offer — it registers the plugin and updates `namedInputs.production` to exclude ESLint config files.
23
+
24
+ ---
25
+
26
+ ### Duplicate `lint` and `eslint:lint` Targets
27
+
28
+ After import, projects will have **two** lint-related targets if the source `package.json` has a `"lint"` npm script:
29
+
30
+ - `eslint:lint` — inferred by `@nx/eslint/plugin`; has proper caching and input/output tracking
31
+ - `lint` — created by Nx from the npm script via `nx:run-script`; no caching intelligence, just wraps `npm run lint`
32
+
33
+ **Fix**: Remove the `"lint"` script from each project's `package.json`. Keep `"lint:fix"` if present — there is no plugin-inferred equivalent for auto-fixing.
34
+
35
+ ---
36
+
37
+ ### Legacy `.eslintrc.*` Configs Linting Generated Files
38
+
39
+ When `@nx/eslint/plugin` runs `eslint .` on a project with a legacy `.eslintrc.*` config that uses `parserOptions.project`, it tries to lint **all** files in the project directory including:
40
+
41
+ - Generated `dist/**/*.d.ts` files (not in tsconfig `include`)
42
+ - The `.eslintrc.js` config file itself (not in tsconfig `include`)
43
+
44
+ This causes `Parsing error: ESLint was configured to run on X using parserOptions.project, however that TSConfig does not include this file`.
45
+
46
+ **Fix**: Add `ignorePatterns` to the `.eslintrc.*` config:
47
+
48
+ ```json
49
+ // .eslintrc.json
50
+ {
51
+ "ignorePatterns": ["dist/**"]
52
+ }
53
+ ```
54
+
55
+ ```js
56
+ // .eslintrc.js — also ignore the config file itself since module.exports isn't in tsconfig
57
+ module.exports = {
58
+ ignorePatterns: ['dist/**', '.eslintrc.js'],
59
+ // ...
60
+ };
61
+ ```
62
+
63
+ ---
64
+
65
+ ### Flat Config `.cjs` Files Self-Linting
66
+
67
+ When a project uses `eslint.config.cjs` (CJS flat config), `eslint .` lints the config file itself. The `require()` call on line 1 triggers `@typescript-eslint/no-require-imports`.
68
+
69
+ **Fix**: Add the config filename to the top-level `ignores` array:
70
+
71
+ ```js
72
+ module.exports = tseslint.config(
73
+ {
74
+ ignores: ['dist/**', 'node_modules/**', 'eslint.config.cjs'],
75
+ },
76
+ // ...
77
+ );
78
+ ```
79
+
80
+ The same applies to `eslint.config.js` in a CJS project (no `"type": "module"`) if it uses `require()`.
81
+
82
+ ---
83
+
84
+ ### `typescript-eslint` Version Conflict With ESLint 9
85
+
86
+ `typescript-eslint@7.x` declares `peerDependencies: { "eslint": "^8.56.0" }`, but it is commonly used alongside `"eslint": "^9.0.0"`. npm treats this as a hard peer dep conflict and refuses to install.
87
+
88
+ **Root cause**: `@nx/eslint` init adds `eslint@~8.57.0` at the workspace root (for its own peer deps). Workspace packages that request `eslint@^9.0.0` + `typescript-eslint@^7.0.0` trigger the conflict when npm resolves their deps.
89
+
90
+ **Fix**: Upgrade `typescript-eslint` from `^7.0.0` to `^8.0.0` directly in the affected workspace package's `package.json`. The `tseslint.config()` API and `tseslint.configs.recommended` are identical between v7 and v8 — no config changes needed.
91
+
92
+ ```json
93
+ // packages/my-package/package.json
94
+ {
95
+ "devDependencies": {
96
+ "typescript-eslint": "^8.0.0"
97
+ }
98
+ }
99
+ ```
100
+
101
+ **Note**: npm's root-level `"overrides"` field does not force versions for workspace packages' direct dependencies — update each package.json individually.
102
+
103
+ ---
104
+
105
+ ### Mixed ESLint v8 and v9 in One Workspace
106
+
107
+ Legacy v8 and flat-config v9 packages can coexist in the same workspace. Each package resolves its own `eslint` version. The root `eslint@~8.57.0` (added by `@nx/eslint` init) is used by legacy v8 packages; v9 packages get their own hoisted `eslint@9`.
108
+
109
+ `@nx/eslint/plugin` infers `eslint:lint` targets for **both** config formats. Legacy packages run ESLint v8 with `.eslintrc.*`; flat-config packages run ESLint v9 with `eslint.config.*`. No special nx.json configuration is needed to support both simultaneously.
@@ -0,0 +1,12 @@
1
+ ## Gradle
2
+
3
+ - If you import an entire Gradle repository into a subfolder, files like `gradlew`, `gradlew.bat`, and `gradle/wrapper` will end up inside that imported subfolder.
4
+ - The `@nx/gradle` plugin expects those files at the workspace root to infer Gradle projects/tasks automatically.
5
+ - If the target workspace has no Gradle setup yet, consider moving those files to the root (especially when using `@nx/gradle`).
6
+ - If the target workspace already has Gradle configured, avoid duplicate wrappers: remove imported duplicates from the subfolder or merge carefully.
7
+ - Because the import lands in a subfolder, Gradle project references can break; review settings and project path references, then fix any errors.
8
+ - If `@nx/gradle` is installed, run `nx show projects` to verify that Gradle projects are being inferred.
9
+
10
+ Helpful docs:
11
+
12
+ - https://nx.dev/docs/technologies/java/gradle/introduction
@@ -0,0 +1,223 @@
1
+ ## Jest
2
+
3
+ Jest-specific guidance for `nx import`. For the basic "Jest Preset Missing" fix (create `jest.preset.js`, install deps), see `SKILL.md`. This file covers deeper Jest integration issues.
4
+
5
+ ---
6
+
7
+ ### How `@nx/jest` Works
8
+
9
+ `@nx/jest/plugin` scans for `jest.config.{ts,js,cjs,mjs,cts,mts}` and creates a `test` target for each project.
10
+
11
+ **Plugin options:**
12
+
13
+ ```json
14
+ {
15
+ "plugin": "@nx/jest/plugin",
16
+ "options": {
17
+ "targetName": "test"
18
+ }
19
+ }
20
+ ```
21
+
22
+ `npx nx add @nx/jest` does two things:
23
+
24
+ 1. **Registers `@nx/jest/plugin` in `nx.json`** — without this, no `test` targets are inferred
25
+ 2. Updates `namedInputs.production` to exclude test files
26
+
27
+ **Gotcha**: `nx add @nx/jest` does NOT create `jest.preset.js` — that file is only generated when you run a generator (e.g. `@nx/jest:configuration`). For imports, you must create it manually (see "Jest Preset" section below).
28
+
29
+ **Other gotcha**: If you create `jest.preset.js` manually but skip `npx nx add @nx/jest`, the plugin won't be registered and `nx run PROJECT:test` will fail with "Cannot find target 'test'". You need both.
30
+
31
+ ---
32
+
33
+ ### Jest Preset
34
+
35
+ The preset provides shared Jest configuration (test patterns, ts-jest transform, resolver, jsdom environment).
36
+
37
+ **Root `jest.preset.js`:**
38
+
39
+ ```js
40
+ const nxPreset = require('@nx/jest/preset').default;
41
+ module.exports = { ...nxPreset };
42
+ ```
43
+
44
+ **Project `jest.config.ts`:**
45
+
46
+ ```ts
47
+ export default {
48
+ displayName: 'my-lib',
49
+ preset: '../../jest.preset.js',
50
+ // project-specific overrides
51
+ };
52
+ ```
53
+
54
+ The `preset` path is relative from the project root to the workspace root. Subdirectory imports preserve the original relative path (e.g. `../../jest.preset.js`), which resolves correctly if the import destination matches the source directory depth.
55
+
56
+ ---
57
+
58
+ ### Testing Dependencies
59
+
60
+ #### Core (always needed)
61
+
62
+ ```
63
+ pnpm add -wD jest ts-jest @types/jest @nx/jest
64
+ ```
65
+
66
+ #### Environment-specific
67
+
68
+ - **DOM testing** (React, Vue, browser libs): `jest-environment-jsdom`
69
+ - **Node testing** (APIs, CLIs): no extra deps (Jest defaults to `node` env, but Nx preset defaults to `jsdom`)
70
+
71
+ #### React testing
72
+
73
+ ```
74
+ pnpm add -wD @testing-library/react @testing-library/jest-dom
75
+ ```
76
+
77
+ #### React with Babel (non-ts-jest transform)
78
+
79
+ Some React projects use Babel instead of ts-jest for JSX transformation:
80
+
81
+ ```
82
+ pnpm add -wD babel-jest @babel/core @babel/preset-env @babel/preset-react @babel/preset-typescript
83
+ ```
84
+
85
+ **When**: Project `jest.config` has `transform` using `babel-jest` instead of `ts-jest`. Common in older Nx workspaces and CRA migrations.
86
+
87
+ #### Vue testing
88
+
89
+ ```
90
+ pnpm add -wD @vue/test-utils
91
+ ```
92
+
93
+ Vue projects typically use Vitest (not Jest) — see VITE.md.
94
+
95
+ ---
96
+
97
+ ### `tsconfig.spec.json`
98
+
99
+ Jest projects need a `tsconfig.spec.json` that includes test files:
100
+
101
+ ```json
102
+ {
103
+ "extends": "./tsconfig.json",
104
+ "compilerOptions": {
105
+ "outDir": "../../dist/out-tsc",
106
+ "module": "commonjs",
107
+ "types": ["jest", "node"]
108
+ },
109
+ "include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
110
+ }
111
+ ```
112
+
113
+ **Common issues after import:**
114
+
115
+ - Missing `"types": ["jest", "node"]` — causes `describe`/`it`/`expect` to be unrecognized
116
+ - Missing `"module": "commonjs"` — Jest doesn't support ESM by default (ts-jest transpiles to CJS)
117
+ - `include` array missing test patterns — TypeScript won't check test files
118
+
119
+ ---
120
+
121
+ ### Jest vs Vitest Coexistence
122
+
123
+ Workspaces can have both:
124
+
125
+ - **Jest**: Next.js apps, older React libs, Node libraries
126
+ - **Vitest**: Vite-based React/Vue apps and libs
127
+
128
+ Both `@nx/jest/plugin` and `@nx/vite/plugin` (which infers Vitest targets) coexist without conflicts — they detect different config files (`jest.config.*` vs `vite.config.*`).
129
+
130
+ **Target naming**: Both default to `test`. If a project somehow has both config files, rename one:
131
+
132
+ ```json
133
+ {
134
+ "plugin": "@nx/jest/plugin",
135
+ "options": { "targetName": "jest-test" }
136
+ }
137
+ ```
138
+
139
+ ---
140
+
141
+ ### `@testing-library/jest-dom` — Jest vs Vitest
142
+
143
+ Projects migrating from Jest to Vitest (or workspaces with both) need different imports:
144
+
145
+ **Jest** (in `test-setup.ts`):
146
+
147
+ ```ts
148
+ import '@testing-library/jest-dom';
149
+ ```
150
+
151
+ **Vitest** (in `test-setup.ts`):
152
+
153
+ ```ts
154
+ import '@testing-library/jest-dom/vitest';
155
+ ```
156
+
157
+ If the source used Jest but the dest workspace uses Vitest for that project type, update the import path. Also add `@testing-library/jest-dom` to tsconfig `types` array.
158
+
159
+ ---
160
+
161
+ ### Non-Nx Source: Test Script Rewriting
162
+
163
+ Nx rewrites `package.json` scripts during init. Test scripts get broken:
164
+
165
+ - `"test": "jest"` → `"test": "nx test"` (circular if no executor configured)
166
+ - `"test": "vitest run"` → `"test": "nx test run"` (broken — `run` becomes an argument)
167
+
168
+ **Fix**: Remove all rewritten test scripts. `@nx/jest/plugin` and `@nx/vite/plugin` infer test targets from config files.
169
+
170
+ ---
171
+
172
+ ### CI Atomization
173
+
174
+ `@nx/jest/plugin` supports splitting tests per-file for CI parallelism:
175
+
176
+ ```json
177
+ {
178
+ "plugin": "@nx/jest/plugin",
179
+ "options": {
180
+ "targetName": "test",
181
+ "ciTargetName": "test-ci"
182
+ }
183
+ }
184
+ ```
185
+
186
+ This creates `test-ci--src/lib/foo.spec.ts` targets for each test file, enabling Nx Cloud distribution. Not relevant during import, but useful for post-import CI setup.
187
+
188
+ ---
189
+
190
+ ### Common Post-Import Issues
191
+
192
+ 1. **"Cannot find target 'test'"**: `@nx/jest/plugin` not registered in `nx.json`. Run `npx nx add @nx/jest` or manually add the plugin entry.
193
+
194
+ 2. **"Cannot find module 'jest-preset'"**: `jest.preset.js` missing at workspace root. Create it (see SKILL.md).
195
+
196
+ 3. **"Cannot find type definition file for 'jest'"**: Missing `@types/jest` or `tsconfig.spec.json` doesn't have `"types": ["jest", "node"]`.
197
+
198
+ 4. **Tests fail with "Cannot use import statement outside a module"**: `ts-jest` not installed or not configured as transform. Check `jest.config.ts` transform section.
199
+
200
+ 5. **Snapshot path mismatches**: After import, `__snapshots__` directories may have paths baked in. Run tests once with `--updateSnapshot` to regenerate.
201
+
202
+ ---
203
+
204
+ ## Fix Order
205
+
206
+ ### Subdirectory Import (Nx Source)
207
+
208
+ 1. `npx nx add @nx/jest` — registers plugin in `nx.json` (does NOT create `jest.preset.js`)
209
+ 2. Create `jest.preset.js` manually (see "Jest Preset" section above)
210
+ 3. Install deps: `pnpm add -wD jest jest-environment-jsdom ts-jest @types/jest`
211
+ 4. Install framework test deps: `@testing-library/react @testing-library/jest-dom` (React), `@vue/test-utils` (Vue)
212
+ 5. Verify `tsconfig.spec.json` has `"types": ["jest", "node"]`
213
+ 6. `nx run-many -t test`
214
+
215
+ ### Whole-Repo Import (Non-Nx Source)
216
+
217
+ 1. Remove rewritten test scripts from `package.json`
218
+ 2. `npx nx add @nx/jest` — registers plugin (does NOT create preset)
219
+ 3. Create `jest.preset.js` manually
220
+ 4. Install deps (same as above)
221
+ 5. Verify/fix `jest.config.*` — ensure `preset` path points to root `jest.preset.js`
222
+ 6. Verify/fix `tsconfig.spec.json` — add `types`, `module`, `include` if missing
223
+ 7. `nx run-many -t test`