Skip to content

feat: adds pkg sort command#7954

Closed
reggi wants to merge 1 commit into
latestfrom
reggi/pkg-sort
Closed

feat: adds pkg sort command#7954
reggi wants to merge 1 commit into
latestfrom
reggi/pkg-sort

Conversation

@reggi

@reggi reggi commented Dec 2, 2024

Copy link
Copy Markdown
Contributor

adds npm pkg sort command to sort package.json fields

@reggi reggi requested a review from a team as a code owner December 2, 2024 20:48
@ljharb

ljharb commented Dec 2, 2024

Copy link
Copy Markdown
Contributor

whoa, this is a large feature. how is it sorting things? how can the order be customized? was there an RFC or public discussion anywhere?

@reggi

reggi commented Dec 2, 2024

Copy link
Copy Markdown
Contributor Author

@ljharb

ljharb commented Dec 2, 2024

Copy link
Copy Markdown
Contributor

ok, so it doesn't seem like this has any customization capability, but many hundreds of thousands of projects likely have orderings this would break:

  • fake comment sections where precise placement is critical (eg "//": {})
  • main-adjacent fields, like module, jsnext:main, sideEffects; any package using yargs.config to configure itself; etc
  • why is engines not precisely next to devEngines by default? that makes no sense
  • never heard of licenses but why isn't it right next to license? that also makes no sense
  • isPrivate is the most important field in there imo, and should go at the top, above name/version

and i could go on for pages. iow, by shipping this, even opt-in, without customizability, npm will be opening the floodgates of custom ordering requests (i speak from experience maintaining multiple eslint plugins that handle orderings).

I strongly urge caution and slowness with a feature like this.

@reggi reggi marked this pull request as draft December 2, 2024 21:10
@wraithgar

Copy link
Copy Markdown
Contributor

@ljharb this is in draft status. Many of these questions would be answered by the docs that we have yet to add to the PR.

@ljharb

ljharb commented Dec 2, 2024

Copy link
Copy Markdown
Contributor

fair, it wasn't in draft until after my comments :-) nothing in the code suggests that it's customizable tho, which seems like a requirement to me

@reggi

reggi commented Jan 22, 2025

Copy link
Copy Markdown
Contributor Author

im gonna close this out for now

@reggi reggi closed this Jan 22, 2025
@wraithgar wraithgar deleted the reggi/pkg-sort branch March 4, 2026 18:06
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.

3 participants