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>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Lucas Gass 2024-01-05 19:05:01 +00:00 committed by Katrin Fischer
parent 6bf839d892
commit 5e3ae14aa0
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -82,6 +82,7 @@ function addExpandHandler() {
$(this).hide();
var target = $(this).data("target");
var syntax = $(this).data("syntax");
var lint_type = syntax === 'javascript'? { 'esversion': 6 } : true;
$("#collapse_" + target).show();
if (syntax) {
var editor = CodeMirror.fromTextArea(document.getElementById("pref_" + target), {
@ -90,7 +91,7 @@ function addExpandHandler() {
lineWrapping: true,
viewportMargin: Infinity,
gutters: ["CodeMirror-lint-markers"],
lint: true
lint: lint_type,
});
editor.on("change", function () {
mark_modified.call($("#pref_" + target)[0]);