eslint-plugin-unicorn
eslint-plugin-unicorn copied to clipboard
Add `switch-braces` rule
Fixes #1702
The fixer will require some tweaks to get it working nicer with both multiline and single-line expressions. Also some more tests may help.
The files for no-array-for-each
and no-useless-spread
are both triggering the rule so that part seems to work
You may misunderstood, the braces creates a new scope, when there are variable declare, braces are required. Correct me if I'm wrong.
Yes, you are correct. The way MDN describes it makes it sound like more of an inconvenience but this will probably make automatic fixing improbable.
My personal opinion, we should only report those cases that braces can be removed. No option alway
and never
.
Stylistically speaking, we'd only want for all blocks to either have braces or blocks.
I personally think braces should always be used for consistency and safety.
The rule is built to allow for either always braces (default) or never braces to allow for differing opinions. The whole context thing adds extra steps since variables defined outside of break statements can't be re-defined within them unless they are block statements which makes fixing a manual thing.
@Richienb Still interested in finishing this?