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

Bug: Sorting priority of hyphens and underscores is wrong #183

Closed
Zamiell opened this issue Sep 21, 2024 · 1 comment
Closed

Bug: Sorting priority of hyphens and underscores is wrong #183

Zamiell opened this issue Sep 21, 2024 · 1 comment

Comments

@Zamiell
Copy link

Zamiell commented Sep 21, 2024

Hello, and thanks for the excellent plugin!

Today, I discovered that this plugin uses a different sorting priority of hyphens and underscores than what npm uses, which was unexpected for me.

Steps to reproduce:

mkdir test
cd test
npm init --yes
npm install --save-dev prettier prettier-plugin-packagejson @types/eslint-config-prettier @types/eslint__js
cat package.json
# Notice that "@types/eslint__js" comes before "@types/eslint-config-prettier".
npx prettier package.json --plugin prettier-plugin-packagejson --write
cat package.json
# Notice that "@types/eslint-config-prettier" comes before "@types/eslint__js".

This mismatch is particularly painful because whenever I install a new dependency with npm (e.g. npm install --save-dev foo), it automatically breaks CI, because now Prettier fails to pass the package.json file, which then requires someone to explicitly go and format the package.json file again.

Can we fix this so that this plugin and npm have parity?

@Zamiell
Copy link
Author

Zamiell commented Sep 21, 2024

Nevermind, this seems to be a duplicate of keithamus/sort-package-json#234.
Sorry for the noise.

@Zamiell Zamiell closed this as completed Sep 21, 2024
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

No branches or pull requests

1 participant