eslint-plugin-nested-if

1.0.0 • Public • Published

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?

Readme

Keywords

none

Package Sidebar

Install

npm i eslint-plugin-nested-if

Weekly Downloads

2,741

Version

1.0.0

License

ISC

Unpacked Size

2.09 kB

Total Files

3

Last publish

Collaborators

  • raivaibhav