.vue files are kept tidy since we introduced them. And the prettier rule "semi: false;" has been used since then. In JavaScript, the use of semicolons (;) to terminate statements is optional due to a feature called Automatic Semicolon Insertion (ASI). This mechanism allows developers to write code without explicit semicolons: the JS engine automatically inserts them where necessary. Pro: omitting semicolons leads to cleaner and more readable code by reducing visual clutter. Modern tools catch potential issues arising from ASI, making explicit semicolons redundant. However, relying only on ASI can introduce subtle bugs. For instance: ``` function getValue() { return { value: 42 } } ``` A semicolon is automatically inserted after the return statement: the function returns undefined instead of the object. This happens because it is interpreted as: ``` function getValue() { return; { value: 42 } } ``` Such unintended behavior can be avoided by explicitly using semicolons. One source: https://github.com/airbnb/javascript?tab=readme-ov-file#semicolons
We should decide now (before bug 38664 is pushed) so that we can adjust the .vue files if necessary. This bug report is for discussion. CCing people who might be interested in taking part in the discussion.
See the 2 following commits Bug 38664: (re)Tidy the .vue files - 'semi: true' Bug 38664: Treat .vue files like other JS files on https://gitlab.com/joubu/Koha/-/commits/bug_38664
In my opinion omitting semicolons does not make code more readable. I think including them makes it more readable.
(In reply to Owen Leonard from comment #3) > In my opinion omitting semicolons does not make code more readable. I think > including them makes it more readable. +1
Coming from perl, it's second nature to me to add semi-colons and I also agree I find it clearer to read... but I do realise I'm probably a little old fashioned on that front.
I have no opposition to doing it, it removes dependence on ASI and makes Vue code consistent with the rest of Koha, both in terms of JS and Perl
(In reply to Martin Renvoize (ashimema) from comment #5) > Coming from perl, it's second nature to me to add semi-colons and I also > agree I find it clearer to read... but I do realise I'm probably a little > old fashioned on that front. I'm the youngest here and I still agree lol. For posterity, I also want to point out these two examples of perfectly valid code that'd be screwn over without semicolons from the AirBnB examples: ```js // bad - raises exception const luke = {} const leia = {} [luke, leia].forEach((jedi) => jedi.father = 'vader') // bad - raises exception const reaction = "No! That’s impossible!" (async function meanwhileOnTheFalcon() { // handle `leia`, `lando`, `chewie`, `r2`, `c3p0` // ... }()) ``` These are real-life examples of code snippets that'd result in very confusing exceptions (especially if stuff worked while testing, and then a pre-commit hook got rid of the semicolons): ``` Uncaught ReferenceError: can't access lexical declaration 'leia' before initialization ``` ``` Uncaught TypeError: "No! That\u2019s impossible!" is not a function ``` Would you glance at these errors, the code, and immediately figure out the lack of semicolons is the cause?
Don't have a strong opinion here. From the explanations provided it seems that using semicolons has no downsides whereas not using them may cause subtle bugs. For that reason I suppose explicitly using semicolons would be preferable.
Thanks all. This will be done on bug 38664 then! *** This bug has been marked as a duplicate of bug 38664 ***