0.4.0 • Published 5 years ago
@mesteche/eslint-plugin-neat-ternaries v0.4.0
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 :
defaultValueInstallation
You'll first need to install ESLint:
$ npm i -D eslintNext, install @mesteche/eslint-plugin-neat-ternaries:
$ npm i -D @mesteche/eslint-plugin-neat-ternariesUsage
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
}
}