nx icon indicating copy to clipboard operation
nx copied to clipboard

dependency-checks --fix functionality is confusing and not documented

Open PowerSupply opened this issue 2 years ago • 1 comments

Documentation issue

  • [ ] Reporting a typo
  • [ ] Reporting a documentation bug
  • [x] Documentation improvement
  • [ ] Documentation feedback

Is there a specific documentation page you are reporting?

https://nx.dev/nx-api/eslint-plugin/documents/dependency-checks

Additional context or description

The guide Manage Nx library dependencies with the @nx/dependency-checks ESLint rule says that "The lint fixer for the checkMissingDependencies ESLint rule option adds dependencies to the peerDependencies or dependencies section of the library's package.json file, depending on which section is declared first." which seems correct based on experience.

This is not mentioned anywhere in the documentation (even the existance of --fix is not mentioned). And I don't think this is how it should work. Getting different results based on the order in the JSON is not at all clear (especially when it is not documented) and highly unconventional.

Also, although JSON has order between properties in an "JSON object" (since JSON is a string), Js objects do not have any guaranteed property order. This means that if/when you read the package.json into Js and then write it back again using JSON.stringify you can not trust that the property order will be the same. Modifying the package.json through Js is a pretty common occurance if you have many projects and want to make changes to all of them programmatically.

It would be better to have an option for adding to "dependencies" or "peerDependencies" instead.

PowerSupply avatar Oct 27 '23 09:10 PowerSupply

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

github-actions[bot] avatar May 05 '24 00:05 github-actions[bot]