diff --git a/extensions/firefox/.eslintrc b/extensions/firefox/.eslintrc index 7c4e6e682..3074a764a 100644 --- a/extensions/firefox/.eslintrc +++ b/extensions/firefox/.eslintrc @@ -7,7 +7,7 @@ ], "parserOptions": { - "sourceType": "script", + "sourceType": "module", }, "plugins": [ diff --git a/external/importL10n/locales.js b/external/importL10n/locales.mjs similarity index 95% rename from external/importL10n/locales.js rename to external/importL10n/locales.mjs index 0e16f3843..04d818f88 100644 --- a/external/importL10n/locales.js +++ b/external/importL10n/locales.mjs @@ -13,11 +13,9 @@ * limitations under the License. */ -"use strict"; - -const fs = require("fs"); -const https = require("https"); -const path = require("path"); +import fs from "fs"; +import https from "https"; +import path from "path"; // Fetches all languages that have an *active* translation in mozilla-central. // This is used in gulpfile.js for the `importl10n` command. @@ -112,7 +110,7 @@ function downloadLanguageFiles(root, langCode) { }); } -async function downloadL10n(root, callback) { +async function downloadL10n(root) { const langCodes = await downloadLanguageCodes(); for (const langCode of langCodes) { @@ -142,10 +140,6 @@ async function downloadL10n(root, callback) { "\n" ); } - - if (callback) { - callback(); - } } -exports.downloadL10n = downloadL10n; +export { downloadL10n }; diff --git a/gulpfile.js b/gulpfile.js index 20b37a092..8dfff41b4 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1880,7 +1880,7 @@ gulp.task("lint", function (done) { const esLintOptions = [ "node_modules/eslint/bin/eslint", "--ext", - ".js,.jsm,.json", + ".js,.jsm,.mjs,.json", ".", "--report-unused-disable-directives", ]; @@ -2004,8 +2004,8 @@ gulp.task("clean", function (done) { rimraf(BUILD_DIR, done); }); -gulp.task("importl10n", function (done) { - const locales = require("./external/importL10n/locales.js"); +gulp.task("importl10n", async function () { + const { downloadL10n } = await import("./external/importL10n/locales.mjs"); console.log(); console.log("### Importing translations from mozilla-central"); @@ -2013,7 +2013,7 @@ gulp.task("importl10n", function (done) { if (!fs.existsSync(L10N_DIR)) { fs.mkdirSync(L10N_DIR); } - locales.downloadL10n(L10N_DIR, done); + await downloadL10n(L10N_DIR); }); function ghPagesPrepare() {