Bug 35718 - Remove ES6 warnings from JavaScript system preferences
Summary: Remove ES6 warnings from JavaScript system preferences
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: Lucas Gass
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-05 19:04 UTC by Lucas Gass
Modified: 2024-03-19 21:02 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
This removes some warnings when entering JavaScript in UserJS system preferences and library specific OPAC JS, when using ECMAScript 6 features/syntax.
Version(s) released in:
24.05.00,23.11.04
Circulation function:


Attachments
Bug 35718: Remove ES6 warns from JS system preferences (2.00 KB, patch)
2024-01-05 19:07 UTC, Lucas Gass
Details | Diff | Splinter Review
Bug 35718: Remove ES6 warns from JS system preferences (2.05 KB, patch)
2024-01-07 15:19 UTC, David Nind
Details | Diff | Splinter Review
Bug 35718: Remove ES6 warnings branches.tt (1.38 KB, patch)
2024-02-29 22:20 UTC, Lucas Gass
Details | Diff | Splinter Review
Bug 35718: Remove ES6 warns from JS system preferences (2.11 KB, patch)
2024-03-01 07:57 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 35718: Remove ES6 warnings branches.tt (1.44 KB, patch)
2024-03-01 07:57 UTC, Julian Maurice
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Lucas Gass 2024-01-05 19:04:18 UTC
When using any of the UserJS system preferences there are warnings if you use any ES6 features/syntax.

To recreate:

1. Add some JS like this to any of the UserJS system preferences:

$(document).ready( function() {
    let something = 1;
    const another_thing = 2;
   
    let an_arrow_function = (a, b) => a + b;
    console.log( an_arrow_function(something, another_thing) );
});

2. Notice the icons and warnings to the left of the line numbers:

let is available in ES6
const is available in ES6
arrow_function_syntax is available in ES6


ES6 syntax is pretty commonly used now, I don't think we need those warnings.
Comment 1 Lucas Gass 2024-01-05 19:07:13 UTC
Created attachment 160584 [details] [review]
Bug 35718: Remove ES6 warns from JS system preferences

To test:
1. Add some JS like this to any of the UserJS system preferences:

$(document).ready( function() {
    let something = 1;
    const another_thing = 2;

    let an_arrow_function = (a, b) => a + b;
    console.log( an_arrow_function(something, another_thing) );
});

2. Notice the icons and warnings to the left of the line numbers:

let is available in ES6
const is available in ES6
arrow_function_syntax is available in ES6

3. APPLY PATCH
4. Try steps 1 and 2 again, the warnings should be gone.
5. Check that the JavaScript still works, in my example it should console.log 3.
Comment 2 David Nind 2024-01-07 15:19:37 UTC
Created attachment 160613 [details] [review]
Bug 35718: Remove ES6 warns from JS system preferences

To test:
1. Add some JS like this to any of the UserJS system preferences:

$(document).ready( function() {
    let something = 1;
    const another_thing = 2;

    let an_arrow_function = (a, b) => a + b;
    console.log( an_arrow_function(something, another_thing) );
});

2. Notice the icons and warnings to the left of the line numbers:

let is available in ES6
const is available in ES6
arrow_function_syntax is available in ES6

3. APPLY PATCH
4. Try steps 1 and 2 again, the warnings should be gone.
5. Check that the JavaScript still works, in my example it should console.log 3.

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 David Cook 2024-01-09 07:37:48 UTC
If no one else gets this first, I'll try to look at it tomorrow or week after next...
Comment 4 Julian Maurice 2024-02-23 10:39:07 UTC
I know that the bug is only about the system preferences page, but Koha also allows to write JS in the "edit library" page.
I think Koha should be consistent about linter settings everywhere it's used.
Can you please remove ES6 warnings on the library page too ?
Comment 5 Lucas Gass 2024-02-29 22:20:29 UTC
Created attachment 162623 [details] [review]
Bug 35718: Remove ES6 warnings branches.tt
Comment 6 Julian Maurice 2024-03-01 07:57:02 UTC
Created attachment 162631 [details] [review]
Bug 35718: Remove ES6 warns from JS system preferences

To test:
1. Add some JS like this to any of the UserJS system preferences:

$(document).ready( function() {
    let something = 1;
    const another_thing = 2;

    let an_arrow_function = (a, b) => a + b;
    console.log( an_arrow_function(something, another_thing) );
});

2. Notice the icons and warnings to the left of the line numbers:

let is available in ES6
const is available in ES6
arrow_function_syntax is available in ES6

3. APPLY PATCH
4. Try steps 1 and 2 again, the warnings should be gone.
5. Check that the JavaScript still works, in my example it should console.log 3.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Comment 7 Julian Maurice 2024-03-01 07:57:05 UTC
Created attachment 162632 [details] [review]
Bug 35718: Remove ES6 warnings branches.tt

Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Comment 8 Julian Maurice 2024-03-01 07:57:42 UTC
Thanks for the follow-up.
Comment 9 Katrin Fischer 2024-03-08 17:59:22 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 10 Fridolin Somers 2024-03-11 14:15:44 UTC
Pushed to 23.11.x for 23.11.04