Skip to content

Migrate to Nx monorepo with create-eslint-config package#50

Open
hanna-skryl wants to merge 21 commits intomainfrom
nx-monorepo-migration
Open

Migrate to Nx monorepo with create-eslint-config package#50
hanna-skryl wants to merge 21 commits intomainfrom
nx-monorepo-migration

Conversation

@hanna-skryl
Copy link
Copy Markdown
Collaborator

@hanna-skryl hanna-skryl commented Apr 7, 2026

Closes #46

Summary

  • Convert repository to Nx monorepo with two packages: @code-pushup/eslint-config (existing) and @code-pushup/create-eslint-config (new, coming soon)
  • Configure Nx to orchestrate tasks (test, lint, typecheck, build, docs) with caching
  • Replace release-it with Nx releases
  • Update CI pipeline to use nx affected for checking affected projects
  • Set up Commitlint and Commitizen for conventional commit enforcement
  • Add monorepo documentation (root README, CONTRIBUTING.md)

Note

The npx nx g @nx/workspace:convert-to-monorepo generator did not produce a usable result for this repository (mangled package name, incomplete file movement, nested scope directory). The monorepo structure was created manually instead.

@hanna-skryl hanna-skryl self-assigned this Apr 7, 2026
@hanna-skryl hanna-skryl marked this pull request as ready for review April 7, 2026 15:48
@hanna-skryl hanna-skryl requested a review from matejchalk April 7, 2026 15:48
@hanna-skryl hanna-skryl requested a review from matejchalk April 9, 2026 19:01
Comment on lines +46 to +52
{
files: ['**/package.json'],
languageOptions: { parser: jsoncParser },
rules: {
'@nx/dependency-checks': 'error',
},
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rule doesn't catch errors for the eslint-config project. You can test this by removing one of the peer dependencies (e.g., globals) from its package.json.

After some digging, I found that @nx/dependency-checks skips everything if it can't find a build target.

https://github.com/nrwl/nx/blob/44abcb2ab49e102885d7eef2231b80024364158f/packages/eslint-plugin/src/rules/dependency-checks.ts#L152-L154

This can be resolved by adding our typecheck target. However, Nx defaults to {projectRoot]/**/* when the target has no cache inputs.

https://github.com/nrwl/nx/blob/44abcb2ab49e102885d7eef2231b80024364158f/packages/js/src/utils/find-npm-dependencies.ts#L101-L103

So it checks imports in non-production code and reports them as missing (vitest, build-md, @typescript-eslint/utils, compare-versions). This may be resolved by excluding certain file patterns.

Finally, Nx thinks eslint-import-resolver-typescript isn't a valid peer dependency because it can't see it being imported. This is a false positive that we need to exclude.

This is the configuration I ended up with in packages/eslint-config/eslint.config.js:

{
  files: ['**/package.json'],
  languageOptions: { parser: jsoncParser },
  rules: {
    '@nx/dependency-checks': [
      'error',
      {
        buildTargets: ['typecheck'],
        ignoredFiles: [
          '{projectRoot}/scripts/**',
          '{projectRoot}/tests/**',
          '{projectRoot}/vitest.config.js',
          '{projectRoot}/eslint.config.js',
        ],
        ignoredDependencies: ['eslint-import-resolver-typescript'],
      },
    ],
  },
},

There might be a more elegant workaround than using the typecheck build target. If we set it to some target that already uses the production cache inputs, our non-production file patterns could be defined in one place. Maybe something like typecheck:prod? 🤔

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I applied your suggestion, keeping the explicit ignoredFiles so the intent is visible at the rule definition. I also added a short comment for extra clarity.

@hanna-skryl hanna-skryl requested a review from matejchalk April 10, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate to monorepo with new @code-pushup/create-eslint-config package

2 participants