-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
syncpack format
orders dependencies differently than npm does
#206
Labels
Comments
jenseng
changed the title
Apr 18, 2024
syncpack format
orders dependencies differently than npm
doessyncpack format
orders dependencies differently than npm does
Great spot @jenseng, thanks a lot. Syncpack is just doing a completely basic syncpack/src/bin-format/format.ts Lines 120 to 126 in db2b31c
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
syncpack format
orders dependencies differently than npm does, so package.json can easily become "unformatted" every time you install a new package (npm likes to re-sort things). This is most noticeable if a dependency begins with a number (e.g.5to6-codemod
); syncpack will sort it before any scoped deps (presumably because of this), whereas npm puts scoped deps first (since it useslocaleCompare
when sorting).Basic repro:
npm i 5to6-codemod @babel/register
@babel/register
appears before5to6-codemod
in package.jsonnpx syncpack format
@babel/register
now appears after5to6-codemod
npm i @babel/types
@babel/*
again appears before5to6-codemod
npx syncpack lint
fails lintingWhile you can mostly work around this by running
syncpack format
in a pre-commit hook, this isn't always feasible (e.g. if you have automated processes that are updating packages ... in that case those also need to explicitly runsyncpack format
)Suggested Solution
syncpack
should sort dependencies the same way that npm does (using alocaleCompare
-based sort, rather than a vanilla sort)The text was updated successfully, but these errors were encountered: