News for hackers. Stuff that matters.
Re:ESLint 7.0 by traes on Monday May 11, 2020 @07:26PM (#23148563)
> to enforce the lack of semicolons

Why would... you want that? You're trading minimal syntactic noise for possible ambiguity errors. You don't really gain anything.

Re:ESLint 7.0 by DCoder on Tuesday May 12, 2020 @01:34AM (#23150846)
This is like asking "vim or emacs". You'll never change anyone's mind on the matter, but you'll get the same old arguments from ~ten years ago [0] about how this is both "very simple†" and "pointless mental overhead" at the same time.

† (if you follow these rules I memorized to show off how smart I am).

---

[0]: https://github.com/twbs/bootstrap/issues/3057

Re:ESLint 7.0 by bdefore on Monday May 11, 2020 @07:42PM (#23148754)
In combination with other linting rules to catch reckless conditionals and multiline returns, it is absolutely safe to enforce no semicolons. And the visual noise is, at least to my eyes, a significant impact.
Re:ESLint 7.0 by wildpeaks on Saturday May 16, 2020 @09:03AM (#23203045)
If visual noise is an issue, I made a VSCode theme specifically for muting things like quotes and semicolons, that way I don't have to choose between explicit semicolons and reduced visual clutter: https://marketplace.visualstudio.com/items?itemName=wildpeak...

The theme was primarily made for me, but I published it because others might find the idea useful.

Re:ESLint 7.0 by hombre_fatal on Monday May 11, 2020 @10:13PM (#23149873)
You need to know when semicolons are necessary whether you use them or not.

And the whole point here is that tooling eslint/prettier prevents bugs.

Prettier will turn this:

    const x = foo()
    [1, 2, 3].forEach(...)
into this:

    const x = foo()[1, 2, 3].forEach(...)
Which makes the problem pretty obvious.

Btw, if you decide to avoid semicolons, one of the only rules you need to know is to prefix any line with a semicolon if it starts with "[(.

Re:ESLint 7.0 by traes on Monday May 11, 2020 @10:35PM (#23150004)
Introducing any mental overhead to eliminate a single character per line at most seems a tad ridiculous.
Re:ESLint 7.0 by hombre_fatal on Tuesday May 12, 2020 @12:39AM (#23150639)
I haven't used semicolons for at least 5 years. Let's not overstate the "overhead", which I would say is zero. Especially in this comment thread where we just established the tooling handles it for you.

Frankly, I die inside every time I work with a semicolon codebase and have to move a semicolon just to chain onto:

    promise
      .then()
      .catch();
    + .then();

    foo
      .bar()
      .baz();
    + .qux();
You are making the common developer/HNer mistake of overvaluing familiarity and overestimating how hard anything slightly unfamiliar must be.

I challenge you to try it the next time you write some Javascript. Don't use semis and remember the one rule I taught you.

Re:ESLint 7.0 by soulofmischief on Tuesday May 12, 2020 @02:14AM (#23151020)
After every single line is not minimal. It's redundant.

In 30 minutes you can learn to recognize and practice handling all of the cases where a semicolon would be necessary. There is no ambiguity because the rules for statement termination are rigid. If you find it hard to navigate with only explicit semicolons, then you should brush up on your JavaScript knowledge.

And seeing as how we're on an ESLint thread... there are tools for that. ;)

Re:ESLint 7.0 by dlbucci on Monday May 11, 2020 @09:52PM (#23149733)
I used always have semi-colons too, but now that my code is always transpiled, I just let the transpiler handle it (and TypeScript does a good job catching ambiguities/unintended code pretty well too).