eslint-plugin-sorting

0.4.1 • Public • Published

Install

npm install --save-dev eslint eslint-plugin-sorting

In the plugins section of your .eslintrc, add sorting.

{
  "plugins": [
    "sorting"
  ],
  "rules": {
    "sorting/sort-object-props": [ 1, {
      "ignoreCase": true,
      "ignoreMethods": false,
      "ignoreMethodSiblings": false
    } ]
  }
}

Rule Details

By default all rules are case insensitive and methods (functions as values) are not ignored.

Warnings:

var obj = {
  c: "foo",
  a: "bar",
  b: {
    e: 1,
    d: 2,
  },
  A: 5
};

OK:

var obj = {
  A: 5,
  a: "bar",
  b: {
    d: 2,
    e: 1,
  },
  c: "foo",
};

OK if ignoreMethods: true

var Foo = {
  b: function() {},
  a: function() {}
};

OK if ignoreMethodSiblings: true

var Foo = {
  c: 1,
  b: 2,
  a: function() {}
};

Readme

Keywords

Package Sidebar

Install

npm i eslint-plugin-sorting

Weekly Downloads

165

Version

0.4.1

License

MIT

Unpacked Size

13.2 kB

Total Files

8

Last publish

Collaborators

  • jacobrask
  • laggingreflex