/eslint-plugin-ternaries

Eslint rules concerning ternaries

Primary LanguageJavaScriptMIT LicenseMIT

eslint-plugin-ternaries Build Status npm version

Eslint rules concerning ternaries

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install eslint-plugin-ternaries:

$ npm install eslint-plugin-ternaries --save-dev

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-ternaries globally.

Usage

Add ternaries to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
+        "ternaries"
    ]
}

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

{
    "rules": {
+        "ternaries/no-null-ternary": 2,
+        "ternaries/no-empty-ternary": 2
    }
}

Supported Rules

  • no-null-ternary - Disallows ternaries with null as either the consequent or alternate condition.
  • no-empty-ternary - Disallows ternaries that have '' or "" as either condition.