@mesteche/eslint-plugin-neat-ternaries

0.4.0 • Public • Published

eslint-plugin-neat-ternaries

npm

format chained ternaries to optimize readability

  • Each line correspond to a case (condition/value pair)
  • The chained ternary is formatted in two columns:
    • The left column is for conditions
    • The right column is for the matching values (including the default value)

Like this:

const neatTernary = someCondition       ? someValue :
                    someOtherCondition  ? someOtherValue :
                    yetAnotherCondition ? yetAnotherValue :
                                          defaultValue

Installation

You'll first need to install ESLint:

$ npm i -D eslint

Next, install @mesteche/eslint-plugin-neat-ternaries:

$ npm i -D @mesteche/eslint-plugin-neat-ternaries

Usage

Add @mesteche/neat-ternaries to the plugins section of your .eslintrc configuration file:

{
    "plugins": [
        "@mesteche/neat-ternaries"
    ]
}

Then configure the rules you want to use under the rules section.

{
    "rules": {
        "@mesteche/neat-ternaries/rule-name": 2
    }
}

Supported Rules

Dependencies (1)

Dev Dependencies (2)

Package Sidebar

Install

npm i @mesteche/eslint-plugin-neat-ternaries

Weekly Downloads

0

Version

0.4.0

License

ISC

Unpacked Size

25.1 kB

Total Files

19

Last publish

Collaborators

  • mesteche