@mesteche/eslint-plugin-neat-ternaries
v0.4.0
Published
format ternaries to optimize readability
Downloads
2
Maintainers
Readme
eslint-plugin-neat-ternaries
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
}
}