prettier-plugin-sort-json
Prettier plugin to sort JSON files alphanumerically by key
Last updated 5 years ago by gudahtt .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install prettier-plugin-sort-json 
SYNC missed versions from official npm registry.

prettier-plugin-sort-json

A plugin for Prettier that sorts JSON files by property name.

Requirements

This module requires an LTS Node version (v10.0.0+), and prettier v2.1.0+.

Install

Using npm:

npm install --save-dev prettier-plugin-sort-json

Using yarn:

yarn add --dev prettier-plugin-sort-json

Description

This plugin adds a JSON preprocessor that will sort JSON files containing a JSON object alphanumerically by key. JSON files containing Arrays or other non-Object values are skipped.

Object entries are sorted by key using Array.sort, according to each character's Unicode code point value.

Examples

Before:

{
    "z": null,
    "a": null,
    "b": null,
    "0": null,
    "exampleNestedObject": {
        "z": null,
        "a": null
    }
}

After:

{
    "0": null,
    "a": null,
    "b": null,
    "exampleNestedObject": {
        "z": null,
        "a": null
    },
    "z": null
}

Configuration

JSON Recursive Sort

Sort JSON objects recursively, including all nested objects.

Default CLI Override API Override
false --json-recursive-sort jsonRecursiveSort: <bool>

Current Tags

  • 0.0.2                                ...           latest (5 years ago)

2 Versions

  • 0.0.2                                ...           5 years ago
  • 0.0.1                                ...           6 years ago
Maintainers (2)
Downloads
Today 0
This Week 2
This Month 2
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (12)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |