eslint-plugin-sorting

2019-04-15 admin

eslint-plugin-sorting是什么

什么是eslint-plugin-sorting,Sorting rules for eslint

eslint-plugin-sorting使用教程帮助文档

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() {}
};

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-61812.html

文章标题:eslint-plugin-sorting

回到顶部