[Development] Using semicolons in JS (QML)

Andreas Aardal Hanssen andreas at hanssen.name
Fri Sep 30 14:41:25 CEST 2016

2016-09-30 14:19 GMT+02:00 Kai Koehne <Kai.Koehne at qt.io>:

> To make a proposal: Let’s use semicolons in imperative JS parts of QML in
> our examples and documentation.
> Apart from being on the safe side regarding some pathological cases, it
> also makes the difference between declarative QML bindings  and
> imperative JS code more explicit.

I propose to have semicolons based on the following rules:

1. Every second line of js outside of any scope should end with a semicolon.
2. Semicolon for multiline statements inside an if.
3. If whitespace isn't clear enough, add one semicolon to make the code
more readable.
4. If the semicolon makes you feel angry, feel free to arbitrarily add (or
remove) semicolons to make you feel better.

For example:

a = b // ok
a = c; // ok, since it's every second line
a = d; // WRONG drop the semicolon, be consistent for goodness sake
; // good, add a semicolon to emphasize the whitespace
;;; // now you're just being ridiculous
if (a === b) {
    a = b;
    a = c; // very good!

Andreas :-) just trying to help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20160930/0b6b8d30/attachment.html>

More information about the Development mailing list