jscs-dev / node-jscs

:arrow_heading_up: JavaScript Code Style checker (unmaintained)
https://jscs-dev.github.io
MIT License
4.96k stars 510 forks source link

requireNewlineBeforeBlockStatements is not working with 'switch' #2045

Closed PaulAnnekov closed 8 years ago

PaulAnnekov commented 8 years ago

Why requireNewlineBeforeBlockStatements option does not accept switch statement?

markelog commented 8 years ago

It totally should, would you like to implement it?

PaulAnnekov commented 8 years ago

@markelog ok, I will try. What about to write nice work, bro mentioning me on twitter when you will close PR? JFF :)

markelog commented 8 years ago

We didn't do it before, but i don't see a reason why we can't :-)

PaulAnnekov commented 8 years ago

@markelog oh, switch's body in AST is defined not even like class's body. It doesn't have a child node that will include braces, so we can't add switch support by adding 2-3 words to source code :).

I have added switch support by special check: https://github.com/PaulAnnekov/node-jscs/commit/0ce22181f51af82cf30916592d9076d78bcde12e https://github.com/PaulAnnekov/node-jscs/commit/b717058d017825b37f5cdc81085b2f8404b3739c

It is OK or maybe we should create separate rule for it because now it looks like exceptional case in sources?

markelog commented 8 years ago

It is OK

I'd say yes, but we need to structure it with low cyclomatic complexity