1.0.0 • Published 4 years ago

eslint-plugin-nested-if v1.0.0

Weekly downloads
89
License
ISC
Repository
-
Last release
4 years ago

eslint-plugin-nested-if

Install

 $ npm i eslint-plugin-nested-if --save-dev

Integrate

  "rules": {
    "nested-if/nested-if-statements": ["warn", <number>]
  },
  "plugins": ["nested-if"]

What is checks?

With provided option of depth level 3 or greater than 3 (example) it will result into warning or error depending upon the config.

if(true) {
  if(true) {
    if (true) {
      console.log('hello');
    }
  }
}

What it will ignore?

if(true) {
  if(true) {
    var a = function () {
      if (true){
        // It's not inside same nested block statement of if.
      }
    }
  }
}

Why it checks?

  • Sometime times unintentionally we do a key check of object, for case like -

    const testObject = {1: {2: {3: {4: {5:5}}}}}

    With the new ecma version we now can completely avoid this type of case by using optional chaining.

  • Why we need more then 2 level of nesting?