Bug 1534155 - Stop ignoring no-undef linter rule in calendar; r=Fallen
authorGeoff Lankow <geoff@darktrojan.net>
Fri, 15 Mar 2019 11:03:39 +1300
changeset 26095 264e469aa3df
parent 26094 af3e3d4899f5
child 26096 a8263af5473c
push id15666
push usergeoff@darktrojan.net
push dateThu, 14 Mar 2019 22:07:07 +0000
treeherdercomm-central@a8263af5473c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFallen
bugs1534155
Bug 1534155 - Stop ignoring no-undef linter rule in calendar; r=Fallen
.eslintignore
calendar/.eslintrc.js
calendar/base/backend/calBackendLoader.js
calendar/base/backend/icaljs/calDateTime.js
calendar/base/backend/icaljs/calICALJSComponents.js
calendar/base/backend/icaljs/calICSService-worker.js
calendar/base/backend/icaljs/calICSService.js
calendar/base/backend/icaljs/calPeriod.js
calendar/base/backend/icaljs/calRecurrenceRule.js
calendar/base/content/agenda-listbox.js
calendar/base/content/agenda-listbox.xml
calendar/base/content/calendar-base-view.xml
calendar/base/content/calendar-chrome-startup.js
calendar/base/content/calendar-clipboard.js
calendar/base/content/calendar-common-sets.js
calendar/base/content/calendar-dnd-listener.js
calendar/base/content/calendar-extract.js
calendar/base/content/calendar-item-bindings.xml
calendar/base/content/calendar-item-editing.js
calendar/base/content/calendar-management.js
calendar/base/content/calendar-menus.xml
calendar/base/content/calendar-month-view.xml
calendar/base/content/calendar-multiday-view.xml
calendar/base/content/calendar-task-editing.js
calendar/base/content/calendar-task-tree.js
calendar/base/content/calendar-task-tree.xml
calendar/base/content/calendar-task-view.js
calendar/base/content/calendar-ui-utils.js
calendar/base/content/calendar-unifinder-todo.js
calendar/base/content/calendar-unifinder.js
calendar/base/content/calendar-view-core.xml
calendar/base/content/calendar-views.js
calendar/base/content/calendar-views.xml
calendar/base/content/dialogs/calendar-alarm-dialog.js
calendar/base/content/dialogs/calendar-creation.js
calendar/base/content/dialogs/calendar-dialog-utils.js
calendar/base/content/dialogs/calendar-event-dialog-attendees.js
calendar/base/content/dialogs/calendar-event-dialog-attendees.xml
calendar/base/content/dialogs/calendar-event-dialog-freebusy.xml
calendar/base/content/dialogs/calendar-event-dialog-recurrence.js
calendar/base/content/dialogs/calendar-event-dialog-reminder.js
calendar/base/content/dialogs/calendar-event-dialog-timezone.js
calendar/base/content/dialogs/calendar-invitations-dialog.js
calendar/base/content/dialogs/calendar-invitations-list.xml
calendar/base/content/dialogs/calendar-migration-dialog.js
calendar/base/content/dialogs/calendar-print-dialog.js
calendar/base/content/dialogs/calendar-properties-dialog.js
calendar/base/content/dialogs/calendar-summary-dialog.js
calendar/base/content/dialogs/chooseCalendarDialog.js
calendar/base/content/import-export.js
calendar/base/content/preferences/alarms.js
calendar/base/content/preferences/categories.js
calendar/base/content/preferences/general.js
calendar/base/content/preferences/views.js
calendar/base/content/today-pane.js
calendar/base/content/widgets/calendar-alarm-widget.xml
calendar/base/content/widgets/calendar-list-tree.xml
calendar/base/content/widgets/calendar-widgets.xml
calendar/base/content/widgets/minimonth.xml
calendar/base/modules/calUtils.jsm
calendar/base/modules/utils/calACLUtils.jsm
calendar/base/src/calCalendarManager.js
calendar/base/src/calEvent.js
calendar/base/src/calFilter.js
calendar/base/src/calIcsParser.js
calendar/base/src/calItemBase.js
calendar/base/src/calItemModule.js
calendar/base/src/calTimezoneService.js
calendar/base/src/calTodo.js
calendar/import-export/calImportExportModule.js
calendar/import-export/calMonthGridPrinter.js
calendar/itip/calItipEmailTransport.js
calendar/lightning/content/html-item-editing/react-code.js
calendar/lightning/content/imip-bar.js
calendar/lightning/content/lightning-calendar-creation.js
calendar/lightning/content/lightning-calendar-properties.js
calendar/lightning/content/lightning-item-iframe.js
calendar/lightning/content/lightning-item-panel.js
calendar/lightning/content/lightning-utils.js
calendar/lightning/content/messenger-overlay-preferences.js
calendar/lightning/content/messenger-overlay-sidebar.js
calendar/lightning/content/suite-overlay-sidebar.js
calendar/providers/caldav/calDavCalendar.js
calendar/providers/caldav/calDavRequestHandlers.js
calendar/providers/caldav/content/caldav-lightning-calendar-creation.js
calendar/providers/caldav/content/caldav-lightning-calendar-properties.js
calendar/providers/caldav/content/caldav-lightning-utils.js
calendar/providers/composite/calCompositeCalendar.js
calendar/providers/gdata/content/gdata-calendar-creation.js
calendar/providers/gdata/content/gdata-calendar-properties.js
calendar/providers/gdata/content/gdata-event-dialog-reminder.js
calendar/providers/gdata/content/gdata-lightning-item-iframe.js
calendar/providers/gdata/content/gdata-list-tree.xml
calendar/providers/gdata/content/gdata-migration.js
calendar/providers/gdata/modules/gdataRequest.jsm
calendar/providers/gdata/modules/gdataSession.jsm
calendar/providers/gdata/modules/gdataUtils.jsm
calendar/providers/ics/calICSCalendar.js
calendar/providers/memory/calMemoryCalendar.js
calendar/providers/storage/calStorageCalendar.js
calendar/providers/wcap/calWcapCalendar.js
calendar/providers/wcap/calWcapCalendarItems.js
calendar/providers/wcap/calWcapCalendarModule.js
calendar/providers/wcap/calWcapErrors.js
calendar/providers/wcap/calWcapRequest.js
calendar/providers/wcap/calWcapSession.js
calendar/providers/wcap/calWcapUtils.js
calendar/resources/content/datetimepickers/datetimepickers.js
calendar/resources/content/datetimepickers/datetimepickers.xml
calendar/resources/content/mouseoverPreviews.js
calendar/resources/content/publish.js
calendar/resources/content/publishDialog.js
calendar/test/mozmill/.eslintrc.js
calendar/test/mozmill/eventDialog/testEventDialog.js
calendar/test/mozmill/invitations/test-imip-bar-eml.js
calendar/test/mozmill/shared-modules/test-calendar-utils.js
calendar/test/mozmill/shared-modules/test-item-editing-helpers.js
calendar/test/mozmill/testAlarmDefaultValue.js
calendar/test/mozmill/views/testTaskView.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -59,11 +59,13 @@ mail/branding/thunderbird/thunderbird-br
 mail/components/im/all-im.js
 mail/locales/en-US/all-l10n.js
 mail/test/mozmill/**
 
 # calendar/ exclusions
 
 # prefs files
 calendar/lightning/content/lightning.js
+calendar/providers/gdata/defaults/preferences.js
+calendar/timezones/preferences.js
 
 # third party library
 calendar/base/modules/ical.js
--- a/calendar/.eslintrc.js
+++ b/calendar/.eslintrc.js
@@ -290,19 +290,16 @@ module.exports = {
         "no-multi-str": 2,
 
         // Disallow Symbol Constructor
         "no-new-symbol": 2,
 
         // Disallow Initializing to undefined
         "no-undef-init": 2,
 
-        // Don't Disallow Undeclared Variables (for now)
-        "no-undef": 0,
-
         // Disallow control flow statements in finally blocks
         "no-unsafe-finally": 2,
 
         // Disallow Unused Labels
         "no-unused-labels": 2,
 
         // Disallow unnecessary computed property keys on objects
         "no-useless-computed-key": 2,
--- a/calendar/base/backend/calBackendLoader.js
+++ b/calendar/base/backend/calBackendLoader.js
@@ -63,14 +63,14 @@ calBackendLoader.prototype = {
 function lazyFactoryFor(backendScope, classID) {
     return {
         createInstance: function(aOuter, aIID) {
             let realFactory = backendScope.NSGetFactory(classID);
             return realFactory.createInstance(aOuter, aIID);
         },
         lockFactory: function(lock) {
             let realFactory = backendScope.NSGetFactory(classID);
-            return realFactory.lockFactory(aOuter, aIID);
+            return realFactory.lockFactory(lock);
         }
     };
 }
 
 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([calBackendLoader]);
--- a/calendar/base/backend/icaljs/calDateTime.js
+++ b/calendar/base/backend/icaljs/calDateTime.js
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from calICALJSComponents.js */
+
 var { ICAL, unwrap, unwrapSetter } = ChromeUtils.import("resource://calendar/modules/ical.js");
 
 var UNIX_TIME_TO_PRTIME = 1000000;
 
 function calDateTime(innerObject) {
     this.wrappedJSObject = this;
     this.innerObject = innerObject || ICAL.Time.epochTime.clone();
 }
--- a/calendar/base/backend/icaljs/calICALJSComponents.js
+++ b/calendar/base/backend/icaljs/calICALJSComponents.js
@@ -1,12 +1,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from ../../src/calTimezone.js */
+/* import-globals-from calDateTime.js */
+/* import-globals-from calDuration.js */
+/* import-globals-from calICSService.js */
+/* import-globals-from calPeriod.js */
+/* import-globals-from calRecurrenceRule.js */
+
 var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 this.NSGetFactory = (cid) => {
     let scriptLoadOrder = [
         "resource://calendar/calendar-js/calTimezone.js",
         "resource://calendar/calendar-js/calDateTime.js",
         "resource://calendar/calendar-js/calDuration.js",
--- a/calendar/base/backend/icaljs/calICSService-worker.js
+++ b/calendar/base/backend/icaljs/calICSService-worker.js
@@ -1,19 +1,23 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /**
  * ChromeWorker for parseICSAsync method in calICSService.js
  */
 
+/* eslint-env worker */
+/* import-globals-from ../../modules/ical.js */
+
 var NS_OK = 0;
 var NS_ERROR_FAILURE = 2147500037;
 
+// eslint-disable-next-line no-unused-vars
 importScripts("resource://calendar/modules/ical.js");
 
 onmessage = function(event) {
     try {
         let comp = ICAL.parse(event.data);
         postMessage({ rc: NS_OK, data: comp });
     } catch (e) {
         postMessage({ rc: NS_ERROR_FAILURE, data: "Exception occurred: " + e });
--- a/calendar/base/backend/icaljs/calICSService.js
+++ b/calendar/base/backend/icaljs/calICSService.js
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from calICALJSComponents.js */
+
 var { ICAL, unwrapSetter, unwrapSingle, wrapGetter } = ChromeUtils.import("resource://calendar/modules/ical.js");
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 function calIcalProperty(innerObject) {
     this.innerObject = innerObject || new ICAL.Property();
     this.wrappedJSObject = this;
 }
 
@@ -456,17 +458,17 @@ calICSService.prototype = {
             let worker = new ChromeWorker("resource://calendar/calendar-js/calICSService-worker.js");
             worker.onmessage = function(event) {
                 let rc = Cr.NS_ERROR_FAILURE;
                 let icalComp = null;
                 try {
                     rc = event.data.rc;
                     icalComp = new calIcalComponent(new ICAL.Component(event.data.data));
                     if (!Components.isSuccessCode(rc)) {
-                        cal.ERROR("[calICSService] Error in parser worker: " + data);
+                        cal.ERROR("[calICSService] Error in parser worker: " + event.data);
                     }
                 } catch (e) {
                     cal.ERROR("[calICSService] Exception parsing item: " + e);
                 }
 
                 listener.onParsingComplete(rc, icalComp);
             };
             worker.onerror = function(event) {
--- a/calendar/base/backend/icaljs/calPeriod.js
+++ b/calendar/base/backend/icaljs/calPeriod.js
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from calICALJSComponents.js */
+
 var { ICAL, unwrapSetter, wrapGetter } = ChromeUtils.import("resource://calendar/modules/ical.js");
 
 function calPeriod(innerObject) {
     this.innerObject = innerObject || new ICAL.Period({});
     this.wrappedJSObject = this;
 }
 
 calPeriod.prototype = {
--- a/calendar/base/backend/icaljs/calRecurrenceRule.js
+++ b/calendar/base/backend/icaljs/calRecurrenceRule.js
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from calICALJSComponents.js */
+
 var { ICAL, unwrapSetter, unwrapSingle, wrapGetter } = ChromeUtils.import("resource://calendar/modules/ical.js");
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 function calRecurrenceRule(innerObject) {
     this.innerObject = innerObject || new ICAL.Recur();
     this.wrappedJSObject = this;
 }
 
--- a/calendar/base/content/agenda-listbox.js
+++ b/calendar/base/content/agenda-listbox.js
@@ -1,12 +1,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from calendar-common-sets.js */
+/* import-globals-from calendar-item-editing.js */
+/* import-globals-from calendar-management.js */
+/* import-globals-from calendar-ui-utils.js */
+/* import-globals-from calendar-views.js */
+
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 function Synthetic(aHeader, aDuration, aMultiday) {
     this.open = aHeader.getAttribute("checked") == "true";
     this.duration = aDuration;
     this.multiday = aMultiday;
--- a/calendar/base/content/agenda-listbox.xml
+++ b/calendar/base/content/agenda-listbox.xml
@@ -1,13 +1,17 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - 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/. -->
 
+<!-- import-globals-from ../../resources/content/mouseoverPreviews.js -->
+<!-- import-globals-from agenda-listbox.js -->
+<!-- import-globals-from calendar-dnd-listener.js -->
+
 <bindings id="agenda-list-bindings"
           xmlns="http://www.mozilla.org/xbl"
           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
           xmlns:xbl="http://www.mozilla.org/xbl">
 
   <binding id="agenda-base-richlist-item"
            extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
     <implementation>
--- a/calendar/base/content/calendar-base-view.xml
+++ b/calendar/base/content/calendar-base-view.xml
@@ -1,13 +1,15 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - 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/. -->
 
+<!-- import-globals-from calendar-views.js -->
+
 <bindings id="calendar-multiday-view-bindings"
           xmlns="http://www.mozilla.org/xbl"
           xmlns:html="http://www.w3.org/1999/xhtml"
           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
           xmlns:xbl="http://www.mozilla.org/xbl">
 
   <binding id="calendar-base-view">
     <implementation>
@@ -733,16 +735,17 @@
         ]]></body>
       </method>
 
       <method name="getDateList">
         <parameter name="aCount"/>
         <parameter name="aDates"/>
         <body><![CDATA[
             let start = this.startDate.clone();
+            let dates = [];
             while (start.compare(this.endDate) <= 0) {
                 dates.push(start);
                 start.day++;
             }
             aCount.value = dates.length;
             return dates;
         ]]></body>
       </method>
@@ -783,16 +786,17 @@
               case "PageDown":
                   this.moveView(1);
                   break;
           }
       ]]></handler>
       <handler event="wheel"><![CDATA[
           const pixelThreshold = 150;
           if (event.shiftKey && Services.prefs.getBoolPref("calendar.view.mousescroll", true)) {
+              let deltaView = 0;
               if (event.deltaMode == event.DOM_DELTA_LINE) {
                   if (event.deltaY != 0) {
                       deltaView = event.deltaY < 0 ? -1 : 1;
                   }
               } else if (event.deltaMode == event.DOM_DELTA_PIXEL) {
                   this.mPixelScrollDelta += event.deltaY;
                   if (this.mPixelScrollDelta > pixelThreshold) {
                       deltaView = 1;
--- a/calendar/base/content/calendar-chrome-startup.js
+++ b/calendar/base/content/calendar-chrome-startup.js
@@ -1,12 +1,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from ../../lightning/content/messenger-overlay-sidebar.js */
+/* import-globals-from calendar-common-sets.js */
+/* import-globals-from calendar-management.js */
+/* import-globals-from calendar-unifinder-todo.js */
+/* import-globals-from calendar-ui-utils.js */
+/* import-globals-from calendar-views.js */
+
 var { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { AppConstants } = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 /* exported commonInitCalendar, commonFinishCalendar */
 
 /**
  * Common initialization steps for calendar chrome windows.
--- a/calendar/base/content/calendar-clipboard.js
+++ b/calendar/base/content/calendar-clipboard.js
@@ -1,12 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from calendar-common-sets.js */
+/* import-globals-from calendar-item-editing.js */
+/* import-globals-from calendar-management.js */
+/* import-globals-from calendar-views.js */
+
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 /* exported cutToClipboard, pasteFromClipboard */
 
 /**
  * Test if a writable calendar is selected, and if the clipboard has items that
  * can be pasted into Calendar. The data must be of type "text/calendar" or
--- a/calendar/base/content/calendar-common-sets.js
+++ b/calendar/base/content/calendar-common-sets.js
@@ -1,12 +1,24 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from ../../../../toolkit/content/globalOverlay.js */
+/* import-globals-from ../../lightning/content/messenger-overlay-sidebar.js */
+/* import-globals-from ../../resources/content/publish.js */
+/* import-globals-from agenda-listbox.js */
+/* import-globals-from calendar-clipboard.js */
+/* import-globals-from calendar-management.js */
+/* import-globals-from calendar-task-tree.js */
+/* import-globals-from calendar-ui-utils.js */
+/* import-globals-from calendar-unifinder.js */
+/* import-globals-from calendar-views.js */
+/* import-globals-from import-export.js */
+
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 /* exported injectCalendarCommandController, removeCalendarCommandController,
  *          setupContextItemType, minimonthPick, getSelectedItems,
  *          deleteSelectedItems, calendarUpdateNewItemsCommand
  */
 
@@ -444,17 +456,17 @@ var calendarController = {
 
     isCalendarInForeground: function() {
         return gCurrentMode && gCurrentMode != "mail";
     },
 
     isInMode: function(mode) {
         switch (mode) {
             case "mail":
-                return !isCalendarInForeground();
+                return !this.isCalendarInForeground();
             case "calendar":
                 return gCurrentMode && gCurrentMode == "calendar";
             case "task":
                 return gCurrentMode && gCurrentMode == "task";
         }
         return false;
     },
 
--- a/calendar/base/content/calendar-dnd-listener.js
+++ b/calendar/base/content/calendar-dnd-listener.js
@@ -1,12 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from ../../../mail/base/content/nsDragAndDrop.js */
+/* import-globals-from calendar-item-editing.js */
+/* import-globals-from calendar-management.js */
+/* import-globals-from import-export.js */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { AppConstants } = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 /* exported invokeEventDragSession, calendarViewDNDObserver,
  *          calendarMailButtonDNDObserver, calendarCalendarButtonDNDObserver,
  *          calendarTaskButtonDNDObserver
  */
@@ -319,19 +324,21 @@ calDNDBaseObserver.prototype = {
                 try {
                     loader.init(listener);
                     channel.asyncOpen(loader);
                 } catch (e) {
                     cal.ERROR(e);
                 }
                 break;
             }
-            case "text/x-moz-message":
+            case "text/x-moz-message": {
+                let messenger = Cc["@mozilla.org/messenger;1"].createInstance(Ci.nsIMessenger);
                 this.onDropMessage(messenger.msgHdrFromURI(data));
                 break;
+            }
             default:
                 cal.ASSERT(false, "unknown data flavour:" + bestFlavor.value+"\n");
                 break;
         }
     },
 
     onDragStart: function(aEvent, aTransferData, aDragAction) {},
     onDragOver: function(aEvent, aFlavor, aDragSession) {},
--- a/calendar/base/content/calendar-extract.js
+++ b/calendar/base/content/calendar-extract.js
@@ -1,12 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from ../../../mail/base/content/msgMail3PaneWindow.js */
+/* import-globals-from calendar-item-editing.js */
+
 var { Extractor } = ChromeUtils.import("resource://calendar/modules/calExtract.jsm");
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var calendarExtract = {
     onShowLocaleMenu: function(target) {
         let localeList = document.getElementById(target.id);
         let langs = [];
--- a/calendar/base/content/calendar-item-bindings.xml
+++ b/calendar/base/content/calendar-item-bindings.xml
@@ -1,13 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - 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/. -->
 
+<!-- globals cal -->
+
 <!DOCTYPE bindings SYSTEM "chrome://calendar/locale/calendar.dtd">
 
 <bindings id="calendar-item-bindings"
           xmlns="http://www.mozilla.org/xbl"
           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
           xmlns:xbl="http://www.mozilla.org/xbl">
 
   <binding id="item-date-row">
--- a/calendar/base/content/calendar-item-editing.js
+++ b/calendar/base/content/calendar-item-editing.js
@@ -1,12 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from calendar-management.js */
+/* import-globals-from calendar-views.js */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 /* exported modifyEventWithDialog, undo, redo, setContextPartstat */
 
 /**
  * Takes a job and makes sure the dispose function on it is called. If there is
  * no dispose function or the job is null, ignore it.
--- a/calendar/base/content/calendar-management.js
+++ b/calendar/base/content/calendar-management.js
@@ -4,16 +4,20 @@
 
 /* exported promptDeleteCalendar, loadCalendarManager, unloadCalendarManager,
  *         updateSortOrderPref, calendarListTooltipShowing,
  *         calendarListSetupContextMenu, ensureCalendarVisible, toggleCalendarVisible,
  *         showAllCalendars, showOnlyCalendar, openCalendarSubscriptionsDialog,
  *         calendarOfflineManager
  */
 
+/* import-globals-from dialogs/calendar-migration-dialog.js */
+/* import-globals-from calendar-common-sets.js */
+/* import-globals-from calendar-ui-utils.js */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 /**
  * Get this window's currently selected calendar.
  *
  * @return      The currently selected calendar.
  */
--- a/calendar/base/content/calendar-menus.xml
+++ b/calendar/base/content/calendar-menus.xml
@@ -1,13 +1,15 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - 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/. -->
 
+<!-- import-globals-from calendar-task-tree.js -->
+
 <!DOCTYPE bindings SYSTEM "chrome://calendar/locale/calendar.dtd">
 
 <bindings id="calendar-menu-bindings"
           xmlns="http://www.mozilla.org/xbl"
           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
           xmlns:xbl="http://www.mozilla.org/xbl">
 
   <binding id="task-menupopup">
@@ -39,19 +41,20 @@
                 let commandName = item.getAttribute("command");
                 let command = document.getElementById(commandName);
                 if (command) {
                     command.setAttribute("checked", "false");
                     item.setAttribute("checked", "false");
                 }
             }
             let propertyValue;
+            // eslint-disable-next-line no-undef
             if (gTabmail && gTabmail.currentTabInfo.mode.type == "calendarTask") {
                 // We are in a task tab (editing a single task).
-                propertyValue = gConfig[this.mType];
+                propertyValue = gConfig[this.mType]; // eslint-disable-line no-undef
             } else {
                 // We are in the Tasks tab.
                 let tasks = getSelectedTasks();
                 let tasksSelected = (tasks != null) && (tasks.length > 0);
                 if (tasksSelected) {
                     if (tasks.every(task => task[this.mType] == tasks[0][this.mType])) {
                         propertyValue = tasks[0][this.mType];
                     }
--- a/calendar/base/content/calendar-month-view.xml
+++ b/calendar/base/content/calendar-month-view.xml
@@ -1,13 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - 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/. -->
 
+<!-- import-globals-from calendar-views.js -->
+
 <!DOCTYPE bindings SYSTEM "chrome://global/locale/global.dtd" >
 
 <bindings id="calendar-month-view-bindings"
           xmlns="http://www.mozilla.org/xbl"
           xmlns:html="http://www.w3.org/1999/xhtml"
           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
           xmlns:xbl="http://www.mozilla.org/xbl">
 
--- a/calendar/base/content/calendar-multiday-view.xml
+++ b/calendar/base/content/calendar-multiday-view.xml
@@ -1,13 +1,18 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - 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/. -->
 
+<!-- import-globals-from ../../resources/content/mouseoverPreviews.js -->
+<!-- import-globals-from calendar-dnd-listener.js -->
+<!-- import-globals-from calendar-ui-utils.js -->
+<!-- import-globals-from calendar-views.js -->
+
 <!DOCTYPE bindings SYSTEM "chrome://global/locale/global.dtd" >
 
 <bindings id="calendar-multiday-view-bindings"
   xmlns="http://www.mozilla.org/xbl"
   xmlns:html="http://www.w3.org/1999/xhtml"
   xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
   xmlns:xbl="http://www.mozilla.org/xbl">
 
@@ -1459,16 +1464,18 @@
                 }
 
                 window.removeEventListener("mousemove", col.onEventSweepMouseMove);
                 window.removeEventListener("mouseup", col.onEventSweepMouseUp);
                 window.removeEventListener("keypress", col.onEventSweepKeypress);
                 document.calendarEventColumnDragging = null;
                 col.mDragState = null;
 
+                var item = dragState.dragOccurrence;
+
                 // the multiday view currently exhibits a less than optimal strategy
                 // in terms of item selection. items don't get automatically selected
                 // when clicked and dragged, as to differentiate inline editing from
                 // the act of selecting an event. but the application internal drop
                 // targets will ask for selected items in order to pull the data from
                 // the packets. that's why we need to make sure at least the currently
                 // dragged event is contained in the set of selected items.
                 let selectedItems = this.getSelectedItems({});
@@ -2017,30 +2024,30 @@
             return newStart;
         ]]></body>
       </method>
     </implementation>
 
     <handlers>
       <handler event="dblclick" button="0"><![CDATA[
           if (this.calendarView.controller) {
-              let newStart = getClickedDateTime(event);
+              let newStart = this.getClickedDateTime(event);
               this.calendarView.controller.createNewEvent(null, newStart, null);
           }
       ]]></handler>
 
       <handler event="click" button="0"><![CDATA[
           if (!(event.ctrlKey || event.metaKey)) {
               this.calendarView.setSelectedItems(0, []);
               this.focus();
           }
       ]]></handler>
 
       <handler event="click" button="2"><![CDATA[
-          let newStart = getClickedDateTime(event);
+          let newStart = this.getClickedDateTime(event);
           this.calendarView.selectedDateTime = newStart;
       ]]></handler>
 
       <!-- mouse down handler, in empty event column regions.  Starts sweeping out a new
          - event.
         -->
       <handler event="mousedown"><![CDATA[
           // select this column
@@ -2313,21 +2320,21 @@
                 }
             }
 
             // this should be done using lookupMethod(), see bug 286629
             let ret = XULElement.prototype.setAttribute.call(this, aAttr, aVal);
 
             if (needsrelayout) {
                 let eventbox = document.getAnonymousElementByAttribute(this, "anonid", "eventbox");
-                eventbox.setAttribute("orient", val);
+                eventbox.setAttribute("orient", aVal);
                 let gb1 = document.getAnonymousElementByAttribute(this, "anonid", "gripbar1");
-                gb1.parentorient = val;
+                gb1.parentorient = aVal;
                 let gb2 = document.getAnonymousElementByAttribute(this, "anonid", "gripbar2");
-                gb2.parentorient = val;
+                gb2.parentorient = aVal;
             }
 
             return ret;
         ]]></body>
       </method>
 
       <method name="getOptimalMinSize">
         <body><![CDATA[
@@ -2898,17 +2905,17 @@
 
       <method name="getDateList">
         <parameter name="aCount"/>
         <body><![CDATA[
             let dates = [];
             if (this.mStartDate && this.mEndDate) {
                 let date = this.mStartDate.clone();
                 while (date.compare(this.mEndDate) <= 0) {
-                    dates.push(d.clone());
+                    dates.push(date.clone());
                     date.day += 1;
                 }
             } else if (this.mDateList) {
                 for (let date of this.mDateList) {
                     dates.push(date.clone());
                 }
             }
 
--- a/calendar/base/content/calendar-task-editing.js
+++ b/calendar/base/content/calendar-task-editing.js
@@ -1,12 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from calendar-item-editing.js */
+/* import-globals-from calendar-management.js */
+/* import-globals-from calendar-ui-utils.js */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 /**
  * Used by the "quick add" feature for tasks, for example in the task view or
  * the uniinder-todo.
  *
  * NOTE: many of the following methods are called without taskEdit being the
  * |this| object.
--- a/calendar/base/content/calendar-task-tree.js
+++ b/calendar/base/content/calendar-task-tree.js
@@ -3,16 +3,19 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* exported addCalendarNames, calendars, changeContextMenuForTask,
  *          contextChangeTaskCalendar, contextChangeTaskPriority,
  *          contextPostponeTask, modifyTaskFromContext, deleteToDoCommand,
  *          tasksToMail, tasksToEvents, toggleCompleted,
  */
 
+/* import-globals-from calendar-common-sets.js */
+/* import-globals-from calendar-dnd-listener.js */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 /**
  * Add registered calendars to the given menupopup. Removes all previous
  * children.
  *
  * XXX Either replace the existing items using replaceNode, or use helper
  * functions (cal.removeChildren).
--- a/calendar/base/content/calendar-task-tree.xml
+++ b/calendar/base/content/calendar-task-tree.xml
@@ -1,13 +1,18 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - 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/. -->
 
+<!-- import-globals-from agenda-listbox.js -->
+<!-- import-globals-from calendar-common-sets.js -->
+<!-- import-globals-from calendar-dnd-listener.js -->
+<!-- import-globals-from calendar-task-tree.js -->
+
 <!DOCTYPE dialog [
   <!ENTITY % dtd1 SYSTEM "chrome://calendar/locale/global.dtd" > %dtd1;
   <!ENTITY % dtd2 SYSTEM "chrome://calendar/locale/calendar.dtd" > %dtd2;
 ]>
 
 <bindings id="calendar-task-tree-bindings"
           xmlns="http://www.mozilla.org/xbl"
           xmlns:xbl="http://www.mozilla.org/xbl"
--- a/calendar/base/content/calendar-task-view.js
+++ b/calendar/base/content/calendar-task-view.js
@@ -1,14 +1,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported taskDetailsView, sendMailToOrganizer, taskViewCopyLink */
 
+/* import-globals-from ../../../mail/base/content/mailCore.js */
+/* import-globals-from calendar-item-editing.js */
+/* import-globals-from calendar-ui-utils.js */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { recurrenceRule2String } = ChromeUtils.import("resource://calendar/modules/calRecurrenceUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { AppConstants } = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 var taskDetailsView = {
 
     /**
--- a/calendar/base/content/calendar-ui-utils.js
+++ b/calendar/base/content/calendar-ui-utils.js
@@ -7,18 +7,21 @@
  *          enableElementWithLock, uncheckChildNodes, removeChildren,
  *          appendCalendarItems, setAttributeToChildren, checkRadioControl,
  *          processEnableCheckbox, updateListboxDeleteButton,
  *          updateUnitLabelPlural, updateMenuLabelsPlural, menuListSelectItem,
  *          getOptimalMinimumWidth, getOptimalMinimumHeight,
  *          getOtherOrientation, updateSelectedLabel, setupAttendanceMenu
  */
 
+/* import-globals-from ../../../../toolkit/content/globalOverlay.js */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { PluralForm } = ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
+var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 /**
  * Helper function for filling the form,
  * Set the value of a property of a XUL element
  *
  * @param aElement      ID of XUL element to set, or the element node itself
  * @param aNewValue     value to set property to ( if undefined no change is made )
  * @param aPropertyName OPTIONAL name of property to set, default is "value",
--- a/calendar/base/content/calendar-unifinder-todo.js
+++ b/calendar/base/content/calendar-unifinder-todo.js
@@ -1,14 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported prepareCalendarToDoUnifinder, finishCalendarToDoUnifinder */
 
+/* import-globals-from calendar-views.js */
+
 /**
  * Called when the window is loaded to set up the unifinder-todo.
  */
 function prepareCalendarToDoUnifinder() {
     // add listener to update the date filters
     getViewDeck().addEventListener("dayselect", updateCalendarToDoUnifinder);
 
     updateCalendarToDoUnifinder();
--- a/calendar/base/content/calendar-unifinder.js
+++ b/calendar/base/content/calendar-unifinder.js
@@ -1,16 +1,22 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported gCalendarEventTreeClicked, unifinderDoubleClick, unifinderKeyPress,
  *          focusSearch, toggleUnifinder
  */
 
+/* import-globals-from ../../../mail/base/content/utilityOverlay.js */
+/* import-globals-from ../../resources/content/mouseoverPreviews.js */
+/* import-globals-from ../src/calFilter.js */
+/* import-globals-from calendar-common-sets.js */
+/* import-globals-from calendar-views.js */
+
 /**
  * U N I F I N D E R
  *
  * This is a hacked in interface to the unifinder. We will need to
  * improve this to make it usable in general.
  *
  * NOTE: Including this file will cause a load handler to be added to the
  * window.
--- a/calendar/base/content/calendar-view-core.xml
+++ b/calendar/base/content/calendar-view-core.xml
@@ -1,13 +1,17 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - 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/. -->
 
+<!-- import-globals-from ../../resources/content/mouseoverPreviews.js -->
+<!-- import-globals-from calendar-dnd-listener.js -->
+<!-- import-globals-from calendar-views.js -->
+
 <bindings id="calendar-core-view-bindings"
           xmlns="http://www.mozilla.org/xbl"
           xmlns:html="http://www.w3.org/1999/xhtml"
           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
           xmlns:xbl="http://www.mozilla.org/xbl">
 
   <binding id="calendar-editable-item">
     <content mousethrough="never"
--- a/calendar/base/content/calendar-views.js
+++ b/calendar/base/content/calendar-views.js
@@ -4,16 +4,19 @@
 
 /* exported switchToView, getSelectedDay, scheduleMidnightUpdate,
  *          updateStyleSheetForViews, observeViewDaySelect, toggleOrientation,
  *          toggleWorkdaysOnly, toggleTasksInView, toggleShowCompletedInView,
  *          goToDate, getLastCalendarView, deleteSelectedEvents,
  *          editSelectedEvents, selectAllEvents
  */
 
+/* import-globals-from calendar-chrome-startup.js */
+/* import-globals-from calendar-item-editing.js */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { countOccurrences } = ChromeUtils.import("resource://calendar/modules/calRecurrenceUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 /**
  * Controller for the views
  * @see calIcalendarViewController
  */
@@ -147,17 +150,17 @@ var calendarViewController = {
                     // The user canceled the dialog, bail out
                     break;
                 }
                 itemToDelete = targetItem;
 
                 // if we have multiple items and the user decided already for one
                 // item whether to delete the occurrence or the entire series,
                 // we apply that decission also to subsequent items
-                previoiusResponse = response;
+                previousResponse = response;
                 promptUser = false;
             }
 
             // Now some dirty work: Make sure more than one occurrence can be
             // deleted by saving the recurring items and removing occurrences as
             // they come in. If this is not an occurrence, we can go ahead and
             // delete the whole item.
             if (itemToDelete.parentItem.hashId == itemToDelete.hashId) {
--- a/calendar/base/content/calendar-views.xml
+++ b/calendar/base/content/calendar-views.xml
@@ -1,13 +1,15 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - 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/. -->
 
+<!-- import-globals-from calendar-views.js -->
+
 <bindings id="calendar-specific-view-bindings"
           xmlns="http://www.mozilla.org/xbl"
           xmlns:html="http://www.w3.org/1999/xhtml"
           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
           xmlns:xbl="http://www.mozilla.org/xbl">
 
   <binding id="calendar-day-view"
            extends="chrome://calendar/content/calendar-multiday-view.xml#calendar-multiday-view">
--- a/calendar/base/content/dialogs/calendar-alarm-dialog.js
+++ b/calendar/base/content/dialogs/calendar-alarm-dialog.js
@@ -1,16 +1,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported onDismissAllAlarms, setupWindow, finishWindow, addWidgetFor,
  *         removeWidgetFor, onSelectAlarm, ensureCalendarVisible
  */
 
+/* import-globals-from ../calendar-item-editing.js */
+
 var { PluralForm } = ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 addEventListener("DOMContentLoaded", () => {
     document.getElementById("alarm-snooze-all-popup").addEventListener("snooze", (event) => {
         snoozeAllItems(event.detail);
     });
--- a/calendar/base/content/dialogs/calendar-creation.js
+++ b/calendar/base/content/dialogs/calendar-creation.js
@@ -20,20 +20,20 @@ function openLocalCalendar() {
     picker.appendFilters(nsIFilePicker.filterAll);
 
     picker.open(rv => {
         if (rv != nsIFilePicker.returnOK || !picker.file) {
             return;
         }
         let calMgr = cal.getCalendarManager();
         let calendars = calMgr.getCalendars({});
-        if (calendars.some(x => x.uri == picker.fileURL)) {
+        let calendar = calendars.find(x => x.uri == picker.fileURL);
+        if (calendar) {
             // The calendar already exists, select it and return.
-            document.getElementById("calendar-list-tree-widget")
-                    .tree.view.selection.select(index);
+            document.getElementById("calendar-list-tree-widget").selectCalendarById(calendar.id);
             return;
         }
 
         let openCalendar = calMgr.createCalendar("ics", picker.fileURL);
 
         // Strip ".ics" from filename for use as calendar name, taken from
         // calendarCreation.js
         let fullPathRegex = new RegExp("([^/:]+)[.]ics$");
--- a/calendar/base/content/dialogs/calendar-dialog-utils.js
+++ b/calendar/base/content/dialogs/calendar-dialog-utils.js
@@ -3,16 +3,19 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* exported gInTab, gMainWindow, gTabmail, intializeTabOrWindowVariables,
  *          dispose, setDialogId, loadReminders, saveReminder,
  *          commonUpdateReminder, updateLink, rearrangeAttendees,
  *          adaptScheduleAgent
  */
 
+/* import-globals-from ../../../lightning/content/lightning-item-iframe.js */
+/* import-globals-from ../calendar-ui-utils.js */
+
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 // Variables related to whether we are in a tab or a window dialog.
 var gInTab = false;
 var gMainWindow = null;
 var gTabmail = null;
--- a/calendar/base/content/dialogs/calendar-event-dialog-attendees.js
+++ b/calendar/base/content/dialogs/calendar-event-dialog-attendees.js
@@ -462,17 +462,17 @@ function editEndTimezone() {
     let tzStart = document.getElementById("timezone-endtime");
     if (tzStart.hasAttribute("disabled")) {
         return;
     }
 
     let self = this;
     let args = {};
     args.calendar = window.arguments[0].calendar;
-    args.time = gEndTime.getInTimezone(gEndTimezone);
+    args.time = gEndDate.getInTimezone(gEndTimezone);
     args.onOk = function(datetime) {
         if (gStartTimezone && gEndTimezone &&
             cal.data.compareObjects(gStartTimezone, gEndTimezone)) {
             gStartTimezone = datetime.timezone;
         }
         gEndTimezone = datetime.timezone;
         self.propagateDateTime();
     };
--- a/calendar/base/content/dialogs/calendar-event-dialog-attendees.xml
+++ b/calendar/base/content/dialogs/calendar-event-dialog-attendees.xml
@@ -1,13 +1,16 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - 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/. -->
 
+<!-- import-globals-from ../calendar-ui-utils.js -->
+<!-- import-globals-from calendar-event-dialog-attendees.js -->
+
 <!DOCTYPE dialog [
   <!ENTITY % dtd1 SYSTEM "chrome://calendar/locale/global.dtd" > %dtd1;
   <!ENTITY % dtd2 SYSTEM "chrome://calendar/locale/calendar.dtd" > %dtd2;
   <!ENTITY % dtd3 SYSTEM "chrome://calendar/locale/calendar-event-dialog.dtd"> %dtd3;
 ]>
 
 <bindings xmlns="http://www.mozilla.org/xbl"
           xmlns:xbl="http://www.mozilla.org/xbl"
@@ -1382,17 +1385,17 @@
 
       <handler event="mousemove"><![CDATA[
           let mouseX = event.screenX;
           if (this.mDragState == 1) {
               // Move the startdate and the enddate
               let delta = mouseX - this.mMouseX;
               let newStart = this.moveTime(this.mStartDate, delta, false);
               if (newStart.compare(this.mStartDate) != 0) {
-                  newEnd = this.moveTime(this.mEndDate, delta, false);
+                  let newEnd = this.moveTime(this.mEndDate, delta, false);
 
                   // We need to adapt this date in case we're dealing with
                   // an all-day event. This is because setting 'endDate' will
                   // automatically add one day extra for all-day events.
                   if (newEnd.isDate) {
                       newEnd.day--;
                   }
 
--- a/calendar/base/content/dialogs/calendar-event-dialog-freebusy.xml
+++ b/calendar/base/content/dialogs/calendar-event-dialog-freebusy.xml
@@ -1,13 +1,16 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - 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/. -->
 
+<!-- import-globals-from ../calendar-ui-utils.js -->
+<!-- import-globals-from calendar-event-dialog-attendees.js -->
+
 <!DOCTYPE dialog [
   <!ENTITY % dtd1 SYSTEM "chrome://calendar/locale/global.dtd" > %dtd1;
   <!ENTITY % dtd2 SYSTEM "chrome://calendar/locale/calendar.dtd" > %dtd2;
   <!ENTITY % dtd3 SYSTEM "chrome://calendar/locale/calendar-event-dialog.dtd" > %dtd3;
 ]>
 
 <bindings xmlns="http://www.mozilla.org/xbl"
           xmlns:xbl="http://www.mozilla.org/xbl"
--- a/calendar/base/content/dialogs/calendar-event-dialog-recurrence.js
+++ b/calendar/base/content/dialogs/calendar-event-dialog-recurrence.js
@@ -1,14 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported onLoad, onAccept, onCancel */
 
+/* import-globals-from ../calendar-ui-utils.js */
+
 var { splitRecurrenceRules } = ChromeUtils.import("resource://calendar/modules/calRecurrenceUtils.jsm");
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var gIsReadOnly = false;
 var gStartTime = null;
 var gEndTime = null;
 var gUntilDate = null;
--- a/calendar/base/content/dialogs/calendar-event-dialog-reminder.js
+++ b/calendar/base/content/dialogs/calendar-event-dialog-reminder.js
@@ -1,16 +1,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported onLoad, onReminderSelected, updateReminder, onNewReminder,
  *          onRemoveReminder, onAccept, onCancel
  */
 
+/* import-globals-from ../calendar-ui-utils.js */
+
 var { PluralForm } = ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 var allowedActionsMap = {};
 var suppressListUpdate = false;
 
--- a/calendar/base/content/dialogs/calendar-event-dialog-timezone.js
+++ b/calendar/base/content/dialogs/calendar-event-dialog-timezone.js
@@ -1,14 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported onLoad, onAccept, onCancel */
 
+/* import-globals-from ../calendar-ui-utils.js */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 /**
  * Sets up the timezone dialog from the window arguments, also setting up all
  * dialog controls from the window's dates.
  */
 function onLoad() {
     let args = window.arguments[0];
--- a/calendar/base/content/dialogs/calendar-invitations-dialog.js
+++ b/calendar/base/content/dialogs/calendar-invitations-dialog.js
@@ -1,14 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported onLoad, onUnload, onAccept, onCancel */
 
+/* globals invitationsText */// From calendar-invitations-dialog.xul.
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 /**
  * Sets up the invitations dialog from the window arguments, retrieves the
  * invitations from the invitations manager.
  */
 function onLoad() {
     let operationListener = {
--- a/calendar/base/content/dialogs/calendar-invitations-list.xml
+++ b/calendar/base/content/dialogs/calendar-invitations-list.xml
@@ -1,13 +1,15 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - 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/. -->
 
+<!-- import-globals-from calendar-invitations-dialog.js -->
+
 <!DOCTYPE dialog [
   <!ENTITY % dtd1 SYSTEM "chrome://calendar/locale/calendar-invitations-dialog.dtd" >  %dtd1;
 ]>
 
 <bindings id="calendar-invitations-list-bindings"
           xmlns="http://www.mozilla.org/xbl"
           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
           xmlns:xbl="http://www.mozilla.org/xbl">
--- a/calendar/base/content/dialogs/calendar-migration-dialog.js
+++ b/calendar/base/content/dialogs/calendar-migration-dialog.js
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from ../import-export.js */
+
 var FIREFOX_UID = "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { AppConstants } = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 //
 // The front-end wizard bits.
--- a/calendar/base/content/dialogs/calendar-print-dialog.js
+++ b/calendar/base/content/dialogs/calendar-print-dialog.js
@@ -1,14 +1,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported loadCalendarPrintDialog, printAndClose, onDatePick */
 
+/* import-globals-from ../../../../../toolkit/components/printing/content/printUtils.js */
+/* import-globals-from ../calendar-ui-utils.js */
+
+var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 var printContent = "";
 
 /**
  * Gets the calendar view from the opening window
  */
 function getCalendarView() {
@@ -138,17 +142,17 @@ function getPrintSettings(receiverFunc) 
         let listener = {
             QueryInterface: ChromeUtils.generateQI([Ci.calIOperationListener]),
             onOperationComplete: function(aCalendar, aStatus, aOperationType, aId, aDateTime) {
                 receiverFunc(settings);
             },
             onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
                 settings.eventList = settings.eventList.concat(aItems);
                 if (!settings.printTasksWithNoDueDate) {
-                    eventWithDueDate = [];
+                    let eventWithDueDate = [];
                     for (let item of settings.eventList) {
                         if (item.dueDate || item.endDate) {
                             eventWithDueDate.push(item);
                         }
                     }
                     settings.eventList = eventWithDueDate;
                 }
             }
--- a/calendar/base/content/dialogs/calendar-properties-dialog.js
+++ b/calendar/base/content/dialogs/calendar-properties-dialog.js
@@ -1,14 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported onLoad, onAcceptDialog, unsubscribeCalendar */
 
+/* import-globals-from ../calendar-ui-utils.js */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { PluralForm } = ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
 
 /**
  * The calendar to modify, is retrieved from window.arguments[0].calendar
  */
 var gCalendar;
 
--- a/calendar/base/content/dialogs/calendar-summary-dialog.js
+++ b/calendar/base/content/dialogs/calendar-summary-dialog.js
@@ -1,16 +1,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported onLoad, onUnload, onAccept, onCancel, updatePartStat, browseDocument,
  *          sendMailToOrganizer, openAttachment, reply
  */
 
+/* import-globals-from ../../src/calApplicationUtils.js */
+/* import-globals-from calendar-dialog-utils.js */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { recurrenceRule2String } = ChromeUtils.import("resource://calendar/modules/calRecurrenceUtils.jsm");
 
 /**
  * Sets up the summary dialog, setting all needed fields on the dialog from the
  * item received in the window arguments.
  */
 function onLoad() {
@@ -224,27 +227,27 @@ function onLoad() {
     let accept = document.documentElement.getButton("accept");
     let cancel = document.documentElement.getButton("cancel");
     accept.setAttribute("collapsed", "true");
     cancel.setAttribute("collapsed", "true");
     cancel.parentNode.setAttribute("collapsed", "true");
 
     updateToolbar();
 
-    if (typeof ToolbarIconColor !== "undefined") {
-        ToolbarIconColor.init();
+    if (typeof window.ToolbarIconColor !== "undefined") {
+        window.ToolbarIconColor.init();
     }
 
     window.focus();
     opener.setCursor("auto");
 }
 
 function onUnload() {
-    if (typeof ToolbarIconColor !== "undefined") {
-        ToolbarIconColor.uninit();
+    if (typeof window.ToolbarIconColor !== "undefined") {
+        window.ToolbarIconColor.uninit();
     }
 }
 
 /**
  * Saves any changed information to the item.
  *
  * @return      Returns true if the dialog
  */
--- a/calendar/base/content/dialogs/chooseCalendarDialog.js
+++ b/calendar/base/content/dialogs/chooseCalendarDialog.js
@@ -1,13 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported loadCalendars, doOK, doExtra1 */
+
+/* import-globals-from ../calendar-ui-utils.js */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 function loadCalendars() {
     const calendarManager = Cc["@mozilla.org/calendar/manager;1"]
                               .getService(Ci.calICalendarManager);
     let listbox = document.getElementById("calendar-list");
     let composite = cal.view.getCompositeCalendar(window.opener);
     let selectedIndex = 0;
--- a/calendar/base/content/import-export.js
+++ b/calendar/base/content/import-export.js
@@ -1,12 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from calendar-item-editing.js */
+
+var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 /* exported loadEventsFromFile, exportEntireCalendar */
 
 // File constants copied from file-utils.js
 var MODE_RDONLY = 0x01;
 var MODE_WRONLY = 0x02;
 var MODE_CREATE = 0x08;
--- a/calendar/base/content/preferences/alarms.js
+++ b/calendar/base/content/preferences/alarms.js
@@ -1,14 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported gAlarmsPane */
 
+/* import-globals-from ../../../lightning/content/messenger-overlay-preferences.js */
+
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 Preferences.addAll([
     { id: "calendar.alarms.playsound", type: "bool" },
     { id: "calendar.alarms.soundURL", type: "string" },
     { id: "calendar.alarms.show", type: "bool" },
     { id: "calendar.alarms.showmissed", type: "bool" },
     { id: "calendar.alarms.onforevents", type: "int" },
--- a/calendar/base/content/preferences/categories.js
+++ b/calendar/base/content/preferences/categories.js
@@ -1,14 +1,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported gCategoriesPane */
 
+/* import-globals-from ../../../lightning/content/messenger-overlay-preferences.js */
+// From categories.xul.
+/* globals noneLabel, newTitle, editTitle, overwrite, overwriteTitle, noBlankCategories */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { AppConstants } = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 Preferences.add({ id: "calendar.categories.names", type: "string" });
 
 var gCategoryList;
 var categoryPrefBranch = Services.prefs.getBranch("calendar.category.color.");
--- a/calendar/base/content/preferences/general.js
+++ b/calendar/base/content/preferences/general.js
@@ -1,14 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported gCalendarGeneralPane */
 
+/* import-globals-from ../../../lightning/content/messenger-overlay-preferences.js */
+/* globals labelLong, labelShort */// From general.xul.
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 Preferences.addAll([
     { id: "calendar.date.format", type: "int" },
     { id: "calendar.event.defaultlength", type: "int" },
     { id: "calendar.timezone.local", type: "string" },
     { id: "calendar.task.defaultstart", type: "string" },
     { id: "calendar.task.defaultstartoffset", type: "int" },
--- a/calendar/base/content/preferences/views.js
+++ b/calendar/base/content/preferences/views.js
@@ -1,14 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported gViewsPane */
 
+/* import-globals-from ../../../lightning/content/messenger-overlay-preferences.js */
+
 Preferences.addAll([
     { id: "calendar.week.start", type: "int" },
     { id: "calendar.view-minimonth.showWeekNumber", type: "bool" },
     { id: "calendar.week.d0sundaysoff", type: "bool", inverted: "true" },
     { id: "calendar.week.d1mondaysoff", type: "bool", inverted: "true" },
     { id: "calendar.week.d2tuesdaysoff", type: "bool", inverted: "true" },
     { id: "calendar.week.d3wednesdaysoff", type: "bool", inverted: "true" },
     { id: "calendar.week.d4thursdaysoff", type: "bool", inverted: "true" },
--- a/calendar/base/content/today-pane.js
+++ b/calendar/base/content/today-pane.js
@@ -1,12 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from ../../lightning/content/messenger-overlay-sidebar.js */
+/* import-globals-from agenda-listbox.js */
+/* import-globals-from calendar-chrome-startup.js */
+/* import-globals-from calendar-unifinder-todo.js */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 /**
  * Namespace object to hold functions related to the today pane.
  */
 var TodayPane = {
     paneViews: null,
     start: null,
--- a/calendar/base/content/widgets/calendar-alarm-widget.xml
+++ b/calendar/base/content/widgets/calendar-alarm-widget.xml
@@ -1,13 +1,15 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - 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/. -->
 
+<!-- globals cal -->
+
 <!DOCTYPE bindings
 [
   <!ENTITY % dtd1 SYSTEM "chrome://calendar/locale/global.dtd" > %dtd1;
   <!ENTITY % dtd2 SYSTEM "chrome://calendar/locale/calendar.dtd" > %dtd2;
 ]>
 
 <bindings id="calendar-alarms"
           xmlns="http://www.mozilla.org/xbl"
@@ -276,17 +278,17 @@
               }
           } else {
               selectedIndex = 0; // Minutes
           }
 
           unitList.selectedIndex = selectedIndex;
           unitValue.value = snoozePref;
 
-          updateAccessibleName();
+          this.updateAccessibleName();
       ]]></constructor>
 
       <method name="snoozeAlarm">
         <parameter name="minutes"/>
         <body><![CDATA[
             let snoozeEvent = document.createEvent("Events");
             snoozeEvent.initEvent("snooze", true, false);
             snoozeEvent.detail = minutes;
@@ -323,16 +325,18 @@
             let unitPopup = document.getAnonymousElementByAttribute(this, "anonid", "snooze-unit-menupopup");
             let unitValue = document.getAnonymousElementByAttribute(this, "anonid", "snooze-value-textbox");
             let okButton = document.getAnonymousElementByAttribute(this, "anonid", "snooze-popup-ok");
 
             function unitName(list) {
                 return { 1: "unitMinutes", 60: "unitHours", 1440: "unitDays" }[list.value] || "unitMinutes";
             }
 
+            let { PluralForm } = ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
+
             let pluralString = cal.l10n.getCalString(unitName(unitList));
             let unitPlural = PluralForm.get(unitValue.value, pluralString)
                                        .replace("#1", unitValue.value);
 
             let accessibleString = cal.l10n.getString("calendar-alarms",
                                                       "reminderSnoozeOkA11y",
                                                       [unitPlural]);
             okButton.setAttribute("aria-label", accessibleString);
--- a/calendar/base/content/widgets/calendar-list-tree.xml
+++ b/calendar/base/content/widgets/calendar-list-tree.xml
@@ -1,13 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - 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/. -->
 
+<!-- import-globals-from ../calendar-common-sets.js -->
+<!-- import-globals-from ../calendar-views.js -->
+
 <!DOCTYPE bindings SYSTEM "chrome://calendar/locale/calendar.dtd">
 
 <bindings id="calendar-list-tree-bindings"
           xmlns="http://www.mozilla.org/xbl"
           xmlns:xbl="http://www.mozilla.org/xbl"
           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <binding id="full-calendar-list-tree" extends="#calendar-list-tree">
     <!--
--- a/calendar/base/content/widgets/calendar-widgets.xml
+++ b/calendar/base/content/widgets/calendar-widgets.xml
@@ -1,12 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - 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/. -->
+
+<!-- import-globals-from ../calendar-ui-utils.js -->
+<!-- import-globals-from ../calendar-views.js -->
+
 <!DOCTYPE dialog [
   <!ENTITY % dtd1 SYSTEM "chrome://global/locale/global.dtd" > %dtd1;
   <!ENTITY % dtd2 SYSTEM "chrome://calendar/locale/calendar-event-dialog.dtd"> %dtd2;
 ]>
 
 <bindings id="calendar-widgets"
           xmlns="http://www.mozilla.org/xbl"
           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
@@ -379,18 +383,18 @@
     <handlers>
       <handler event="dragstart" phase="capturing"><![CDATA[
           let draggedDOMNode = event.target;
           if (!draggedDOMNode || draggedDOMNode.parentNode != this) {
               return;
           }
           let item = draggedDOMNode.occurrence.clone();
           let beginMoveDate = draggedDOMNode.mParentBox.date;
-          let itemStartDate = (item.startDate || item.entryDate || item.dueDate).getInTimezone(calendarView.mTimezone);
-          let itemEndDate = (item.endDate || item.dueDate || item.entryDate).getInTimezone(calendarView.mTimezone);
+          let itemStartDate = (item.startDate || item.entryDate || item.dueDate).getInTimezone(this.calendarView.mTimezone);
+          let itemEndDate = (item.endDate || item.dueDate || item.entryDate).getInTimezone(this.calendarView.mTimezone);
           let oneMoreDay = (itemEndDate.hour > 0 || itemEndDate.minute > 0);
           itemStartDate.isDate = true;
           itemEndDate.isDate = true;
           let offsetDuration = itemStartDate.subtractDate(beginMoveDate);
           let lenDuration = itemEndDate.subtractDate(itemStartDate);
           let len = lenDuration.weeks * 7 + lenDuration.days;
           this.calendarView.mShadowOffset = offsetDuration;
           this.calendarView.mDropShadowsLength = oneMoreDay ? len + 1 : len;
--- a/calendar/base/content/widgets/minimonth.xml
+++ b/calendar/base/content/widgets/minimonth.xml
@@ -22,16 +22,18 @@
    bugs that occur when minimonth is displayed in a popup (as in datepicker):
      Currently (2005.3)
        whenever a child popup is hidden, the parent popup needs to be reshown.
          Use onpopuplisthidden to reshow parent popop (hidePopup, openPopup).
        When title month or year changes, parent popup may need to be reshown.
          Use onmonthchange to reshow parent popop (hidePopup, openPopup).
 -->
 
+<!-- import-globals-from ../calendar-ui-utils.js -->
+
 <!DOCTYPE bindings
 [
     <!ENTITY % dtd1 SYSTEM "chrome://calendar/locale/global.dtd" > %dtd1;
     <!ENTITY % dtd2 SYSTEM "chrome://global/locale/global.dtd" > %dtd2;
 ]>
 
 <bindings id="xulMiniMonth"
           xmlns="http://www.mozilla.org/xbl"
--- a/calendar/base/modules/calUtils.jsm
+++ b/calendar/base/modules/calUtils.jsm
@@ -204,17 +204,17 @@ var cal = {
      * Generate a ClassInfo implementation for a component. The returned object
      * must be assigned to the 'classInfo' property of a JS object. The first and
      * only argument should be an object that contains a number of optional
      * properties: "interfaces", "contractID", "classDescription", "classID" and
      * "flags". The values of the properties will be returned as the values of the
      * various properties of the nsIClassInfo implementation.
      */
     generateCI: function(classInfo) {
-        if (QueryInterface in classInfo) {
+        if ("QueryInterface" in classInfo) {
             throw Error("In generateCI, don't use a component for generating classInfo");
         }
         /* Note that Ci[Ci.x] == Ci.x for all x */
         let _interfaces = [];
         for (let i = 0; i < classInfo.interfaces.length; i++) {
             let iface = classInfo.interfaces[i];
             if (Ci[iface]) {
                 _interfaces.push(Ci[iface]);
--- a/calendar/base/modules/utils/calACLUtils.jsm
+++ b/calendar/base/modules/utils/calACLUtils.jsm
@@ -76,11 +76,11 @@ var calacl = {
      *
      * @param aItem         The calendar item to check
      * @return              True if the invitation w.r.t. the item can be
      *                        responded to.
      */
     userCanRespondToInvitation: function(aItem) {
         let aclEntry = aItem.aclEntry;
         // TODO check if || is really wanted here
-        return aclUtils.userCanModifyItem(aItem) || aclEntry.userCanRespond;
+        return calacl.userCanModifyItem(aItem) || aclEntry.userCanRespond;
     }
 };
--- a/calendar/base/src/calCalendarManager.js
+++ b/calendar/base/src/calCalendarManager.js
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from calItemModule.js */
+
 var { AddonManager } = ChromeUtils.import("resource://gre/modules/AddonManager.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { Preferences } = ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 var REGISTRY_BRANCH = "calendar.registry.";
 var DB_SCHEMA_VERSION = 10;
 var MAX_INT = Math.pow(2, 31) - 1;
--- a/calendar/base/src/calEvent.js
+++ b/calendar/base/src/calEvent.js
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from calItemModule.js */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 //
 // constructor
 //
 function calEvent() {
     this.initItemBase();
 
--- a/calendar/base/src/calFilter.js
+++ b/calendar/base/src/calFilter.js
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from ../content/calendar-views.js */
+
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 /**
  * Object that contains a set of filter properties that may be used by a calFilter object
  * to filter a set of items.
  * Supported filter properties:
  *   start, end:   Specifies the relative date range to use when calculating the filter date
@@ -323,17 +325,17 @@ calFilter.prototype = {
      * Returns the filter name that a set of filter properties were previously defined as.
      *
      * @param aFilterProperties   The filter properties previously defined.
      * @return                    The name of the first filter name that the properties
      *                            were defined as, or null if the filter properties were
      *                            not previously defined.
      */
     getDefinedFilterName: function(aFilterProperties) {
-        for (filter in this.mDefinedFilters) {
+        for (let filter in this.mDefinedFilters) {
             if (this.mDefinedFilters[filter].equals(aFilterProperties)) {
                 return filter;
             }
         }
         return null;
     },
 
     /**
--- a/calendar/base/src/calIcsParser.js
+++ b/calendar/base/src/calIcsParser.js
@@ -1,14 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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 { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
+var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 function calIcsParser() {
     this.wrappedJSObject = this;
     this.mItems = [];
     this.mParentlessItems = [];
     this.mComponents = [];
     this.mProperties = [];
 }
--- a/calendar/base/src/calItemBase.js
+++ b/calendar/base/src/calItemBase.js
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from calItemModule.js */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 /**
  * calItemBase prototype definition
  *
  * @implements calIItemBase
  * @constructor
  */
--- a/calendar/base/src/calItemModule.js
+++ b/calendar/base/src/calItemModule.js
@@ -1,12 +1,37 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from calItemBase.js */
+/* import-globals-from calCachedCalendar.js */
+/* import-globals-from calAlarm.js */
+/* import-globals-from calAlarmMonitor.js */
+/* import-globals-from calAlarmService.js */
+/* import-globals-from calAttendee.js */
+/* import-globals-from calAttachment.js */
+/* import-globals-from calCalendarManager.js */
+/* import-globals-from calCalendarSearchService.js */
+/* import-globals-from calDateTimeFormatter.js */
+/* import-globals-from calDeletedItems.js */
+/* import-globals-from calEvent.js */
+/* import-globals-from calFreeBusyService.js */
+/* import-globals-from calIcsParser.js */
+/* import-globals-from calIcsSerializer.js */
+/* import-globals-from calItipItem.js */
+/* import-globals-from calProtocolHandler.js */
+/* import-globals-from calRecurrenceDate.js */
+/* import-globals-from calRecurrenceInfo.js */
+/* import-globals-from calRelation.js */
+/* import-globals-from calStartupService.js */
+/* import-globals-from calTransactionManager.js */
+/* import-globals-from calTodo.js */
+/* import-globals-from calWeekInfoService.js */
+
 var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 this.NSGetFactory = (cid) => {
     let scriptLoadOrder = [
         "resource://calendar/calendar-js/calItemBase.js",
         "resource://calendar/calendar-js/calCachedCalendar.js",
 
--- a/calendar/base/src/calTimezoneService.js
+++ b/calendar/base/src/calTimezoneService.js
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from calTimezone.js */
+
 var { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { ICAL, unwrapSingle } = ChromeUtils.import("resource://calendar/modules/ical.js");
 
 function calStringEnumerator(stringArray) {
@@ -470,17 +472,17 @@ function guessSystemTimezone() {
             // Must examine UNTIL date (not next daylight start) because
             // some zones (e.g., Arizona, Hawaii) may stop using daylight
             // time, so there might not be a next daylight start.
             let rrule = period.getFirstProperty("RRULE");
             if (rrule) {
                 let match = untilRegex.exec(rrule.valueAsIcalString);
                 if (match) {
                     periodUntilCalDate.icalString = match[1];
-                    if (todayUTC.nativeTime > periodUntilDate.nativeTime) {
+                    if (todayUTC.nativeTime > periodUntilCalDate.nativeTime) {
                         continue; // period ends too early
                     }
                 } // else forever rule
             } // else no daylight rule
 
             // found period that covers today.
             if (!isForNextTransitionDate) {
                 return period;
--- a/calendar/base/src/calTodo.js
+++ b/calendar/base/src/calTodo.js
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from calItemModule.js */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 //
 // constructor
 //
 function calTodo() {
     this.initItemBase();
 
--- a/calendar/import-export/calImportExportModule.js
+++ b/calendar/import-export/calImportExportModule.js
@@ -1,12 +1,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from calIcsImportExport.js */
+/* import-globals-from calHtmlExport.js */
+/* import-globals-from calOutlookCSVImportExport.js */
+/* import-globals-from calListFormatter.js */
+/* import-globals-from calMonthGridPrinter.js */
+/* import-globals-from calWeekPrinter.js */
+
 var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 this.NSGetFactory = (cid) => {
     let scriptLoadOrder = [
         "resource://calendar/calendar-js/calIcsImportExport.js",
         "resource://calendar/calendar-js/calHtmlExport.js",
         "resource://calendar/calendar-js/calOutlookCSVImportExport.js",
--- a/calendar/import-export/calMonthGridPrinter.js
+++ b/calendar/import-export/calMonthGridPrinter.js
@@ -116,17 +116,17 @@ calMonthPrinter.prototype = {
         // Copy end date, which is exclusive. For our calculations, we will
         // only be handling dates and the formatToHtml() code is much cleaner with
         // the range being inclusive.
         let endDate = aEnd.clone();
         endDate.isDate = true;
 
         // Find out if the end date is also shown in the last week of the
         // previous month. This also means we can spare a month printout.
-        lastDayOfPreviousMonth = endDate.clone();
+        let lastDayOfPreviousMonth = endDate.clone();
         lastDayOfPreviousMonth.month--;
         lastDayOfPreviousMonth = lastDayOfPreviousMonth.endOfMonth;
         if (cal.getWeekInfoService().getEndOfWeek(lastDayOfPreviousMonth).compare(endDate) >= 0) {
             endDate = lastDayOfPreviousMonth;
         }
 
         return endDate;
     },
--- a/calendar/itip/calItipEmailTransport.js
+++ b/calendar/itip/calItipEmailTransport.js
@@ -158,17 +158,17 @@ calItipEmailTransport.prototype = {
                 // identity.
                 let allIdentities = MailServices.accounts.allIdentities;
                 if (allIdentities.length > 0) {
                     this.mDefaultIdentity = allIdentities.queryElementAt(0, Ci.nsIMsgIdentity);
                 } else {
                     // If there are no identities, then we are in the same
                     // situation as if we didn't have Xpcom Mail.
                     this.mHasXpcomMail = false;
-                    cal.LOG("initEmailService: No XPCOM Mail available: " + e);
+                    cal.LOG("initEmailService: No XPCOM Mail available");
                 }
             }
         } catch (ex) {
             // Then we must resort to operating system specific means
             this.mHasXpcomMail = false;
         }
     },
 
--- a/calendar/lightning/content/html-item-editing/react-code.js
+++ b/calendar/lightning/content/html-item-editing/react-code.js
@@ -1,16 +1,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 // This file contains code that uses react.js
 
 /* exported gTopComponent, DatePicker, TopComponent */
 
+/* import-globals-from ../lightning-item-iframe.js */
+/* globals React, ReactDOM */
+
 var gTopComponent = null;
 
 var Tabstrip = React.createClass({
     handleChange: function(index) {
         // The click handler will update the state with
         // the index of the focused menu entry
         this.props.onInput(this.props.keyprop, index);
     },
--- a/calendar/lightning/content/imip-bar.js
+++ b/calendar/lightning/content/imip-bar.js
@@ -1,12 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from ../../../mail/base/content/msgHdrView.js */
+/* import-globals-from ../../base/content/calendar-item-editing.js */
+/* import-globals-from ../../base/content/calendar-ui-utils.js */
+/* globals msgWindow */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { ltn } = ChromeUtils.import("resource://calendar/modules/ltnInvitationUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 /**
  * Provides shortcuts to set label and collapsed attribute of imip-bar node.
  */
 const imipBar = {
--- a/calendar/lightning/content/lightning-calendar-creation.js
+++ b/calendar/lightning/content/lightning-calendar-creation.js
@@ -1,14 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported onChangeIdentity */
 
+/* import-globals-from ../../resources/content/calendarCreation.js */
+/* import-globals-from lightning-utils.js */
+
 var common_initCustomizePage = initCustomizePage;
 var common_doCreateCalendar = doCreateCalendar;
 
 initCustomizePage = function() {
     common_initCustomizePage();
     ltnInitMailIdentitiesRow();
     ltnNotifyOnIdentitySelection();
 };
--- a/calendar/lightning/content/lightning-calendar-properties.js
+++ b/calendar/lightning/content/lightning-calendar-properties.js
@@ -1,14 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported onChangeIdentity */
 
+/* import-globals-from ../../base/content/dialogs/calendar-properties-dialog.js */
+/* import-globals-from lightning-utils.js */
+
 var common_onLoad = onLoad;
 var common_onAcceptDialog = onAcceptDialog;
 
 onLoad = function() {
     gCalendar = window.arguments[0].calendar;
     ltnInitMailIdentitiesRow();
     ltnNotifyOnIdentitySelection();
     common_onLoad();
--- a/calendar/lightning/content/lightning-item-iframe.js
+++ b/calendar/lightning/content/lightning-item-iframe.js
@@ -9,16 +9,21 @@
  *          deleteAllAttachments, copyAttachment, attachmentLinkKeyPress,
  *          attachmentDblClick, attachmentClick, notifyUser,
  *          removeNotification, chooseRecentTimezone, showTimezonePopup,
  *          attendeeDblClick, attendeeClick, removeAttendee,
  *          removeAllAttendees, sendMailToUndecidedAttendees, checkUntilDate,
  *          applyValues
  */
 
+/* import-globals-from ../../base/content/calendar-ui-utils.js */
+/* import-globals-from ../../base/content/dialogs/calendar-dialog-utils.js */
+/* import-globals-from html-item-editing/react-code.js */
+/* globals gTimezonesEnabled, gShowLink */// Set by lightning-item-panel.js.
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var {
     recurrenceRule2String,
     splitRecurrenceRules,
     checkRecurrenceRule,
     countOccurrences
 } = ChromeUtils.import("resource://calendar/modules/calRecurrenceUtils.jsm");
@@ -211,17 +216,17 @@ function receiveMessage(aEvent) {
             setElementValue(textbox, aEvent.data.value);
             updateToDoStatus("percent-changed");
             break;
         }
         case "postponeTask":
             postponeTask(aEvent.data.value);
             break;
         case "toggleTimezoneLinks":
-            gTimezonesEnabled = aEvent.data.checked;
+            gTimezonesEnabled = aEvent.data.checked; // eslint-disable-line
             updateDateTime();
             /*
             // Not implemented in react-code.js yet
             if (gNewItemUI) {
                 gTopComponent.importState({ timezonesEnabled: aEvent.data.checked });
             }
             */
             break;
@@ -1222,20 +1227,16 @@ function dateTimeControls2State(aStartDa
         updateUntildateRecRule();
 
         // Don't allow for until date earlier than the start date.
         if (gUntilDate.compare(gStartTime) < 0) {
             // We have to restore valid dates. Since the user has intentionally
             // changed the start date, it looks reasonable to restore a valid
             // until date equal to the start date.
             gUntilDate = gStartTime.clone();
-            // Update the rule.
-            let rrules = splitRecurrenceRules(window.recurrenceInfo);
-            recRule = rrules[0][0];
-            recRule.untilDate = gUntilDate.clone();
             // Update the until-date-picker. In case of "custom" rule, the
             // recurrence string is going to be changed by updateDateTime() below.
             let notCustomRule = document.getElementById("repeat-deck").selectedIndex == 0;
             if (notCustomRule) {
                 setElementValue("repeat-until-datepicker",
                                 cal.dtz.dateTimeToJsDate(gUntilDate.getInTimezone(cal.dtz.floating)));
             }
 
@@ -3713,16 +3714,17 @@ function updateAttendees() {
     let attendeePanel = document.getElementById("event-grid-tabpanel-attendees");
     let notifyOptions = document.getElementById("notify-options");
     if (cal.item.isEvent(window.calendarItem)) {
         attendeeTab.removeAttribute("collapsed");
         attendeePanel.removeAttribute("collapsed");
         notifyOptions.removeAttribute("collapsed");
 
         if (window.organizer && window.organizer.id) {
+            let organizer = window.organizer;
             document.getElementById("item-organizer-row").removeAttribute("collapsed");
             let cell = document.querySelector(".item-organizer-cell");
             let icon = cell.querySelector("img:nth-of-type(1)");
             let text = cell.querySelector("label:nth-of-type(1)");
 
             let role = organizer.role || "REQ-PARTICIPANT";
             let userType = organizer.userType || "INDIVIDUAL";
             let partStat = organizer.participationStatus || "NEEDS-ACTION";
@@ -3954,17 +3956,17 @@ function removeAllAttendees() {
 }
 
 /**
  * Send Email to all attendees that haven't responded or are tentative.
  *
  * @param aAttendees    The attendees to check.
  */
 function sendMailToUndecidedAttendees(aAttendees) {
-    let targetAttendees = attendees.filter(isAttendeeUndecided);
+    let targetAttendees = aAttendees.filter(isAttendeeUndecided);
     sendMailToAttendees(targetAttendees);
 }
 
 /**
  * Send Email to all given attendees.
  *
  * @param aAttendees    The attendees to send mail to.
  */
--- a/calendar/lightning/content/lightning-item-panel.js
+++ b/calendar/lightning/content/lightning-item-panel.js
@@ -6,16 +6,20 @@
  *          onCommandDeleteItem, editAttendees, editPrivacy, editPriority,
  *          editStatus, editShowTimeAs, updateShowTimeAs, editToDoStatus,
  *          postponeTask, toggleTimezoneLinks, toggleLink, attachURL,
  *          onCommandViewToolbar, onCommandCustomize, attachFileByAccountKey,
  *          onUnloadLightningItemPanel, openNewEvent, openNewTask,
  *          openNewMessage, openNewCardDialog
  */
 
+/* import-globals-from ../../../../toolkit/content/globalOverlay.js */
+/* import-globals-from ../../base/content/dialogs/calendar-dialog-utils.js */
+/* import-globals-from ../../base/content/calendar-ui-utils.js */
+
 // XXX Need to determine which of these we really need here.
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { MailServices } = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 // gTabmail is null if we are in a dialog window and not in a tab.
 var gTabmail = document.getElementById("tabmail") || null;
 
@@ -245,18 +249,18 @@ function onLoadLightningItemPanel(aIfram
         // hide the ok and cancel dialog buttons
         let accept = document.documentElement.getButton("accept");
         let cancel = document.documentElement.getButton("cancel");
         accept.setAttribute("collapsed", "true");
         cancel.setAttribute("collapsed", "true");
         cancel.parentNode.setAttribute("collapsed", "true");
 
         // set toolbar icon color for light or dark themes
-        if (typeof ToolbarIconColor !== "undefined") {
-            ToolbarIconColor.init();
+        if (typeof window.ToolbarIconColor !== "undefined") {
+            window.ToolbarIconColor.init();
         }
 
         // Enlarge the dialog window so the iframe content fits, and prevent it
         // getting smaller. We don't know the minimum size of the content unless
         // it's overflowing, so don't attempt to enforce what we don't know.
         let docEl = document.documentElement;
         let overflowListener = () => {
             let { scrollWidth, scrollHeight } = iframe.contentDocument.documentElement;
@@ -317,18 +321,18 @@ function onLoadLightningItemPanel(aIfram
 
 /**
  * Unload handler for the outer parent context that contains the iframe.
  * Currently only called for windows and not tabs.
  */
 function onUnloadLightningItemPanel() {
     if (!gTabmail) {
         // window dialog case
-        if (typeof ToolbarIconColor !== "undefined") {
-            ToolbarIconColor.uninit();
+        if (typeof window.ToolbarIconColor !== "undefined") {
+            window.ToolbarIconColor.uninit();
         }
     }
 }
 
 /**
  * Updates the UI.  Called when a user makes a change and when an
  * event/task tab is shown.  When a tab is shown aArg contains the gConfig
  * data for that event/task.  We pass the full tab state object to the
--- a/calendar/lightning/content/lightning-utils.js
+++ b/calendar/lightning/content/lightning-utils.js
@@ -1,16 +1,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported ltnInitMailIdentitiesRow, ltnGetMailIdentitySelection,
  *          ltnSaveMailIdentitySelection, ltnNotifyOnIdentitySelection
  */
 
+/* import-globals-from ../../base/content/calendar-ui-utils.js */
+/* globals gCalendar */
+
 var { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
 var { MailServices } = ChromeUtils.import("resource:///modules/MailServices.jsm");
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 /**
  * Initializing the email identity row
  * (shared between calendar creation wizard and properties dialog)
  */
--- a/calendar/lightning/content/messenger-overlay-preferences.js
+++ b/calendar/lightning/content/messenger-overlay-preferences.js
@@ -1,14 +1,22 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported gLightningPane */
 
+/* import-globals-from ../../../mail/components/preferences/preferences.js */
+/* import-globals-from ../../../mail/components/preferences/subdialogs.js */
+/* import-globals-from ../../base/content/calendar-ui-utils.js */
+/* import-globals-from ../../base/content/preferences/alarms.js */
+/* import-globals-from ../../base/content/preferences/categories.js */
+/* import-globals-from ../../base/content/preferences/general.js */
+/* import-globals-from ../../base/content/preferences/views.js */
+
 Preferences.add({ id: "calendar.preferences.lightning.selectedTabIndex", type: "int" });
 
 var gLightningPane = {
     mInitialized: false,
 
     init: function() {
         let preference = Preferences.get("calendar.preferences.lightning.selectedTabIndex");
         let ltnPrefs = document.getElementById("calPreferencesTabbox");
--- a/calendar/lightning/content/messenger-overlay-sidebar.js
+++ b/calendar/lightning/content/messenger-overlay-sidebar.js
@@ -3,16 +3,21 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* exported refreshUIBits, switchCalendarView, rescheduleInvitationsUpdate,
  *          openInvitationsDialog, onToolbarsPopupShowingWithMode,
  *          InitViewCalendarPaneMenu, onToolbarsPopupShowingForTabType,
  *          customizeMailToolbarForTabType
  */
 
+/* import-globals-from ../../base/content/calendar-common-sets.js */
+/* import-globals-from ../../base/content/calendar-invitations-manager.js */
+/* import-globals-from ../../base/content/today-pane.js */
+/* import-globals-from lightning-item-panel.js */
+
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { AddonManager } = ChromeUtils.import("resource://gre/modules/AddonManager.jsm");
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 var gLastShownCalendarView = null;
 
 var calendarTabMonitor = {
     monitorName: "lightning",
--- a/calendar/lightning/content/suite-overlay-sidebar.js
+++ b/calendar/lightning/content/suite-overlay-sidebar.js
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from ../../../suite/base/content/utilityOverlay.js */
+
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var ltnSuiteUtils = {
 
     addStartupObserver: function() {
         Services.obs.addObserver(this.startupObserver, "lightning-startup-done");
         Services.obs.addObserver(this.startupObserver, "calendar-taskview-startup-done");
     },
--- a/calendar/providers/caldav/calDavCalendar.js
+++ b/calendar/providers/caldav/calDavCalendar.js
@@ -1,12 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from calDavRequestHandlers.js */
+/* globals OAUTH_BASE_URI, OAUTH_SCOPE, OAUTH_CLIENT_ID, OAUTH_HASH */
+
 var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { setTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm");
 
 var { OAuth2 } = ChromeUtils.import("resource:///modules/OAuth2.jsm");
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
@@ -141,21 +144,21 @@ calDavCalendar.prototype = {
         return null;
     },
 
     get displayName() {
         return cal.l10n.getCalString("caldavName");
     },
 
     createCalendar: function() {
-        throw NS_ERROR_NOT_IMPLEMENTED;
+        throw Cr.NS_ERROR_NOT_IMPLEMENTED;
     },
 
     deleteCalendar: function(_cal, listener) {
-        throw NS_ERROR_NOT_IMPLEMENTED;
+        throw Cr.NS_ERROR_NOT_IMPLEMENTED;
     },
 
     // calIChangeLog interface
     get offlineStorage() {
         return this.mOfflineStorage;
     },
 
     set offlineStorage(storage) {
@@ -1897,18 +1900,17 @@ calDavCalendar.prototype = {
             self.completeCheckServerInfo(aChangeLogListener, Cr.NS_ERROR_FAILURE);
         };
 
         this.sendHttpRequest(this.makeUri(), queryXml, MIME_TEXT_XML, null, (channel) => {
             channel.setRequestHeader("Depth", "0", false);
             channel.requestMethod = "PROPFIND";
             return streamListener;
         }, () => {
-            notifyListener(Cr.NS_ERROR_NOT_AVAILABLE,
-                           "Error preparing http channel");
+            this.completeCheckServerInfo(aChangeLogListener, Cr.NS_ERROR_NOT_AVAILABLE);
         });
     },
 
     /**
      * Checks server capabilities.
      *
      * setupAuthentication
      * checkDavResourceType
@@ -1996,18 +1998,17 @@ calDavCalendar.prototype = {
                 self.completeCheckServerInfo(aChangeLogListener);
             }
         };
 
         this.sendHttpRequest(homeSet, null, null, null, (channel) => {
             channel.requestMethod = "OPTIONS";
             return streamListener;
         }, () => {
-            notifyListener(Cr.NS_ERROR_NOT_AVAILABLE,
-                           "Error preparing http channel");
+            this.completeCheckServerInfo(aChangeLogListener, Cr.NS_ERROR_NOT_AVAILABLE);
         });
     },
 
     /**
      * Locates the principal namespace. This function should soely be called
      * from checkServerCaps to find the principal namespace.
      *
      * setupAuthentication
@@ -2076,17 +2077,17 @@ calDavCalendar.prototype = {
             self.checkPrincipalsNameSpace(nsList, aChangeLogListener);
         };
 
         this.sendHttpRequest(homeSet, queryXml, MIME_TEXT_XML, null, (channel) => {
             channel.setRequestHeader("Depth", "0", false);
             channel.requestMethod = "PROPFIND";
             return streamListener;
         }, () => {
-            notifyListener(Cr.NS_ERROR_NOT_AVAILABLE);
+            this.completeCheckServerInfo(aChangeLogListener, Cr.NS_ERROR_NOT_AVAILABLE);
         });
     },
 
     /**
      * Checks the principals namespace for scheduling info. This function should
      * soely be called from findPrincipalNS
      *
      * setupAuthentication
@@ -2261,17 +2262,17 @@ calDavCalendar.prototype = {
             if (queryDepth == 0) {
                 // Set header, doing this for Depth: 1 is not needed since thats the
                 // default.
                 channel.setRequestHeader("Depth", "0", false);
             }
             channel.requestMethod = queryMethod;
             return streamListener;
         }, () => {
-            notifyListener(Cr.NS_ERROR_NOT_AVAILABLE);
+            this.completeCheckServerInfo(aChangeLogListener, Cr.NS_ERROR_NOT_AVAILABLE);
         });
     },
 
     /**
      * This is called to complete checking the server info. It should be the
      * final call when checking server options. This will either report the
      * error or if it is a success then refresh the calendar.
      *
@@ -2530,18 +2531,17 @@ calDavCalendar.prototype = {
 
         let fbUri = this.makeUri(null, this.outboxUrl);
         this.sendHttpRequest(fbUri, fbQuery, MIME_TEXT_CALENDAR, null, (channel) => {
             channel.requestMethod = "POST";
             channel.setRequestHeader("Originator", organizer, false);
             channel.setRequestHeader("Recipient", mailto_aCalId, false);
             return streamListener;
         }, () => {
-            notifyListener(Cr.NS_ERROR_NOT_AVAILABLE,
-                           "Error preparing http channel");
+            aListener.onResult(null, null);
         });
     },
 
     /**
      * Extract the path from the full spec, if the regexp failed, log
      * warning and return unaltered path.
      */
     extractPathFromSpec: function(aSpec) {
@@ -2864,18 +2864,17 @@ calDavCalendar.prototype = {
             this.sendHttpRequest(requestUri, uploadData, MIME_TEXT_CALENDAR, null, (channel) => {
                 channel.requestMethod = "POST";
                 channel.setRequestHeader("Originator", this.calendarUserAddress, false);
                 for (let recipient of aRecipients) {
                     channel.setRequestHeader("Recipient", recipient.id, true);
                 }
                 return streamListener;
             }, () => {
-                notifyListener(Cr.NS_ERROR_NOT_AVAILABLE,
-                               "Error preparing http channel");
+                cal.LOG("CalDAV: Error preparing http channel");
             });
         }
         return true;
     },
 
     mVerboseLogging: undefined,
     verboseLogging: function() {
         if (this.mVerboseLogging === undefined) {
--- a/calendar/providers/caldav/calDavRequestHandlers.js
+++ b/calendar/providers/caldav/calDavRequestHandlers.js
@@ -1,12 +1,13 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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 { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { setTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm");
 
 var xmlHeader = '<?xml version="1.0" encoding="UTF-8"?>\n';
 var MIME_TEXT_XML = "text/xml; charset=utf-8";
 
 /**
  * This is a handler for the etag request in calDavCalendar.js' getUpdatedItem.
--- a/calendar/providers/caldav/content/caldav-lightning-calendar-creation.js
+++ b/calendar/providers/caldav/content/caldav-lightning-calendar-creation.js
@@ -1,12 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from ../../../lightning/content/lightning-calendar-creation.js */
+/* import-globals-from caldav-lightning-utils.js */
+
 var ltn_initCustomizePage = initCustomizePage;
 var ltn_doCreateCalendar = doCreateCalendar;
 var ltn_onChangeIdentity = onChangeIdentity;
 
 initCustomizePage = function() {
     ltn_initCustomizePage();
     caldavInitForceEmailScheduling();
 };
--- a/calendar/providers/caldav/content/caldav-lightning-calendar-properties.js
+++ b/calendar/providers/caldav/content/caldav-lightning-calendar-properties.js
@@ -1,12 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from ../../../lightning/content/lightning-calendar-properties.js */
+/* import-globals-from caldav-lightning-utils.js */
+
 var ltn_onChangeIdentity = onChangeIdentity;
 
 onLoad = function() {
     gCalendar = window.arguments[0].calendar;
     ltnInitMailIdentitiesRow();
     caldavInitForceEmailScheduling();
     common_onLoad();
 };
--- a/calendar/providers/caldav/content/caldav-lightning-utils.js
+++ b/calendar/providers/caldav/content/caldav-lightning-utils.js
@@ -1,16 +1,20 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported caldavInitForceEmailScheduling, caldavSaveForceEmailScheduling,
  *          caldavUpdateForceEmailSchedulingControl
  */
 
+/* import-globals-from ../../../base/content/calendar-ui-utils.js */
+/* import-globals-from ../../../lightning/content/lightning-utils.js */
+/* globals gCalendar */
+
 /**
  * Initializing calendar creation wizard and properties dialog to display the
  * option to enforce email scheduling for outgoing scheduling operations
  * (shared between calendar creation wizard and properties dialog)
  */
 function caldavInitForceEmailScheduling() {
     if (gCalendar && gCalendar.type == "caldav") {
         let checkbox = document.getElementById("force-email-scheduling");
--- a/calendar/providers/composite/calCompositeCalendar.js
+++ b/calendar/providers/composite/calCompositeCalendar.js
@@ -93,22 +93,22 @@ calCompositeCalendar.prototype = {
 
     //
     // calICalendarProvider interface
     //
     get prefChromeOverlay() { return null; },
     get displayName() { return cal.l10n.getCalString("compositeName"); },
 
     createCalendar: function() {
-        throw NS_ERROR_NOT_IMPLEMENTED;
+        throw Cr.NS_ERROR_NOT_IMPLEMENTED;
     },
 
     deleteCalendar: function(calendar, listener) {
         // You shouldn't be able to delete from the composite calendar.
-        throw NS_ERROR_NOT_IMPLEMENTED;
+        throw Cr.NS_ERROR_NOT_IMPLEMENTED;
     },
 
     //
     // calICompositeCalendar interface
     //
 
     mCalendars: null,
     mDefaultCalendar: null,
--- a/calendar/providers/gdata/content/gdata-calendar-creation.js
+++ b/calendar/providers/gdata/content/gdata-calendar-creation.js
@@ -1,18 +1,21 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from ../../../lightning/content/lightning-calendar-creation.js */
+
 // Backwards compatibility with Thunderbird <60.
 if (!("Cc" in this)) {
     // eslint-disable-next-line mozilla/no-define-cc-etc, no-unused-vars
     const { utils: Cu } = Components;
 }
 
+var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { cal } = ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm");
 var { getGoogleSessionManager } = ChromeUtils.import("resource://gdata-provider/modules/gdataSession.jsm");
 var { monkeyPatch } = ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
 
 (function() {
     function pageorder(anchor, ...pages) {
         let wizard = document.documentElement;
         let page = wizard.getPageById(anchor);
@@ -70,16 +73,18 @@ var { monkeyPatch } = ChromeUtils.import
             return protofunc(type);
         });
     } else {
         // The exchange provider overwrites the select handler, which causes
         // our provider to fail. The exchange provider overwrites the select
         // handler, which causes our provider to fail. Given the exchange
         // provider is currently not maintained and we want them to work
         // together, here is a workaround.
+
+        // eslint-disable-next-line no-undef
         monkeyPatch(tmpCalendarCreation, "doRadioExchangeCalendar", (protofunc, target) => {
             // We need to run our function first, otherwise resetting the
             // pageorder will overwrite what the exchange provider does.
             selectProvider(target.value);
             let rv = protofunc(target);
 
             // But then again, when switching to the gdata provider, the
             // exchange provider overwrites the uri we set.
--- a/calendar/providers/gdata/content/gdata-calendar-properties.js
+++ b/calendar/providers/gdata/content/gdata-calendar-properties.js
@@ -1,12 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from ../../../lightning/content/lightning-calendar-properties.js */
+
+var { monkeyPatch } = ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
+
 window.addEventListener("load", () => {
     if (document.getElementById("calendar-uri").value) {
         // Calendar's load function needs to be called first, and that seems to have happened.
         gdataOnLoad();
     } else {
         // onLoad has not yet been called, so we can piggyback on that function.
         monkeyPatch(window, "onLoad", (protofunc, ...args) => {
             let rv = protofunc(...args);
--- a/calendar/providers/gdata/content/gdata-event-dialog-reminder.js
+++ b/calendar/providers/gdata/content/gdata-event-dialog-reminder.js
@@ -1,16 +1,21 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from ../../../base/content/dialogs/calendar-event-dialog-reminder.js */
+
 (function() {
     const FOUR_WEEKS_BEFORE = -2419200;
     const { cal } = ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm");
-    const { monkeyPatch } = ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
+    const {
+        monkeyPatch,
+        getProviderString,
+    } = ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
 
     // NOTE: This function exits early if its not a gdata calendar
     let item = window.arguments[0].item;
     let calendar = window.arguments[0].calendar;
     if (calendar.type != "gdata") {
         return;
     }
 
--- a/calendar/providers/gdata/content/gdata-lightning-item-iframe.js
+++ b/calendar/providers/gdata/content/gdata-lightning-item-iframe.js
@@ -1,12 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from ../../../lightning/content/lightning-item-iframe.js */
+/* import-globals-from ../../../base/content/dialogs/calendar-dialog-utils.js */
+
 var { monkeyPatch } = ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
 
 var { cal } = ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm");
 
 (function() {
     monkeyPatch(window, "updateCalendar", function(protofunc, ...args) {
         let rv = protofunc.apply(this, args);
         let calendar = getCurrentCalendar();
--- a/calendar/providers/gdata/content/gdata-list-tree.xml
+++ b/calendar/providers/gdata/content/gdata-list-tree.xml
@@ -1,13 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - 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/. -->
 
+<!-- globals cal, Services -->
+
 <!DOCTYPE bindings SYSTEM "chrome://calendar/locale/calendar.dtd">
 
 <bindings id="gdata-list-tree-bindings"
           xmlns="http://www.mozilla.org/xbl"
           xmlns:xbl="http://www.mozilla.org/xbl"
           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <binding id="gdata-list-tree" extends="chrome://calendar/content/widgets/calendar-list-tree.xml#calendar-list-tree">
--- a/calendar/providers/gdata/content/gdata-migration.js
+++ b/calendar/providers/gdata/content/gdata-migration.js
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from ../../../base/content/calendar-ui-utils.js */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 /* exported migrateSelectedCalendars */
 
 /**
  * Migrate the calendar selected in the wizard from ics to gdata.
  */
--- a/calendar/providers/gdata/modules/gdataRequest.jsm
+++ b/calendar/providers/gdata/modules/gdataRequest.jsm
@@ -353,17 +353,17 @@ calGoogleRequest.prototype = {
         }
 
         let httpChannel = aLoader.request.QueryInterface(Ci.nsIHttpChannel);
 
         // Convert the stream, falling back to utf-8 in case its not given.
         let result = new TextDecoder(httpChannel.contentCharset || "utf-8").decode(Uint8Array.from(aResult));
         if (result === null) {
             this.fail(Cr.NS_ERROR_FAILURE,
-                      "Could not convert bytestream to Unicode: " + e);
+                      "Could not convert bytestream to Unicode");
             return;
         }
 
         let objData;
         try {
             if (result.length) {
                 objData = JSON.parse(result);
             } else {
--- a/calendar/providers/gdata/modules/gdataSession.jsm
+++ b/calendar/providers/gdata/modules/gdataSession.jsm
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* globals OAUTH_BASE_URI, OAUTH_SCOPE, OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET */
+
 // Backwards compatibility with Thunderbird <60.
 if (!("Cc" in this)) {
     // eslint-disable-next-line mozilla/no-define-cc-etc, no-unused-vars
     const { classes: Cc, interfaces: Ci, results: Cr } = Components;
 }
 
 var { OAuth2 } = ChromeUtils.import("resource://gdata-provider/modules/OAuth2.jsm");
 var { getProviderString } = ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
--- a/calendar/providers/gdata/modules/gdataUtils.jsm
+++ b/calendar/providers/gdata/modules/gdataUtils.jsm
@@ -578,18 +578,18 @@ function setupRecurrence(aItem, aRecurre
 
     if (aItem.recurrenceInfo) {
         aItem.recurrenceInfo.clearRecurrenceItems();
     } else {
         aItem.recurrenceInfo = cal.createRecurrenceInfo(aItem);
     }
 
     let rootComp;
+    let vevent = "BEGIN:VEVENT\r\n" + aRecurrence.join("\r\n") + "\r\nEND:VEVENT";
     try {
-        let vevent = "BEGIN:VEVENT\r\n" + aRecurrence.join("\r\n") + "\r\nEND:VEVENT";
         rootComp = cal.getIcsService().parseICS(vevent, null);
     } catch (e) {
         cal.ERROR("[calGoogleCalendar] Unable to parse recurrence item: " + vevent);
     }
 
     let hasRecurringRules = false;
     for (let prop = rootComp.getFirstProperty("ANY");
          prop;
--- a/calendar/providers/ics/calICSCalendar.js
+++ b/calendar/providers/ics/calICSCalendar.js
@@ -77,21 +77,21 @@ calICSCalendar.prototype = {
         return null;
     },
 
     get displayName() {
         return cal.l10n.getCalString("icsName");
     },
 
     createCalendar: function() {
-        throw NS_ERROR_NOT_IMPLEMENTED;
+        throw Cr.NS_ERROR_NOT_IMPLEMENTED;
     },
 
     deleteCalendar: function(_cal, listener) {
-        throw NS_ERROR_NOT_IMPLEMENTED;
+        throw Cr.NS_ERROR_NOT_IMPLEMENTED;
     },
 
     //
     // calICalendar interface
     //
     get type() { return "ics"; },
 
     get canRefresh() {
--- a/calendar/providers/memory/calMemoryCalendar.js
+++ b/calendar/providers/memory/calMemoryCalendar.js
@@ -54,17 +54,17 @@ calMemoryCalendar.prototype = {
         return null;
     },
 
     get displayName() {
         return cal.l10n.getCalString("memoryName");
     },
 
     createCalendar: function() {
-        throw NS_ERROR_NOT_IMPLEMENTED;
+        throw Cr.NS_ERROR_NOT_IMPLEMENTED;
     },
 
     deleteCalendar: function(calendar, listener) {
         calendar = calendar.wrappedJSObject;
         calendar.mItems = {};
         calendar.mMetaData = new Map();
 
         try {
--- a/calendar/providers/storage/calStorageCalendar.js
+++ b/calendar/providers/storage/calStorageCalendar.js
@@ -63,17 +63,17 @@ calStorageCalendar.prototype = {
         return null;
     },
 
     get displayName() {
         return cal.l10n.getCalString("storageName");
     },
 
     createCalendar: function() {
-        throw NS_ERROR_NOT_IMPLEMENTED;
+        throw Cr.NS_ERROR_NOT_IMPLEMENTED;
     },
 
     deleteCalendar: function(aCalendar, listener) {
         aCalendar = aCalendar.wrappedJSObject;
 
         if (this.mDeleteEventExtras) {
             for (let stmt of this.mDeleteEventExtras) {
                 try {
--- a/calendar/providers/wcap/calWcapCalendar.js
+++ b/calendar/providers/wcap/calWcapCalendar.js
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from calWcapCalendarModule.js */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 /**
  * The calendar provider class for WCAP calendars. Usually instanciated through
  * the calendar manager, but may also be created by the wcap session, hence the
  * following optional parameters.
  *
  * @param session       (optional) The calWcapSession for this calendar
@@ -68,23 +70,23 @@ calWcapCalendar.prototype = {
     },
 
     // calICalendarProvider:
     get prefChromeOverlay() {
         return null;
     },
     // displayName attribute already part of calIWcapCalendar
     createCalendar: function(name, url, listener) {
-        throw NS_ERROR_NOT_IMPLEMENTED;
+        throw Cr.NS_ERROR_NOT_IMPLEMENTED;
     },
     deleteCalendar: function(calendar, listener) {
-        throw NS_ERROR_NOT_IMPLEMENTED;
+        throw Cr.NS_ERROR_NOT_IMPLEMENTED;
     },
     getCalendar: function(url) {
-        throw NS_ERROR_NOT_IMPLEMENTED;
+        throw Cr.NS_ERROR_NOT_IMPLEMENTED;
     },
 
     // calICalendar:
     get name() {
         let name = this.getProperty("name");
         if (!name) {
             name = this.displayName;
         }
--- a/calendar/providers/wcap/calWcapCalendarItems.js
+++ b/calendar/providers/wcap/calWcapCalendarItems.js
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* import-globals-from calWcapCalendarModule.js */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 calWcapCalendar.prototype.encodeAttendee = function(att) {
     if (LOG_LEVEL > 2) {
         log("attendee.icalProperty.icalString=" + att.icalProperty.icalString, this);
     }
     function encodeAttr(val, attr, params) {
         if (val && val.length > 0) {
--- a/calendar/providers/wcap/calWcapCalendarModule.js
+++ b/calendar/providers/wcap/calWcapCalendarModule.js
@@ -6,18 +6,26 @@
  *          calIWcapCalendar, calIWcapErrors, calICalendar, calIItemBase,
  *          calIOperationListener, calIFreeBusyProvider, calIFreeBusyInterval,
  *          calICalendarSearchProvider, calIErrors, g_privateItemTitle,
  *          g_confidentialItemTitle, g_busyItemTitle,
  *          g_busyPhantomItemUuidPrefix, CACHE_LAST_RESULTS,
  *          CACHE_LAST_RESULTS_INVALIDATE, LOG_LEVEL
  */
 
+/* import-globals-from calWcapUtils.js */
+/* import-globals-from calWcapErrors.js */
+/* import-globals-from calWcapRequest.js */
+/* import-globals-from calWcapSession.js */
+/* import-globals-from calWcapCalendar.js */
+/* import-globals-from calWcapCalendarItems.js */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 //
 // init code for globals, prefs:
 //
 
 // constants:
 var NS_OK = Cr.NS_OK;
 var NS_ERROR_UNEXPECTED = Cr.NS_ERROR_UNEXPECTED;
--- a/calendar/providers/wcap/calWcapErrors.js
+++ b/calendar/providers/wcap/calWcapErrors.js
@@ -1,16 +1,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported checkErrorCode, checkWcapXmlErrno, checkWcapIcalErrno,
  *          errorToString
  */
 
+/* import-globals-from calWcapCalendarModule.js */
+
 var NS_ERROR_INVALID_ARG = Cr.NS_ERROR_INVALID_ARG;
 
 //
 // Common netwerk errors:
 //
 var NS_ERROR_MODULE_BASE_OFFSET = 0x45;
 var NS_ERROR_MODULE_NETWORK = 6;
 
--- a/calendar/providers/wcap/calWcapRequest.js
+++ b/calendar/providers/wcap/calWcapRequest.js
@@ -14,16 +14,18 @@
    The request function itself may return either
    - a further calIOperation request object, i.e. an async continuation
    - some data (incl null/undefined) which is the result of the async function,
      indicating that there is no further continuation
 */
 
 /* exported issueNetworkRequest, getWcapRequestStatusString, stringToIcal, stringToXml */
 
+/* import-globals-from calWcapCalendarModule.js */
+
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 function generateRequestId() {
     if (!generateRequestId.mRequestPrefix) {
         generateRequestId.mRequestPrefix = cal.getUUID() + "-";
         generateRequestId.mRequestId = 0;
     }
--- a/calendar/providers/wcap/calWcapSession.js
+++ b/calendar/providers/wcap/calWcapSession.js
@@ -1,14 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported getWcapSessionFor */
 
+/* import-globals-from calWcapCalendarModule.js */
+
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 function calWcapTimezone(tzProvider, tzid_, component_) {
     this.wrappedJSObject = this;
     this.provider = tzProvider;
     this.icalComponent = component_;
--- a/calendar/providers/wcap/calWcapUtils.js
+++ b/calendar/providers/wcap/calWcapUtils.js
@@ -1,16 +1,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported getCalendarSearchService, getDomParser, isParent, filterXmlNodes,
  *          getIcalUTC, getDatetimeFromIcalProp, getWcapString
  */
 
+/* import-globals-from calWcapCalendarModule.js */
+
 var { Preferences } = ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 var g_bShutdown = false;
 
 function initLogging() {
--- a/calendar/resources/content/datetimepickers/datetimepickers.js
+++ b/calendar/resources/content/datetimepickers/datetimepickers.js
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
+/* globals BaseControlMixin, cal, MozElementMixin, MozXULElement */
+
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 customElements.whenDefined("menulist-editable").then(() => {
     class MozTimepickerMinute extends MozXULElement {
         static get observedAttributes() {
             return ["label", "selected"];
         }
 
--- a/calendar/resources/content/datetimepickers/datetimepickers.xml
+++ b/calendar/resources/content/datetimepickers/datetimepickers.xml
@@ -1,16 +1,18 @@
 <?xml version="1.0"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - 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/. -->
 
+<!-- globals cal -->
+
 <!--
     This defines <datepicker/> <timepicker/> and <datetimepicker/>
     which all descend from datetimepicker-base to get date/time parsing
     and consistent behavior.
     It relies on <minimonth/> for the date picker's drop down.
     You can be notified of change event as follows:
       <datepicker id="my-date-picker" onchange="myDatePick(this);"/>
     May get/set value in javascript with
--- a/calendar/resources/content/mouseoverPreviews.js
+++ b/calendar/resources/content/mouseoverPreviews.js
@@ -9,16 +9,18 @@
  *
  *   (Portions of this code were previously in calendar.js and unifinder.js,
  *   some of it duplicated.)
  */
 
 /* exported onMouseOverItem, showToolTip, getPreviewForItem,
              getEventStatusString, getToDoStatusString */
 
+/* import-globals-from ../../base/content/calendar-ui-utils.js */
+
 /**
  * PUBLIC: This changes the mouseover preview based on the start and end dates
  * of an occurrence of a (one-time or recurring) calEvent or calToDo.
  * Used by all grid views.
  */
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
--- a/calendar/resources/content/publish.js
+++ b/calendar/resources/content/publish.js
@@ -1,16 +1,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported publishCalendarData, publishCalendarDataDialogResponse,
  *          publishEntireCalendar, publishEntireCalendarDialogResponse
  */
 
+/* import-globals-from ../../base/content/calendar-views.js */
+
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 /**
  * publishCalendarData
  * Show publish dialog, ask for URL and publish all selected items.
  */
 function publishCalendarData() {
@@ -92,17 +94,16 @@ function publishEntireCalendarDialogResp
     let itemArray = [];
     let getListener = {
         QueryInterface: ChromeUtils.generateQI([Ci.calIOperationListener]),
         onOperationComplete: function(aCalendar, aStatus, aOperationType, aId, aDetail) {
             publishItemArray(itemArray, CalendarPublishObject.remotePath, aProgressDialog);
         },
         onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
             if (!Components.isSuccessCode(aStatus)) {
-                aborted = true;
                 return;
             }
             if (aCount) {
                 for (let i = 0; i < aCount; ++i) {
                     // Store a (short living) reference to the item.
                     let itemCopy = aItems[i].clone();
                     itemArray.push(itemCopy);
                 }
--- a/calendar/resources/content/publishDialog.js
+++ b/calendar/resources/content/publishDialog.js
@@ -1,14 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 /* exported loadCalendarPublishDialog, onOKCommand, closeDialog */
 
+/* globals publishButtonLabel, closeButtonLabel */// From publishDialog.xul
+
 var gOnOkFunction;   // function to be called when user clicks OK
 var gPublishObject;
 
 /**
 *   Called when the dialog is loaded.
 */
 function loadCalendarPublishDialog() {
     // Get arguments, see description at top of file
--- a/calendar/test/mozmill/.eslintrc.js
+++ b/calendar/test/mozmill/.eslintrc.js
@@ -1,12 +1,13 @@
 "use strict";
 
 module.exports = {
     globals: {
+        __file__: true,
         elementslib: true,
         controller: true,
         mozmill: true,
         utils: true,
         require: true,
         exports: true,
         module: true,
         registeredFunctions: true,
--- a/calendar/test/mozmill/eventDialog/testEventDialog.js
+++ b/calendar/test/mozmill/eventDialog/testEventDialog.js
@@ -169,17 +169,17 @@ function testEventDialog() {
     plan_for_modal_dialog("Calendar:AlarmWindow", alarm => {
         let { eid: alarmid } = helpersForController(alarm);
         alarm.waitThenClick(alarmid("alarm-dismiss-all-button"));
     });
     wait_for_modal_dialog("Calendar:AlarmWindow", TIMEOUT_MODAL_DIALOG);
 
     // Verify event and alarm icon visible until endDate (3 full rows) and check tooltip.
     for (let row = 1; row <= 3; row++) {
-        for (col = 1; col <= 7; col++) {
+        for (let col = 1; col <= 7; col++) {
             controller.waitForElement(lookupEventBox("month", EVENT_BOX, row, col, null, EVENTPATH));
             checkAlarmIcon(controller, "month", row, col);
             checkTooltip(row, col, startTime, endTime);
         }
     }
     controller.assertNodeNotExist(lookupEventBox("month", EVENT_BOX, 4, 1, null, EVENTPATH));
 
     // Delete and verify deleted 6th col in row 1.
--- a/calendar/test/mozmill/invitations/test-imip-bar-eml.js
+++ b/calendar/test/mozmill/invitations/test-imip-bar-eml.js
@@ -10,16 +10,18 @@
 
 var MODULE_NAME = "testInvitations";
 
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["folder-display-helpers", "window-helpers", "notificationbox-helpers"];
 
 var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
 
+/* globals open_message_from_file, close_window */
+
 function setupModule(module) {
     for (let dep of MODULE_REQUIRES) {
         collector.getModule(dep).installInto(module);
     }
 }
 
 /**
  * Test that when opening a message containing an event, the IMIP bar shows.
--- a/calendar/test/mozmill/shared-modules/test-calendar-utils.js
+++ b/calendar/test/mozmill/shared-modules/test-calendar-utils.js
@@ -115,17 +115,16 @@ function installInto(module) {
     module.EVENTPATH = EVENTPATH;
     module.ALARM_ICON_PATH = ALARM_ICON_PATH;
     module.EVENT_BOX = EVENT_BOX;
     module.CANVAS_BOX = CANVAS_BOX;
     module.ALLDAY = ALLDAY;
 
     // Now copy helper functions.
     module.helpersForController = helpersForController;
-    module.setupLightning = setupLightning;
     module.handleOccurrencePrompt = handleOccurrencePrompt;
     module.switchToView = switchToView;
     module.goToDate = goToDate;
     module.invokeEventDialog = invokeEventDialog;
     module.getEventBoxPath = getEventBoxPath;
     module.getEventDetails = getEventDetails;
     module.checkAlarmIcon = checkAlarmIcon;
     module.viewForward = viewForward;
--- a/calendar/test/mozmill/shared-modules/test-item-editing-helpers.js
+++ b/calendar/test/mozmill/shared-modules/test-item-editing-helpers.js
@@ -6,29 +6,33 @@ var MODULE_NAME = "item-editing-helpers"
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "window-helpers"];
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
 var SHORT_SLEEP, TIMEOUT_MODAL_DIALOG;
 var helpersForController, menulistSelect;
 var plan_for_modal_dialog, wait_for_modal_dialog;
+var mark_failure;
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
     ({
         SHORT_SLEEP,
         TIMEOUT_MODAL_DIALOG,
         helpersForController,
         menulistSelect
     } = collector.getModule("calendar-utils"));
     Object.assign(module, helpersForController(controller));
 
     ({ plan_for_modal_dialog, wait_for_modal_dialog } =
         collector.getModule("window-helpers"));
+
+    ({ mark_failure } =
+        collector.getModule("folder-display-helpers"));
 }
 // Lookup paths and path-snippets.
 // These 5 have to be used with itemEditLookup().
 var CATEGORY_LIST = `
     id("event-grid-category-color-row")/id("event-grid-category-box")/id("item-categories")/
     id("item-categories-popup")
 `;
 var REPEAT_DETAILS = `
@@ -90,17 +94,16 @@ function installInto(module) {
     module.REC_DLG_DAYS = REC_DLG_DAYS;
     module.REC_DLG_UNTIL_INPUT = REC_DLG_UNTIL_INPUT;
     // Now copy helper functions.
     module.helpersForEditUI = helpersForEditUI;
     module.setData = setData;
     module.setReminderMenulist = setReminderMenulist;
     module.setCategories = setCategories;
     module.handleAddingAttachment = handleAddingAttachment;
-    module.acceptSendingNotificationMail = acceptSendingNotificationMail;
     module.setTimezone = setTimezone;
 }
 
 function helpersForEditUI(controller) {
     function selector(sel) {
         return sel.trim().replace(/\n(\s*)/g, "");
     }
 
@@ -218,23 +221,23 @@ function setData(dialog, iframe, data) {
     let untilDateInput = getDateTimePicker("UNTILDATE");
 
     let dateFormatter = cal.getDateFormatter();
     // Wait for input elements' values to be populated.
     sleep();
 
     // title
     if (data.title != undefined) {
-        titleInput = iframeid("item-title");
+        let titleInput = iframeid("item-title");
         replaceText(titleInput, data.title);
     }
 
     // location
     if (data.location != undefined) {
-        locationInput = iframeid("item-location");
+        let locationInput = iframeid("item-location");
         replaceText(locationInput, data.location);
     }
 
     // categories
     if (data.categories != undefined) {
         setCategories(dialog, iframe, data.categories);
     }
 
@@ -451,17 +454,17 @@ function setReminderMenulist(controller,
  */
 function setCategories(dialog, iframe, categories) {
     let { eid: iframeid } = helpersForController(iframe);
     let { iframeLookup } = helpersForEditUI(iframe);
     let categoryMenulist = iframeid("item-categories");
     let categoryList = iframeLookup(CATEGORY_LIST);
     dialog.click(categoryMenulist);
     dialog.waitFor(() => categoryMenulist.getNode().open);
-    if (categoryMenulist.itemCount > -1 && categoryMenulist.itemCount < data.categories.length) {
+    if (categoryMenulist.itemCount > -1 && categoryMenulist.itemCount < categories.length) {
         mark_failure(["more categories than supported by current calendar"]);
     } else {
         // Iterate over categories and check if needed.
         let listItems = categoryList.getNode().childNodes;
         for (let item of listItems) {
             let set = false;
             if (categories.includes(item.label)) {
                 set = true;
--- a/calendar/test/mozmill/testAlarmDefaultValue.js
+++ b/calendar/test/mozmill/testAlarmDefaultValue.js
@@ -13,35 +13,37 @@ var MODULE_REQUIRES = ["calendar-utils",
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 var { PluralForm } = ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 const DEFVALUE = 43;
 
 var helpersForController, invokeEventDialog, openLightningPrefs, menulistSelect;
 var plan_for_modal_dialog, wait_for_modal_dialog;
+var content_tab_e, content_tab_eid;
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
     ({
         helpersForController,
         invokeEventDialog,
         openLightningPrefs,
         menulistSelect
     } = collector.getModule("calendar-utils"));
     collector.getModule("calendar-utils").setupModule(controller);
-    Object.assign(module, helpersForController(controller));
+
+    ({ plan_for_modal_dialog, wait_for_modal_dialog } = collector.getModule("window-helpers"));
 
-    ({ plan_for_modal_dialog, wait_for_modal_dialog } =
-        collector.getModule("window-helpers"));
-
-    collector.getModule("content-tab-helpers").installInto(module);
+    ({ content_tab_e, content_tab_eid } = collector.getModule("content-tab-helpers"));
+    collector.getModule("content-tab-helpers").setupModule();
 }
 
 function testDefaultAlarms() {
+    let { eid } = helpersForController(controller);
+
     let localeUnitString = cal.l10n.getCalString("unitDays");
     let unitString = PluralForm.get(DEFVALUE, localeUnitString).replace("#1", DEFVALUE);
     let alarmString = (...args) => cal.l10n.getString("calendar-alarms", ...args);
     let originStringEvent = alarmString("reminderCustomOriginBeginBeforeEvent");
     let originStringTask = alarmString("reminderCustomOriginBeginBeforeTask");
     let expectedEventReminder = alarmString("reminderCustomTitle", [unitString, originStringEvent]);
     let expectedTaskReminder = alarmString("reminderCustomTitle", [unitString, originStringTask]);
 
@@ -87,16 +89,17 @@ function testDefaultAlarms() {
         wait_for_modal_dialog("Calendar:EventDialog:Reminder");
 
         // Close the task dialog.
         task.window.close();
     });
 }
 
 function handlePrefTab(tab) {
+    let { replaceText } = helpersForController(controller);
     // Click on the alarms tab.
     content_tab_e(tab, "calPreferencesTabAlarms").click();
 
     // Turn on alarms for events and tasks.
     menulistSelect(content_tab_eid(tab, "eventdefalarm"), "1", controller);
     menulistSelect(content_tab_eid(tab, "tododefalarm"), "1", controller);
 
     // Selects "days" as a unit.
--- a/calendar/test/mozmill/views/testTaskView.js
+++ b/calendar/test/mozmill/views/testTaskView.js
@@ -148,17 +148,16 @@ function testTaskView() {
     // Mark completed, verify.
     controller.click(eid("task-actions-markcompleted"));
     sleep();
 
     toolTipNode.ownerGlobal.showToolTip(toolTipNode, taskTreeNode.getTaskAtRow(0));
     controller.assertJSProperty(toolTipStatus, "textContent", "Completed");
 
     // Delete task and verify.
-    countBefore = taskTreeNode.mTaskArray.length;
     controller.click(eid("calendar-delete-task-button"));
     controller.waitFor(() => taskTreeNode.mTaskArray.length == 0, "Task did not delete");
 }
 
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
     closeAllEventDialogs();
 }