[Bug 39059] New: Do not use "semi: false" for .vue files
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39059 Bug ID: 39059 Summary: Do not use "semi: false" for .vue files Change sponsored?: --- Product: Koha Version: unspecified Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: jonathan.druart@gmail.com Reporter: jonathan.druart@gmail.com QA Contact: testopia@bugs.koha-community.org Blocks: 38664 .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 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38664 [Bug 38664] Tidy the whole codebase -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39059 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |In Discussion CC| |julian.maurice@biblibre.com | |, | |matt.blenkinsop@ptfs-europe | |.com, oleonard@myacpl.org, | |pedro.amorim@ptfs-europe.co | |m, | |schodkowy.omegi-0r@icloud.c | |om --- Comment #1 from Jonathan Druart <jonathan.druart@gmail.com> --- 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. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39059 --- Comment #2 from Jonathan Druart <jonathan.druart@gmail.com> --- 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 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39059 --- Comment #3 from Owen Leonard <oleonard@myacpl.org> --- In my opinion omitting semicolons does not make code more readable. I think including them makes it more readable. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39059 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au --- Comment #4 from David Cook <dcook@prosentient.com.au> --- (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 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39059 Martin Renvoize (ashimema) <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |martin.renvoize@ptfs-europe | |.com --- Comment #5 from Martin Renvoize (ashimema) <martin.renvoize@ptfs-europe.com> --- 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. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39059 --- Comment #6 from Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> --- 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 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39059 --- Comment #7 from Michał <schodkowy.omegi-0r@icloud.com> --- (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? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39059 --- Comment #8 from Pedro Amorim <pedro.amorim@ptfs-europe.com> --- 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.
-- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39059 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |DUPLICATE Status|In Discussion |RESOLVED --- Comment #9 from Jonathan Druart <jonathan.druart@gmail.com> --- Thanks all. This will be done on bug 38664 then! *** This bug has been marked as a duplicate of bug 38664 *** -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org