eslint-plugin-array-tokens-sorter

0.0.7 • Public • Published

eslint-plugin-array-tokens-sorter

Purpose

For an example you have an array of elements, and you want to sort each element in alphabetical order

Code before:

class A {}
class B {}
class C {}

const SCOPE: unknown[] = [];

// eslint: enable-alphabetical-order-array
export default [...SCOPE, A, B, C];

export default [...SCOPE, A, B, C]; // eslint: enable-alphabetical-order-array - a second sample of usage

// eslint: enable-unique-alphabetical-order-array
export default [...SCOPE, A, A, B, C];

After fixing the code

class A {}
class B {}
class C {}

const SCOPE: unknown[] = [];

// eslint: enable-alphabetical-order-array
export default [...SCOPE, A, B, C];

export default [...SCOPE, A, B, C]; // eslint: enable-alphabetical-order-array - a second sample of usage

// eslint: enable-unique-alphabetical-order-array
export default [...SCOPE, A, B, C];

Installation

yarn add -D eslint-plugin-array-tokens-sorter

Setup

Add array-tokens-sorter to your list of plugins in your ESLint config.

JSON ESLint config example:

{
  "plugins": ["array-tokens-sorter"],
  "rules": {
    "array-tokens-sorter/array": ["error", { "spreadVariablesFirst": true }]
  }
}

Package Sidebar

Install

npm i eslint-plugin-array-tokens-sorter

Weekly Downloads

96

Version

0.0.7

License

MIT

Unpacked Size

10.1 kB

Total Files

15

Last publish

Collaborators

  • pashak09