Skip to content

Conversation

@nwidynski
Copy link

@nwidynski nwidynski commented Apr 5, 2025

This (non-breaking) PR adds support for multiple configuration objects as well as a production flag to the dependency-checks eslint rule. This is similar to how https://knip.dev/features/production-mode works.

With this change, it is now possible to enforce presence of devDependencies for dev-only files, e.g. .spec, like so:

// ...
"@nx/dependency-checks": ["error", 
  { "ignoredFiles": ["**/*.spec.ts"] }, 
  { "production": false, "ignoredFiles": ["**/!(*.spec.ts)"] }
]

Furthermore, this PR also adds capability to match dependencies via regex pattern in the ignoredDependencies.

Current Behavior

It is impossible to enforce dev-only dependencies.

Expected Behavior

Related Issue(s)

Fixes #30614

@nwidynski nwidynski requested a review from a team as a code owner April 5, 2025 22:38
@nwidynski nwidynski requested a review from leosvelperez April 5, 2025 22:38
@vercel
Copy link

vercel bot commented Apr 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Apr 8, 2025 9:41pm

@nwidynski nwidynski marked this pull request as draft April 5, 2025 22:58
@nwidynski nwidynski marked this pull request as ready for review April 6, 2025 00:02
@nwidynski nwidynski changed the title feat: add multi config support to @nx/dependency-checks feat: add devDependencies support & regex ignored dependencies to @nx/dependency-checks Apr 8, 2025
@nwidynski
Copy link
Author

@FrozenPandaz Any updates here?

@FrozenPandaz FrozenPandaz added the priority: medium Medium Priority (not high, not low priority) label May 14, 2025
Copy link
Member

@leosvelperez leosvelperez left a comment

Choose a reason for hiding this comment

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

Thanks for contributing!

Some general feedback:

  • Look for operations that could be cached for all visitors. For example:
    • The call to findNpmDependencies could be cached using buildTarget as the key, most of the time all configs will have the same buildTarget
    • The few Regex you added could be created once instead of every time they are needed
  • Please do not remove existing comments unless you're addressing them or are outdated

Comment on lines +52 to +54
schema: {
type: 'array',
items: {
Copy link
Member

Choose a reason for hiding this comment

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

The current changes would allow multiple configurations with the same value for production and more than two configurations, which is not ideal. The tooling wouldn't prevent users from making such a mistake. We need to limit to at most two configurations, and a way to enforce that there are not two configurations with the same value for production.

Additionally, it would be great if users wouldn't have to repeat common configuration properties for both configurations.

@PowerSupply
Copy link
Contributor

Any progress on this?

@nwidynski
Copy link
Author

@PowerSupply Not for now, I will see whether I can pick this back up later this month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: medium Medium Priority (not high, not low priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@nx/dependency-checks fails on missing dev dependencies

4 participants