4 ms·
I would prefer finding a subset of JavaScript in which omitting semicolons is okay. Maybe this could be enforced in a linter. For example, if you never begin st
by lacker 11y ago
I would prefer finding a subset of JavaScript in which omitting semicolons is okay. Maybe this could be enforced in a linter. For example, if you never begin statements with [ or (, would it be okay to omit all semicolons?
A semicolon doesn't seem like much but that's a lot of extra typing over the course of a career.
- mcav 11y agoThis (somewhat insane) linter prohibits unnecessary semicolons: http://standardjs.com http://standardjs.com
- WorldMaker 11y agoThere is a growing number of us moving away from semicolons. I find Typescript useful as the language is (of course) ASI-aware and you can double check that the Typescript compiler's output looks about how you would "expect it". ESLint and TSLint both now have semicolon never options and StandardJS is a simple NPM install standard away towards such an ESLint configuration. Yeah, pretty much the only "rules" are to know never to add a line break after keywords such as return (which is the same rule as languages such as Python and which is also something you have to know, regardless of semicolons) and the "Winky Frown Rule": (, [, and ` all have to be winky frowns if you start a line with one: ;(, ;[, ;` It's pretty liberating writing JS/ES/TS without semicolons, and with ES2015 syntax things, makes the language feel like Python or an OCaML relative (which it sort of is).