jsonc/sort-array-values | eslint-plugin-jsonc (original) (raw)

require array values to be sorted

📖 Rule Details

This rule checks values of array and verifies that values are sorted alphabetically or specified order.

🔧 Options

json5

{
    "jsonc/sort-array-values": ["error", 
        {
            "pathPattern": "^files$",  // Hits the files property
            "order": { "type": "asc" }
        },
        {
            "pathPattern": "^keywords$", // Hits the keywords property
            "order": [
                "eslint",
                "eslintplugin",
                "eslint-plugin",
                {
                    // Fallback order
                    "order": { "type": "asc" }
                }
            ]
        }
    ]
}

The option receives multiple objects with the following properties:

🚀 Version

This rule was introduced in eslint-plugin-jsonc v2.2.0

🔍 Implementation