New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

prettier-plugin-sort-json

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettier-plugin-sort-json - npm Package Compare versions

Comparing version 3.1.0 to 4.0.0

22

CHANGELOG.md

@@ -9,2 +9,21 @@ # Changelog

## [4.0.0]
### Changed
- **BREAKING**: Drop support for Node.js v16 ([#203](https://github.com/Gudahtt/prettier-plugin-sort-json/pull/203))
- **BREAKING**: Update case insensitive sort to use deterministic key order ([#189](https://github.com/Gudahtt/prettier-plugin-sort-json/pull/189))
- Previously the "case insensitive" sorting options would leave keys in their original order when they differed only in case. They have been updated to sort identical keys in case order instead, making these sort options deterministic.
- This change has been made because deterministic sort orders tend to be easier to work with, are more aligned with how Prettier works, and typically lead to less churn. However, if your project needs to preserve original key order, you can emulate the old behavior by defining a custom sort order that has a category for each case-insensitive character. For example, you could set this as your `prettierrc.js` file:
```JavaScript prettierrc.js
{
jsonSortOrder: JSON.stringify({
'/^[Aa]/': 'none',
'/^[Bb]/': 'none',
'/^[Cc]/': 'none',
...
'/^[Zz]/': 'none',
})
}
```
This should work for small character sets. If you require case-insensitive sorting with a larger character set, please submit a feature request. We can bring back the old sorting order as an option if there is demand for it.
## [3.1.0]

@@ -64,3 +83,4 @@ ### Added

[Unreleased]: https://github.com/Gudahtt/prettier-plugin-sort-json/compare/v3.1.0...HEAD
[Unreleased]: https://github.com/Gudahtt/prettier-plugin-sort-json/compare/v4.0.0...HEAD
[4.0.0]: https://github.com/Gudahtt/prettier-plugin-sort-json/compare/v3.1.0...v4.0.0
[3.1.0]: https://github.com/Gudahtt/prettier-plugin-sort-json/compare/v3.0.1...v3.1.0

@@ -67,0 +87,0 @@ [3.0.1]: https://github.com/Gudahtt/prettier-plugin-sort-json/compare/v3.0.0...v3.0.1

10

dist/index.js

@@ -14,3 +14,9 @@ "use strict";

function lexicalSort(a, b) {
return a > b ? 1 : -1;
if (a > b) {
return 1;
}
if (a < b) {
return -1;
}
return 0;
}

@@ -70,3 +76,3 @@ const integerPrefixRegex = /^(\d+)/u;

return (a, b) => {
return sortFunction(a.toLowerCase(), b.toLowerCase());
return sortFunction(a.toLowerCase(), b.toLowerCase()) || sortFunction(a, b);
};

@@ -73,0 +79,0 @@ }

{
"name": "prettier-plugin-sort-json",
"version": "3.1.0",
"version": "4.0.0",
"description": "Prettier plugin to sort JSON files alphanumerically by key",

@@ -28,3 +28,4 @@ "repository": {

"@babel/types": "^7.18.10",
"@lavamoat/allow-scripts": "^2.0.3",
"@lavamoat/allow-scripts": "^3.0.0",
"@lavamoat/preinstall-always-fail": "^2.0.0",
"@metamask/auto-changelog": "^3.0.0",

@@ -36,3 +37,3 @@ "@metamask/eslint-config": "^12.0.0",

"@typescript-eslint/parser": "^5.33.1",
"ava": "^5.3.1",
"ava": "^6.0.0",
"eslint": "^8.27.0",

@@ -42,3 +43,3 @@ "eslint-config-prettier": "^9.0.0",

"eslint-plugin-jsdoc": "^39.3.6",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-n": "^16.0.0",
"eslint-plugin-prettier": "^5.0.0",

@@ -48,3 +49,3 @@ "eslint-plugin-promise": "^6.1.1",

"prettier-plugin-packagejson": "^2.2.11",
"typescript": "~4.9.0"
"typescript": "~5.1.6"
},

@@ -54,5 +55,5 @@ "peerDependencies": {

},
"packageManager": "yarn@3.6.1",
"packageManager": "yarn@4.1.0",
"engines": {
"node": ">=16.0.0"
"node": ">=18.0.0"
},

@@ -59,0 +60,0 @@ "lavamoat": {

@@ -128,3 +128,3 @@ # prettier-plugin-sort-json

- Install [Node.js](https://nodejs.org) version 16
- Install the current LTS version of [Node.js](https://nodejs.org)
- If you are using [nvm](https://github.com/creationix/nvm#installation) (recommended) running `nvm use` will automatically choose the right node version for you.

@@ -131,0 +131,0 @@ - Install [Yarn v3](https://yarnpkg.com/getting-started/install)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc