简体   繁体   中英

Is there an ESLint rule that checks the number of logical operators in a conditional expression?

I am looking for such a rule to see the complexity of the conditional expression.

For example, if the threshold is 5, the following conditional expression would result in an error:

if ((true && false) || ((false || true) && (true || false))) {
  // ...
}

However, the following conditional expression will not produce an error:

if ((true && false) || ((false || true) && true)) {
  // ...
}

I created an ESLint plugin to check the number of logical operator . For the moment, it only check the number of logical operators in the conditional expression of the if statement. But I may update the rule to get to check any expression.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM