Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix eslint errors #31

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -17,5 +25,12 @@ module.exports = {
browser: false,
},
},
{
files: ["*/experiments/*/parent/*.js"],
globals: {
global: true,
Services: true,
}
}
]
};
2 changes: 1 addition & 1 deletion NotificationBox/NotificationBox/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down
4 changes: 2 additions & 2 deletions NotificationBox/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions calendar/experiments/calendar/ext-calendar-utils.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
22 changes: 9 additions & 13 deletions calendar/experiments/calendar/parent/ext-calendar-calendars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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;
Expand Down Expand Up @@ -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)));
Expand All @@ -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)
Expand All @@ -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}`);
Expand Down Expand Up @@ -141,15 +137,15 @@ 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}`);
}

cal.manager.unregisterCalendar(calendar);
},
clear: async function(id) {
async clear(id) {
if (!id.endsWith("#cache")) {
throw new ExtensionError("Cannot clear non-cached calendar");
}
Expand Down Expand Up @@ -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)) {
Expand Down
20 changes: 8 additions & 12 deletions calendar/experiments/calendar/parent/ext-calendar-items.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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)];
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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;
}
Expand All @@ -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);
Expand Down
10 changes: 3 additions & 7 deletions calendar/experiments/calendar/parent/ext-calendar-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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");
}
Expand Down Expand Up @@ -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 });
});
});
}
Expand Down