
Nx Import
Fix ESLint and lint-target issues after nx import so monorepo projects cache correctly and do not double-run lint.
Overview
Nx Import is an agent skill for the Build phase that fixes ESLint plugin inference and duplicate lint targets after importing packages into an Nx workspace.
Install
npx skills add https://github.com/nrwl/nx-ai-agents-config --skill nx-importWhat is this skill?
- @nx/eslint/plugin infers eslint:lint from flat and legacy eslint config filenames
- Duplicate lint vs eslint:lint when package.json still has a lint npm script—remove lint script, keep lint:fix if needed
- Auto-install @nx/eslint on import when ESLint configs are detected; updates namedInputs.production exclusions
- Guidance for legacy .eslintrc.* linting generated files after import
- Cross-reference to generic nx import SKILL.md for root deps, pnpm globs, and project references
- Two lint-related targets when source package.json retains a lint script
Adoption & trust: 1.4k installs on skills.sh; 24 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
After nx import, every project runs two lint paths and legacy ESLint configs may lint generated output without Nx caching benefits.
Who is it for?
Indie developers importing npm packages into Nx who hit duplicate lint targets or need @nx/eslint/plugin explained post-import.
Skip if: Greenfield Nx apps with no import, or teams not using ESLint in the monorepo.
When should I use this skill?
You imported a project with nx import and need ESLint plugin behavior, duplicate lint target removal, or legacy config fixes.
What do I get? / Deliverables
Projects rely on a single cached eslint:lint target, production inputs exclude ESLint configs correctly, and legacy eslintrc scope issues are addressed for CI.
- Updated package.json scripts without duplicate lint
- Configured @nx/eslint/plugin with correct targetName and inputs
Recommended Skills
Journey fit
Build is where monorepos land new packages; nx import is applied while integrating external repos into the Nx workspace. Integrations fits because the skill is the ESLint-specific companion to generic nx import—wiring @nx/eslint/plugin after packages enter the graph.
How it compares
ESLint-focused import appendix—use alongside generic nx import, not instead of Nx docs for graph and dependency moves.
Common Questions / FAQ
Who is nx-import for?
Builders using Nx who import external projects and need agents to clean up ESLint targets and plugin registration.
When should I use nx-import?
Right after nx import when you see both lint and eslint:lint targets or when @nx/eslint/plugin offers auto-install during import.
Is nx-import safe to install?
It guides file and package.json edits—check Security Audits on this page and review diffs before pushing to shared CI.
SKILL.md
READMESKILL.md - Nx Import
## ESLint ESLint-specific guidance for `nx import`. For generic import issues (root deps, pnpm globs, project references), see `SKILL.md`. --- ### How `@nx/eslint/plugin` Works `@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}`). **Plugin options (set during `nx add @nx/eslint`):** ```json { "plugin": "@nx/eslint/plugin", "options": { "targetName": "eslint:lint" } } ``` **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. --- ### Duplicate `lint` and `eslint:lint` Targets After import, projects will have **two** lint-related targets if the source `package.json` has a `"lint"` npm script: - `eslint:lint` — inferred by `@nx/eslint/plugin`; has proper caching and input/output tracking - `lint` — created by Nx from the npm script via `nx:run-script`; no caching intelligence, just wraps `npm run lint` **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. --- ### Legacy `.eslintrc.*` Configs Linting Generated Files 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: - Generated `dist/**/*.d.ts` files (not in tsconfig `include`) - The `.eslintrc.js` config file itself (not in tsconfig `include`) This causes `Parsing error: ESLint was configured to run on X using parserOptions.project, however that TSConfig does not include this file`. **Fix**: Add `ignorePatterns` to the `.eslintrc.*` config: ```json // .eslintrc.json { "ignorePatterns": ["dist/**"] } ``` ```js // .eslintrc.js — also ignore the config file itself since module.exports isn't in tsconfig module.exports = { ignorePatterns: ['dist/**', '.eslintrc.js'], // ... }; ``` --- ### Flat Config `.cjs` Files Self-Linting 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`. **Fix**: Add the config filename to the top-level `ignores` array: ```js module.exports = tseslint.config( { ignores: ['dist/**', 'node_modules/**', 'eslint.config.cjs'], } // ... ); ``` The same applies to `eslint.config.js` in a CJS project (no `"type": "module"`) if it uses `require()`. --- ### `typescript-eslint` Version Conflict With ESLint 9 `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. **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. **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. ```json // packages/my-package/package.json { "devDependencies": { "typescript-eslint": "^8.0.0" } } ``` **Note**: npm's root-level `"overrides"` field does not force versions for workspace packages' direct dependencies — update each package.json individually. --- ### Mixed ESLint v8 and v9 in One Workspace 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