diff --git a/.eslintrc.js b/.eslintrc.js index 477c656..2209cce 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -9,6 +9,14 @@ module.exports = { "plugins": ["mozilla"], "extends": ["plugin:mozilla/recommended"], + rules: { + // experiment files are not ES modules, so we can't use static import + "mozilla/use-static-import": "off", + + // We are still experimenting, console messages are ok for now + "no-console": "off" + }, + overrides: [ { files: [".eslintrc.js"], @@ -17,5 +25,12 @@ module.exports = { browser: false, }, }, + { + files: ["*/experiments/*/parent/*.js"], + globals: { + global: true, + Services: true, + } + } ] }; diff --git a/NotificationBox/NotificationBox/implementation.js b/NotificationBox/NotificationBox/implementation.js index 219a95b..1a6027d 100644 --- a/NotificationBox/NotificationBox/implementation.js +++ b/NotificationBox/NotificationBox/implementation.js @@ -99,7 +99,7 @@ const parts = cssPropertyName.split("-"); return ( // check if first part is in whitelist - parts.length > 0 && + !!parts.length && allowedCssPropNames.includes(parts[0]) && // validate second part (if any) being a simple word (parts.length == 1 || diff --git a/NotificationBox/background.js b/NotificationBox/background.js index e495bed..e1207e1 100644 --- a/NotificationBox/background.js +++ b/NotificationBox/background.js @@ -6,9 +6,9 @@ messenger.NotificationBox.onButtonClicked.addListener((windowId, notificationId, if (["btn-keep"].includes(buttonId)) { console.log("Box will not close, as long as one listener returns {close:false}."); return { close: false }; - } else { + } return { close: true }; - } + }); // Defining another onButtonClicked listener diff --git a/calendar/experiments/calendar/ext-calendar-utils.sys.mjs b/calendar/experiments/calendar/ext-calendar-utils.sys.mjs index 08cca19..e46829a 100644 --- a/calendar/experiments/calendar/ext-calendar-utils.sys.mjs +++ b/calendar/experiments/calendar/ext-calendar-utils.sys.mjs @@ -2,9 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -var { - ExtensionUtils: { ExtensionError, promiseEvent } -} = ChromeUtils.importESModule("resource://gre/modules/ExtensionUtils.sys.mjs"); +var { ExtensionUtils: { ExtensionError, promiseEvent } } = ChromeUtils.importESModule("resource://gre/modules/ExtensionUtils.sys.mjs"); var { cal } = ChromeUtils.importESModule("resource:///modules/calendar/calUtils.sys.mjs"); var { CalEvent } = ChromeUtils.importESModule("resource:///modules/CalEvent.sys.mjs"); diff --git a/calendar/experiments/calendar/parent/ext-calendar-calendars.js b/calendar/experiments/calendar/parent/ext-calendar-calendars.js index a39a481..44b1000 100644 --- a/calendar/experiments/calendar/parent/ext-calendar-calendars.js +++ b/calendar/experiments/calendar/parent/ext-calendar-calendars.js @@ -2,12 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -var { - ExtensionCommon: { ExtensionAPI, EventManager } -} = ChromeUtils.importESModule("resource://gre/modules/ExtensionCommon.sys.mjs"); -var { - ExtensionUtils: { ExtensionError } -} = ChromeUtils.importESModule("resource://gre/modules/ExtensionUtils.sys.mjs"); +var { ExtensionCommon: { ExtensionAPI, EventManager } } = ChromeUtils.importESModule("resource://gre/modules/ExtensionCommon.sys.mjs"); +var { ExtensionUtils: { ExtensionError } } = ChromeUtils.importESModule("resource://gre/modules/ExtensionUtils.sys.mjs"); var { cal } = ChromeUtils.importESModule("resource:///modules/calendar/calUtils.sys.mjs"); @@ -23,7 +19,7 @@ this.calendar_calendars = class extends ExtensionAPI { return { calendar: { calendars: { - query: async function({ type, url, name, color, readOnly, enabled }) { + async query({ type, url, name, color, readOnly, enabled }) { let calendars = cal.manager.getCalendars(); let pattern = null; @@ -68,7 +64,7 @@ this.calendar_calendars = class extends ExtensionAPI { }) .map(calendar => convertCalendar(context.extension, calendar)); }, - get: async function(id) { + async get(id) { // TODO find a better way to determine cache id if (id.endsWith("#cache")) { let calendar = unwrapCalendar(cal.manager.getCalendarById(id.substring(0, id.length - 6))); @@ -79,7 +75,7 @@ this.calendar_calendars = class extends ExtensionAPI { return convertCalendar(context.extension, calendar); } }, - create: async function(createProperties) { + async create(createProperties) { let calendar = cal.manager.createCalendar( createProperties.type, Services.io.newURI(createProperties.url) @@ -98,7 +94,7 @@ this.calendar_calendars = class extends ExtensionAPI { calendar = cal.manager.getCalendarById(calendar.id); return convertCalendar(context.extension, calendar); }, - update: async function(id, updateProperties) { + async update(id, updateProperties) { let calendar = cal.manager.getCalendarById(id); if (!calendar) { throw new ExtensionError(`Invalid calendar id: ${id}`); @@ -141,7 +137,7 @@ this.calendar_calendars = class extends ExtensionAPI { } } }, - remove: async function(id) { + async remove(id) { let calendar = cal.manager.getCalendarById(id); if (!calendar) { throw new ExtensionError(`Invalid calendar id: ${id}`); @@ -149,7 +145,7 @@ this.calendar_calendars = class extends ExtensionAPI { cal.manager.unregisterCalendar(calendar); }, - clear: async function(id) { + async clear(id) { if (!id.endsWith("#cache")) { throw new ExtensionError("Cannot clear non-cached calendar"); } @@ -179,7 +175,7 @@ this.calendar_calendars = class extends ExtensionAPI { calendar.wrappedJSObject.mObservers.notify("onLoad", [calendar]); }, - synchronize: function(ids) { + synchronize(ids) { let calendars = []; if (ids) { if (!Array.isArray(ids)) { diff --git a/calendar/experiments/calendar/parent/ext-calendar-items.js b/calendar/experiments/calendar/parent/ext-calendar-items.js index 73e349e..aa9101b 100644 --- a/calendar/experiments/calendar/parent/ext-calendar-items.js +++ b/calendar/experiments/calendar/parent/ext-calendar-items.js @@ -2,12 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -var { - ExtensionCommon: { ExtensionAPI, EventManager } -} = ChromeUtils.importESModule("resource://gre/modules/ExtensionCommon.sys.mjs"); -var { - ExtensionUtils: { ExtensionError } -} = ChromeUtils.importESModule("resource://gre/modules/ExtensionUtils.sys.mjs"); +var { ExtensionCommon: { ExtensionAPI, EventManager } } = ChromeUtils.importESModule("resource://gre/modules/ExtensionCommon.sys.mjs"); +var { ExtensionUtils: { ExtensionError } } = ChromeUtils.importESModule("resource://gre/modules/ExtensionUtils.sys.mjs"); var { cal } = ChromeUtils.importESModule("resource:///modules/calendar/calUtils.sys.mjs"); @@ -26,7 +22,7 @@ this.calendar_items = class extends ExtensionAPI { return { calendar: { items: { - query: async function(queryProps) { + async query(queryProps) { let calendars = []; if (typeof queryProps.calendarId == "string") { calendars = [getResolvedCalendarById(context.extension, queryProps.calendarId)]; @@ -64,12 +60,12 @@ this.calendar_items = class extends ExtensionAPI { return calendarItems.flat().map(item => convertItem(item, queryProps, context.extension)); }, - get: async function(calendarId, id, options) { + async get(calendarId, id, options) { let calendar = getResolvedCalendarById(context.extension, calendarId); let item = await calendar.getItem(id); return convertItem(item, options, context.extension); }, - create: async function(calendarId, createProperties) { + async create(calendarId, createProperties) { let calendar = getResolvedCalendarById(context.extension, calendarId); let item = propsToItem(createProperties); item.calendar = calendar.superCalendar; @@ -88,7 +84,7 @@ this.calendar_items = class extends ExtensionAPI { return convertItem(createdItem, createProperties, context.extension); }, - update: async function(calendarId, id, updateProperties) { + async update(calendarId, id, updateProperties) { let calendar = getResolvedCalendarById(context.extension, calendarId); let oldItem = await calendar.getItem(id); @@ -112,7 +108,7 @@ this.calendar_items = class extends ExtensionAPI { let modifiedItem = await calendar.modifyItem(newItem, oldItem); return convertItem(modifiedItem, updateProperties, context.extension); }, - move: async function(fromCalendarId, id, toCalendarId) { + async move(fromCalendarId, id, toCalendarId) { if (fromCalendarId == toCalendarId) { return; } @@ -135,7 +131,7 @@ this.calendar_items = class extends ExtensionAPI { await toCalendar.addItem(item); await fromCalendar.deleteItem(item); }, - remove: async function(calendarId, id) { + async remove(calendarId, id) { let calendar = getResolvedCalendarById(context.extension, calendarId); let item = await calendar.getItem(id); diff --git a/calendar/experiments/calendar/parent/ext-calendar-provider.js b/calendar/experiments/calendar/parent/ext-calendar-provider.js index 550dbfc..41ac2d8 100644 --- a/calendar/experiments/calendar/parent/ext-calendar-provider.js +++ b/calendar/experiments/calendar/parent/ext-calendar-provider.js @@ -2,9 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -var { - ExtensionCommon: { ExtensionAPI, EventManager } -} = ChromeUtils.importESModule("resource://gre/modules/ExtensionCommon.sys.mjs"); +var { ExtensionCommon: { ExtensionAPI, EventManager } } = ChromeUtils.importESModule("resource://gre/modules/ExtensionCommon.sys.mjs"); var { cal } = ChromeUtils.importESModule("resource:///modules/calendar/calUtils.sys.mjs"); var { ExtensionSupport } = ChromeUtils.importESModule("resource:///modules/ExtensionSupport.sys.mjs"); @@ -484,9 +482,7 @@ this.calendar_provider = class extends ExtensionAPI { } loadPromise.then(() => { - browser.fixupAndLoadURIString(calendarType.panelSrc, { - triggeringPrincipal: this.extension.principal - }); + browser.fixupAndLoadURIString(calendarType.panelSrc, { triggeringPrincipal: this.extension.principal }); }); win.gButtonHandlers.forNodeId["panel-addon-calendar-settings"].accept = calendarType.onCreated; @@ -522,7 +518,7 @@ this.calendar_provider = class extends ExtensionAPI { .getProtocolHandler("resource") .QueryInterface(Ci.nsIResProtocolHandler) .setSubstitution("tb-experiments-calendar", null); - Services.obs.notifyObservers(null, "startupcache-invalidate", null); + Services.obs.notifyObservers(null, "startupcache-invalidate"); } onManifestEntry(entryName) { diff --git a/calendar/experiments/calendar/parent/ext-calendarItemAction.js b/calendar/experiments/calendar/parent/ext-calendarItemAction.js index 28ccec4..5e4df44 100644 --- a/calendar/experiments/calendar/parent/ext-calendarItemAction.js +++ b/calendar/experiments/calendar/parent/ext-calendarItemAction.js @@ -37,7 +37,7 @@ this.calendarItemAction = class extends ToolbarButtonAPI { // TODO this is only necessary in the experiment, can refactor this when moving to core. ExtensionSupport.registerWindowListener("ext-calendar-itemAction-" + this.extension.id, { chromeURLs: ["chrome://calendar/content/calendar-event-dialog.xhtml"], - onLoadWindow: function(win) { + onLoadWindow(win) { let { document } = win; if (!document.getElementById("mainPopupSet")) { diff --git a/calendar/experiments/calendar/parent/ext-calendarItemDetails.js b/calendar/experiments/calendar/parent/ext-calendarItemDetails.js index f2e039a..32c2e4d 100644 --- a/calendar/experiments/calendar/parent/ext-calendarItemDetails.js +++ b/calendar/experiments/calendar/parent/ext-calendarItemDetails.js @@ -2,9 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -var { - ExtensionCommon: { ExtensionAPI, makeWidgetId } -} = ChromeUtils.importESModule("resource://gre/modules/ExtensionCommon.sys.mjs"); +var { ExtensionCommon: { ExtensionAPI, makeWidgetId } } = ChromeUtils.importESModule("resource://gre/modules/ExtensionCommon.sys.mjs"); var { ExtensionSupport } = ChromeUtils.importESModule("resource:///modules/ExtensionSupport.sys.mjs"); @@ -16,7 +14,7 @@ this.calendarItemDetails = class extends ExtensionAPI { if (this.extension.manifest.calendar_item_details) { let panelFrame; if (window.tabmail) { - panelFrame = window.document.getElementById(iframeId|| tabmail.currentTabInfo.iframe?.id); + panelFrame = window.document.getElementById(iframeId || window.tabmail.currentTabInfo.iframe?.id); } else { panelFrame = window.document.getElementById("calendar-item-panel-iframe"); } @@ -45,9 +43,7 @@ this.calendarItemDetails = class extends ExtensionAPI { let loadPromise = setupE10sBrowser(this.extension, browser, tabpanel); return loadPromise.then(() => { - browser.fixupAndLoadURIString(this.extension.manifest.calendar_item_details.default_content, { - triggeringPrincipal: this.extension.principal - }); + browser.fixupAndLoadURIString(this.extension.manifest.calendar_item_details.default_content, { triggeringPrincipal: this.extension.principal }); }); }); }