1.5.0 • Published 8 years ago

coffeelint-alphabetize-keys v1.5.0

Weekly downloads
81
License
MIT
Repository
github
Last release
8 years ago

coffeelint-alphabetize-keys

NPM Version Build Status

Coffeelint rule requiring objects to have keys in alphabetical order

Installation

npm install coffeelint-alphabetize-keys

Usage

Put this in your coffeelint config:

"alphabetize_keys": {
  "module": "coffeelint-alphabetize-keys"
}

Configuration options

  • overrides - Array of keys to order as a separate category, keys must appear in the order provided.

Examples

Objects

{keyA, keyB, keyC} # Good
{keyC, keyB, keyA} # Bad

The rule applies to both defining and destructing objects.

Classes

# Good
class A
  methodA: ->
  methodB: ->
  methodC: ->

# Bad
class A
  methodC: ->
  methodB: ->
  methodA: ->

The keys are broken down into 8 categories and each are required to only be individually alphabetical. Keys are separated based on:

  • function vs variable (based on the type of the value)
  • public vs private (key starting with _ is private)
  • instance vs static

The constructor function is ignored.

Overrides

"alphabetize_keys": {
  "module": "coffeelint-alphabetize-keys",
  "overrides": ["methodC", "methodB", "methodA"]
}
# Good
class A
  methodC: ->
  methodB: ->
  methodA: ->

# Bad
class A
  methodA: ->
  methodB: ->
  methodC: ->
1.5.0

8 years ago

1.4.2

9 years ago

1.4.1

9 years ago

1.4.0

9 years ago

1.3.0

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago