Skip to content

Enable and fix `curly` rule (but ignore single-line blocks)

Axel Bocciarelli requested to merge eslint-curly into master

https://eslint.org/docs/rules/curly

The curly rule is now configured to multi-line so as to report and fix braceless multi-line blocks like this:

// BEFORE
if (foo)
  doSomething();

// AFTER
if (foo) {
  doSomething();
}

Braceless multi-line blocks are not as readable, and also risky, because if two lines get swapped by mistake, it can go undetected. Now, if two lines get swapped, there's a chance that the block will become empty, and therefore be reported as such by ESLint.

The codebase has a lot of single-line if blocks like if (foo) doSomething();, which is perfectly fine, so I've left those alone.

Edited by Axel Bocciarelli

Merge request reports