Migrate to Nx monorepo with create-eslint-config package#50
Migrate to Nx monorepo with create-eslint-config package#50hanna-skryl wants to merge 21 commits intomainfrom
Conversation
| { | ||
| files: ['**/package.json'], | ||
| languageOptions: { parser: jsoncParser }, | ||
| rules: { | ||
| '@nx/dependency-checks': 'error', | ||
| }, | ||
| }, |
There was a problem hiding this comment.
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.
This can be resolved by adding our typecheck target. However, Nx defaults to {projectRoot]/**/* when the target has no cache inputs.
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? 🤔
There was a problem hiding this comment.
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.
Closes #46
Summary
@code-pushup/eslint-config(existing) and@code-pushup/create-eslint-config(new, coming soon)release-itwith Nx releasesnx affectedfor checking affected projectsREADME,CONTRIBUTING.md)Note
The
npx nx g @nx/workspace:convert-to-monorepogenerator 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.