question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rule proposal: Collapsible if-statements

See original GitHub issue

The rule should identify nested if-statements that can be combined into one.

Would be useful if the rule could be auto-fixable.

Instead of:

if (foo) {
    if (bar) {
        // ...
    }
}

Prefer:

if (foo && bar) {
    // ...
}

From: https://github.com/typescript-eslint/typescript-eslint/issues/279

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
sindresorhuscommented, Dec 17, 2020

No, but @sindresorhus made this proposal here. I guess he want have this rule in unicorn first?

Yeah, I have given up bothering proposing stuff over at ESLint. The process there is way too slow and they reject almost everything anyway.

2reactions
fiskercommented, Dec 14, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Rule proposal: Collapsible if-statements · Issue #279 - GitHub
The rule should identify nested if-statements that can be combined into one. Would be useful if the rule could be auto-fixable. Instead of:....
Read more >
Apex static code analysis: Collapsible "if" statements should ...
Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code Smells in your APEX code ... Collapsible "if" statements should be merged.
Read more >
Refactoring - Collapsible "if" statements should be merged
In IntelliJ IDEA put the text cursor on the first if keyword, press Alt + Enter and invoke Merge nested 'if's . Save...
Read more >
SonarQube - Collapsible If Statements
Sometimes two 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator. This rule is deprecated, ...
Read more >
Collapse If Statements | jSparrow Documentation
Collapses, when possible, the nested if-statements into a single one by concatenating their conditions with the infix operator && . If the concatenation ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found