Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🛠 Tooling: sort package.json #223

Closed
3 tasks done
RebeccaStevens opened this issue Feb 6, 2023 · 5 comments · Fixed by JoshuaKGoldberg/ts-api-utils#22 or #224
Closed
3 tasks done

🛠 Tooling: sort package.json #223

RebeccaStevens opened this issue Feb 6, 2023 · 5 comments · Fixed by JoshuaKGoldberg/ts-api-utils#22 or #224
Labels
area: tooling Managing the repository's maintenance status: waiting for author Needs an action taken by the original poster

Comments

@RebeccaStevens
Copy link
Contributor

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Overview

Keep package.json sorted to make it easy to quickly find each section.

Additional Info

This can automatically be done with a prettier plugin.

@RebeccaStevens RebeccaStevens added the area: tooling Managing the repository's maintenance label Feb 6, 2023
RebeccaStevens referenced this issue in RebeccaStevens/ts-api-utils Feb 6, 2023
@JoshuaKGoldberg JoshuaKGoldberg transferred this issue from JoshuaKGoldberg/ts-api-utils Feb 6, 2023
@JoshuaKGoldberg
Copy link
Owner

JoshuaKGoldberg commented Feb 6, 2023

Agreed, package.json should be sorted - and it already is with ESLint! See JoshuaKGoldberg/ts-api-utils#20 https://github.com/JoshuaKGoldberg/ts-api-tools/actions/runs/4107681077/jobs/7089665450:

/home/runner/work/ts-api-tools/ts-api-tools/package.json
Error:   44:4  error  Expected object keys to be in ascending order. 'import' should be before 'types'  jsonc/sort-keys
Error:   54:2  error  Expected object keys to be in ascending order. 'name' should be before 'types'    jsonc/sort-keys

The difference is, I have them sorted in alphabetical order. Which is something I believe in - it's hard to memorize arbitrary sorts for different systems. Alphabetical is a nice predictable standard. What do you think?

Btw, I transferred this issue over from ts-api-tools to this template-typescript-node-package since it impacts all of them.

@JoshuaKGoldberg JoshuaKGoldberg added the status: waiting for author Needs an action taken by the original poster label Feb 6, 2023
@RebeccaStevens
Copy link
Contributor Author

Personally, I think the why sort-package-json sorts things is the better approach than just alphabetical. The ordering it does has kind of become a standard agreed upon by a large number of developers.

It's also doesn't enforce sorting on elements where order matter (such as with the exports field).

@JoshuaKGoldberg

This comment was marked as off-topic.

@allcontributors

This comment was marked as off-topic.

@JoshuaKGoldberg
Copy link
Owner

JoshuaKGoldberg commented Feb 7, 2023

All right, I filed ota-meshi/eslint-plugin-jsonc#211. The alphabetical ordering feels wrong to me... but so did a lot of good tooling things, such as Prettier. So maybe I'm just being a luddite. Let's try it out! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: tooling Managing the repository's maintenance status: waiting for author Needs an action taken by the original poster
Projects
None yet
2 participants