Gudahtt / prettier-plugin-sort-json

A plugin for Prettier that sorts JSON files by property name.
MIT License
103 stars 12 forks source link

jsonSortOrder not working properly? #230

Open x1c0 opened 1 week ago

x1c0 commented 1 week ago

Hi there, this is my .prettierrc.js file

module.exports = {
    semi: true,
    trailingComma: 'es5',
    singleQuote: true,
    printWidth: 140,
    tabWidth: 4,
    useTabs: false,
    endOfLine: 'auto',
    plugins: ['prettier-plugin-sort-json'],
    jsonRecursiveSort: true,
    jsonSortOrder: 'caseInsensitiveLexical',
};

and when I run this on this json:

{
    "a": "a",
    "AB": "AB",
    "b": {
        "e": "ff",
        "c": "dd",
        "a": "b"
    },
    "c": "c"
}

I get:

{
    "AB": "AB",
    "a": "a",
    "b": {
        "e": "ff",
        "c": "dd",
        "a": "b"
    },
    "c": "c"
}

So I see 2 problems here:

  1. jsonSortOrder is not working since AB should not come before a because is not using caseInsensitiveLexical and is using the default lexical
  2. jsonRecursiveSort is also not working since inside of b the json is not being sorted

Thank you