Enable the ESLint no-var rule in the extensions/firefox/ folder

This was done automatically, using the `gulp lint --fix` command.
This commit is contained in:
Jonas Jenwald 2023-07-22 10:05:37 +02:00
parent 6d783d2722
commit 25cb4883e9
2 changed files with 13 additions and 16 deletions

View File

@ -15,9 +15,6 @@
], ],
"rules": { "rules": {
// Items different from the mozilla/recommended configuration.
"no-var": "off",
// Other rules mozilla/recommended hasn't enabled yet. // Other rules mozilla/recommended hasn't enabled yet.
"no-shadow": "error", "no-shadow": "error",
"arrow-body-style": ["error", "as-needed"], "arrow-body-style": ["error", "as-needed"],

View File

@ -30,8 +30,8 @@
// translate a string // translate a string
function translateString(key, args, fallback) { function translateString(key, args, fallback) {
var i = key.lastIndexOf("."); const i = key.lastIndexOf(".");
var name, property; let name, property;
if (i >= 0) { if (i >= 0) {
name = key.substring(0, i); name = key.substring(0, i);
property = key.substring(i + 1); property = key.substring(i + 1);
@ -39,8 +39,8 @@
name = key; name = key;
property = "textContent"; property = "textContent";
} }
var data = getL10nData(name); const data = getL10nData(name);
var value = (data && data[property]) || fallback; const value = (data && data[property]) || fallback;
if (!value) { if (!value) {
return "{{" + key + "}}"; return "{{" + key + "}}";
} }
@ -54,15 +54,15 @@
} }
// get the related l10n object // get the related l10n object
var key = element.dataset.l10nId; const key = element.dataset.l10nId;
var data = getL10nData(key); const data = getL10nData(key);
if (!data) { if (!data) {
return; return;
} }
// get arguments (if any) // get arguments (if any)
// TODO: more flexible parser? // TODO: more flexible parser?
var args; let args;
if (element.dataset.l10nArgs) { if (element.dataset.l10nArgs) {
try { try {
args = JSON.parse(element.dataset.l10nArgs); args = JSON.parse(element.dataset.l10nArgs);
@ -73,7 +73,7 @@
// translate element // translate element
// TODO: security check? // TODO: security check?
for (var k in data) { for (const k in data) {
element[k] = substArguments(data[k], args); element[k] = substArguments(data[k], args);
} }
} }
@ -83,9 +83,9 @@
element = element || document.querySelector("html"); element = element || document.querySelector("html");
// check all translatable children (= w/ a `data-l10n-id' attribute) // check all translatable children (= w/ a `data-l10n-id' attribute)
var children = element.querySelectorAll("*[data-l10n-id]"); const children = element.querySelectorAll("*[data-l10n-id]");
var elementCount = children.length; const elementCount = children.length;
for (var i = 0; i < elementCount; i++) { for (let i = 0; i < elementCount; i++) {
translateElement(children[i]); translateElement(children[i]);
} }
@ -109,10 +109,10 @@
getDirection() { getDirection() {
// http://www.w3.org/International/questions/qa-scripts // http://www.w3.org/International/questions/qa-scripts
// Arabic, Hebrew, Farsi, Pashto, Urdu // Arabic, Hebrew, Farsi, Pashto, Urdu
var rtlList = ["ar", "he", "fa", "ps", "ur"]; const rtlList = ["ar", "he", "fa", "ps", "ur"];
// use the short language code for "full" codes like 'ar-sa' (issue 5440) // use the short language code for "full" codes like 'ar-sa' (issue 5440)
var shortCode = gLanguage.split("-")[0]; const shortCode = gLanguage.split("-")[0];
return rtlList.includes(shortCode) ? "rtl" : "ltr"; return rtlList.includes(shortCode) ? "rtl" : "ltr";
}, },