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

Wrong sort order: Expected object keys to be in ascending order. '3dmol' should be before '@atomistics/xyz' jsonc/sort-key #66

Open
5 tasks done
dflock opened this issue Jun 7, 2023 · 2 comments

Comments

@dflock
Copy link
Contributor

dflock commented Jun 7, 2023

Describe the bug

After running taze, I get this eslint error:

error  Expected object keys to be in ascending order. '3dmol' should be before '@atomistics/xyz'  jsonc/sort-key

If I start with these dependencies:

"dependencies": {
    "3dmol": "^2.0.3",
    "@atomistics/xyz": "^1.0.0",
    "@vueuse/core": "^10.1.2",
    "date-fns": "^2.30.0",
}

after I run taze, they end up like this:

"dependencies": {
    "@atomistics/xyz": "^1.0.0",
    "@vueuse/core": "^10.1.2",
    "3dmol": "^2.0.3",
    "date-fns": "^2.30.0",
}

which causes the jsonc/sort-key linter error.

Looks like taze is sorting numbers after symbols, whereas jsonc/sort-key is expecting symbols first.

If you look at the reproduction repo: https://github.com/dflock/vitesse-jsonc-sort-keys-repro - this is a fork of vitesse, where I've run the following command (which you can see in the git log):

  • pnpm i
  • pnpm upgrade pnpm taze
  • pnpm run lint

eslint succeeds. Then I ran this to install a module with a name starting with a number:

  • pnpm add 3dmol
  • pnpm run lint

eslint succeeds. Then I ran this to run taze:

  • pnpm run up
  • pnpm run lint

and I get this:

pnpm run lint

> @ lint C:\Users\DuncanLock\dev\vitesse-jsonc-sort-keys-repro
> eslint .

=============

WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.

You may find that it works just fine, or you may not.

SUPPORTED TYPESCRIPT VERSIONS: >=3.3.1 <5.1.0

YOUR TYPESCRIPT VERSION: 5.1.3

Please only submit bug reports when using the officially supported version.

=============

C:\Users\DuncanLock\dev\vitesse-jsonc-sort-keys-repro\package.json
  24:5  error  Expected object keys to be in ascending order. '3dmol' should be before '@vueuse/head'  jsonc/sort-keys

✖ 1 problem (1 error, 0 warnings)
  1 error and 0 warnings potentially fixable with the `--fix` option.

 ELIFECYCLE  Command failed with exit code 1.

Reproduction

https://github.com/dflock/vitesse-jsonc-sort-keys-repro

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (16) x64 Intel(R) Core(TM) i7-10700T CPU @ 2.00GHz
    Memory: 14.34 GB / 31.71 GB
  Binaries:
    Node: 18.16.0 - ~\scoop\apps\nodejs-lts\current\node.EXE
    npm: 9.5.1 - ~\scoop\apps\nodejs-lts\current\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (114.0.1823.37)
    Internet Explorer: 11.0.19041.1566

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
@NamesMT
Copy link

NamesMT commented Sep 18, 2023

whereas jsonc/sort-key is expecting symbols first.

I think you mean jsonc/sort-key is expecting numbers first.

BTW related: #58

@a1mersnow
Copy link
Contributor

While running taze -w won't produce new dependencies, how about obeying the old order when writing into the package.json?
If it's ok, I would be pleasant to compose a PR.
@antfu

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

3 participants