Hacker News new | ask | show | jobs
by tauchunfall 4037 days ago
>Unfortunately the rules are complex, prone to certain errors, and I can't rely on everyone I ever work with understanding all of those rules.

Are they really complex? This recently released version 4.0.0 of the JavaScript Standard Style [1] suggests to never start a line with "(" or "[". This rule looks even simpler than the rules of operator precedence.

[1] https://github.com/feross/standard

Update: Now I learned about the JavaScript Semi-Standard Style [2] which accually enforces semi-colons. Quite hilarious.

[2] https://github.com/Flet/semistandard

1 comments

They are complicated enough; and different enough from other languages that they lead to unexpected behaviors. It is just easier to say, "everyone must use semi-colons". Then I can add linting into our build process and reduce risk of bugs.

One quick example is the very contrived example that follows.

return {a:1, b:2}

That is valid JavaScript. It is evaluated as an empty return and an unreachable expression. Probably not what was intended.

I've sent copies of the rules to people and explained them numerous times, but at the end of the day it is more productive to just use them and move on to something else IMHO.