Bug 1280898 - Set up eslint for calendar files - enable no-new-object rule. r=MakeMyDay
authoreslint <eslint@bugzilla.kewis.ch>
Fri, 08 Jul 2016 11:18:56 +0200
changeset 25949 239f769da6b375beb31a149046382429f59af6ae
parent 25948 12f82fc35c280eb8de3d1a07af751b578e971166
child 25950 7b2fedd2dee96487ec5dde6c89617429e3737dc6
push id1771
push userclokep@gmail.com
push dateMon, 14 Nov 2016 17:47:53 +0000
treeherdercomm-beta@399ae9d71595 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMakeMyDay
bugs1280898
Bug 1280898 - Set up eslint for calendar files - enable no-new-object rule. r=MakeMyDay MozReview-Commit-ID: AYrXdIQ547D
calendar/.eslintrc
calendar/base/content/calendar-base-view.xml
calendar/base/content/calendar-invitations-manager.js
calendar/base/content/calendar-item-editing.js
calendar/base/content/calendar-multiday-view.xml
calendar/base/content/calendar-unifinder.js
calendar/base/content/dialogs/calendar-event-dialog-attendees.js
calendar/base/content/dialogs/calendar-print-dialog.js
calendar/base/content/import-export.js
calendar/base/content/widgets/calendar-list-tree.xml
calendar/lightning/content/lightning-item-iframe.js
calendar/lightning/content/messenger-overlay-sidebar.js
calendar/resources/content/publish.js
calendar/resources/content/publishDialog.js
--- a/calendar/.eslintrc
+++ b/calendar/.eslintrc
@@ -30,16 +30,19 @@
 
     // Disallow the omission of parentheses when invoking a constructor with no
     // arguments.
     "new-parens": 2,
 
     // Disallow use of the Array constructor.
     "no-array-constructor": 2,
 
+    // disallow use of the Object constructor
+    "no-new-object": 2,
+
     // Disallow the catch clause parameter name being the same as a variable in
     // the outer scope, to avoid confusion.
     "no-catch-shadow": 2,
 
     // Disallow assignment in conditional expressions.
     "no-cond-assign": 2,
 
     // Disallow use of debugger.
--- a/calendar/base/content/calendar-base-view.xml
+++ b/calendar/base/content/calendar-base-view.xml
@@ -24,17 +24,17 @@
       <field name="mController">null</field>
       <field name="mStartDate">null</field>
       <field name="mEndDate">null</field>
       <field name="mTasksInView">false</field>
       <field name="mShowCompleted">false</field>
       <field name="mDisplayDaysOff">true</field>
       <field name="mDaysOffArray">[0, 6]</field>
       <field name="mTimezone">null</field>
-      <field name="mFlashingEvents">new Object()</field>
+      <field name="mFlashingEvents">null</field>
       <field name="mSelectedItems">[]</field>
       <field name="mLongWeekdayTotalPixels">-1</field>
       <field name="mResizeHandler">null</field>
       <field name="mDropShadowsLength">null</field>
       <field name="mShadowOffset">null</field>
       <field name="mDropShadows">null</field>
       <field name="mMagnifyAmount">0</field>
       <field name="mPixelScrollDelta">0</field>
@@ -256,16 +256,17 @@
             self.onResize(self); };
         this.viewBroadcaster.addEventListener(this.getAttribute("type") + "viewresized", this.mResizeHandler, true);
         // add a preference observer to monitor changes
         Services.prefs.addObserver("calendar.", this.mPrefObserver, false);
         this.weekStartOffset = Preferences.get("calendar.week.start", 0);
         this.updateDaysOffPrefs();
         this.mPendingRefreshJobs = new Map();
         this.mLog = Log4Moz.getConfiguredLogger("calBaseView");
+        this.mFlashingEvents = {};
       ]]></constructor>
 
       <destructor><![CDATA[
         Components.utils.import("resource://gre/modules/Services.jsm");
 
         if (this.mCalendar) {
             this.mCalendar.removeObserver(this.mObserver);
         }
--- a/calendar/base/content/calendar-invitations-manager.js
+++ b/calendar/base/content/calendar-invitations-manager.js
@@ -235,17 +235,17 @@ InvitationsManager.prototype = {
      * @param onLoadOpListener          The operation listener to notify when
      *                                    getting invitations. Should be passed
      *                                    to this.getInvitations().
      * @param finishedCallBack          A callback function to call when the
      *                                    dialog has completed.
      */
     openInvitationsDialog: function IM_openInvitationsDialog(onLoadOpListener,
                                                              finishedCallBack) {
-        var args = new Object();
+        var args = {};
         args.onLoadOperationListener = onLoadOpListener;
         args.queue = [];
         args.finishedCallBack = finishedCallBack;
         args.requestManager = gInvitationsRequestManager;
         args.invitationsManager = this;
         // the dialog will reset this to auto when it is done loading
         window.setCursor("wait");
         // open the dialog
--- a/calendar/base/content/calendar-item-editing.js
+++ b/calendar/base/content/calendar-item-editing.js
@@ -430,17 +430,17 @@ function openEventDialog(calendarItem, c
                 // choice. Since we are shortly before a release to keep
                 // regression risk low, explicitly set the item's calendar here.
                 calendarItem.calendar = calendars[0];
             }
         }
     }
 
     // Setup the window arguments
-    var args = new Object();
+    var args = {};
     args.calendarEvent = calendarItem;
     args.calendar = calendar;
     args.mode = mode;
     args.onOk = callback;
     args.job = job;
     args.initialStartDateValue = (initialDate || getDefaultStartDate());
     args.inTab = Preferences.get("calendar.item.editInTab", false);
     args.useNewItemUI = Preferences.get("calendar.item.useNewItemUI", false);
--- a/calendar/base/content/calendar-multiday-view.xml
+++ b/calendar/base/content/calendar-multiday-view.xml
@@ -248,16 +248,17 @@
       </xul:stack>
       <xul:calendar-event-box anonid="config-box" hidden="true" xbl:inherits="orient"/>
     </content>
 
     <implementation>
       <constructor><![CDATA[
         this.mEventInfos = [];
         this.mTimezone = UTC();
+        this.mSelectedItemIds = {};
       ]]></constructor>
 
       <!-- fields -->
       <field name="mPixPerMin">0.6</field>
       <field name="mStartMin">0*60</field>
       <field name="mEndMin">24*60</field>
       <field name="mDayStartMin">8*60</field>
       <field name="mDayEndMin">17*60</field>
@@ -284,17 +285,17 @@
            widths.  When we relayout, we need to cancel those handlers -->
       <field name="mHandlersToRemove">[]</field>
 
       <!-- Set this true so that we know in our onAddItem listener to start
          - modifying an event when it comes back to us as created
         -->
       <field name="mCreatedNewEvent">false</field>
       <field name="mEventToEdit">null</field>
-      <field name="mSelectedItemIds">new Object()</field>
+      <field name="mSelectedItemIds">null</field>
 
       <!-- properties -->
       <property name="pixelsPerMinute">
         <getter><![CDATA[
           return this.mPixPerMin;
         ]]></getter>
         <setter><![CDATA[
           if (val <= 0.0) {
--- a/calendar/base/content/calendar-unifinder.js
+++ b/calendar/base/content/calendar-unifinder.js
@@ -817,17 +817,17 @@ var unifinderTreeView = {
     setCellText: function uTV_setCellText(aRow, aCol, aValue) {},
 
     performAction: function uTV_performAction(aAction) {},
 
     performActionOnRow: function uTV_performActionOnRow(aAction, aRow) {},
 
     performActionOnCell: function uTV_performActionOnCell(aAction, aRow, aCol) {},
 
-    outParameter: new Object() // used to obtain dates during sort
+    outParameter: {} // used to obtain dates during sort
 };
 
 /**
  * Refresh the unifinder tree by getting items from the composite calendar and
  * applying the current filter.
  */
 function refreshEventTree() {
     let field = document.getElementById("unifinder-search-field");
--- a/calendar/base/content/dialogs/calendar-event-dialog-attendees.js
+++ b/calendar/base/content/dialogs/calendar-event-dialog-attendees.js
@@ -437,17 +437,17 @@ function updateEndTime() {
  */
 function editStartTimezone() {
     var tzStart = document.getElementById("timezone-starttime");
     if (tzStart.hasAttribute("disabled")) {
         return;
     }
 
     var self = this;
-    var args = new Object();
+    var args = {};
     args.calendar = window.arguments[0].calendar;
     args.time = gStartDate.getInTimezone(gStartTimezone);
     args.onOk = function(datetime) {
         var equalTimezones = false;
         if (gStartTimezone && gEndTimezone &&
             compareObjects(gStartTimezone, gEndTimezone)) {
             equalTimezones = true;
         }
@@ -472,17 +472,17 @@ function editStartTimezone() {
  */
 function editEndTimezone() {
     var tzStart = document.getElementById("timezone-endtime");
     if (tzStart.hasAttribute("disabled")) {
         return;
     }
 
     var self = this;
-    var args = new Object();
+    var args = {};
     args.calendar = window.arguments[0].calendar;
     args.time = gEndTime.getInTimezone(gEndTimezone);
     args.onOk = function(datetime) {
         if (gStartTimezone && gEndTimezone &&
             compareObjects(gStartTimezone, gEndTimezone)) {
             gStartTimezone = datetime.timezone;
         }
         gEndTimezone = datetime.timezone;
--- a/calendar/base/content/dialogs/calendar-print-dialog.js
+++ b/calendar/base/content/dialogs/calendar-print-dialog.js
@@ -65,17 +65,17 @@ function loadCalendarPrintDialog() {
  * Retrieves a settings object containing info on what to print. The
  * receiverFunc will be called with the settings object containing various print
  * settings.
  *
  * @param receiverFunc  The callback function to call on completion.
  */
 function getPrintSettings(receiverFunc) {
     let tempTitle = document.getElementById("title-field").value;
-    let settings = new Object();
+    let settings = {};
     let requiresFetch = true;
     settings.title = (tempTitle || calGetString("calendar", "Untitled"));
     settings.layoutCId = document.getElementById("layout-field").value;
     settings.start = null;
     settings.end = null;
     settings.eventList = [];
     settings.printEvents = document.getElementById("events").checked;
     settings.printTasks = document.getElementById("tasks").checked;
--- a/calendar/base/content/import-export.js
+++ b/calendar/base/content/import-export.js
@@ -110,17 +110,17 @@ function loadEventsFromFile(aCalendar) {
             // XXX alert something?
             return;
         } else if (calendars.length == 1) {
             // There's only one calendar, so it's silly to ask what calendar
             // the user wants to import into.
             putItemsIntoCal(calendars[0], items, filePath);
         } else {
             // Ask what calendar to import into
-            let args = new Object();
+            let args = {};
             args.onOk = function putItems(aCal) { putItemsIntoCal(aCal, items, filePath); };
             args.calendars = calendars;
             args.promptText = calGetString("calendar", "importPrompt");
             openDialog("chrome://calendar/content/chooseCalendarDialog.xul",
                        "_blank", "chrome,titlebar,modal,resizable", args);
         }
     }
 }
@@ -335,26 +335,26 @@ function exportEntireCalendar(aCalendar)
     };
 
     function getItemsFromCal(aCal) {
         aCal.getItems(Components.interfaces.calICalendar.ITEM_FILTER_ALL_ITEMS,
                       0, null, null, getListener);
     }
 
     if (!aCalendar) {
-        var count = new Object();
+        var count = {};
         var calendars = getCalendarManager().getCalendars(count);
 
         if (count.value == 1) {
             // There's only one calendar, so it's silly to ask what calendar
             // the user wants to import into.
             getItemsFromCal(calendars[0]);
         } else {
             // Ask what calendar to import into
-            var args = new Object();
+            var args = {};
             args.onOk = getItemsFromCal;
             args.promptText = calGetString("calendar", "exportPrompt");
             openDialog("chrome://calendar/content/chooseCalendarDialog.xul",
                        "_blank", "chrome,titlebar,modal,resizable", args);
         }
     } else {
         getItemsFromCal(aCalendar);
     }
--- a/calendar/base/content/widgets/calendar-list-tree.xml
+++ b/calendar/base/content/widgets/calendar-list-tree.xml
@@ -219,26 +219,28 @@
       </xul:tree>
     </content>
     <implementation implements="nsITreeView">
 
       <field name="mCalendarList">[]</field>
       <field name="mCompositeCalendar">null</field>
       <field name="tree">null</field>
       <field name="treebox">null</field>
-      <field name="ruleCache">new Object()</field>
+      <field name="ruleCache">null</field>
       <field name="mCachedSheet">null</field>
 
-      <field name="mCycleCalendarFlag">new Object()</field>
+      <field name="mCycleCalendarFlag">null</field>
       <field name="mCycleTimer">null</field>
 
       <constructor><![CDATA[
         Components.utils.import("resource://calendar/modules/calUtils.jsm");
         Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
         this.tree.view = this;
+        this.ruleCache = {};
+        this.mCycleCalendarFlag = {};
       ]]></constructor>
       <destructor><![CDATA[
         // Clean up the calendar manager observers. Do not use removeCalendar
         // here since that will remove the calendar from the composite calendar.
         for (let calendar of this.mCalendarList) {
             calendar.removeObserver(this.calObserver);
         }
 
--- a/calendar/lightning/content/lightning-item-iframe.js
+++ b/calendar/lightning/content/lightning-item-iframe.js
@@ -1826,17 +1826,17 @@ function editAttendees() {
     if (isAllDay) {
         startTime.isDate = true;
         endTime.isDate = true;
         endTime.day += 1;
     } else {
         startTime.isDate = false;
         endTime.isDate = false;
     }
-    var args = new Object();
+    var args = {};
     args.startTime = startTime;
     args.endTime = endTime;
     args.displayTimezone = gTimezonesEnabled;
     args.attendees = window.attendees;
     args.organizer = window.organizer && window.organizer.clone();
     args.calendar = calendar;
     args.item = window.calendarItem;
     args.onOk = callback;
@@ -2507,17 +2507,17 @@ function updateCalendar() {
     updateCapabilities();
 }
 
 /**
  * Opens the recurrence dialog modally to allow the user to edit the recurrence
  * rules.
  */
 function editRepeat() {
-    var args = new Object();
+    var args = {};
     args.calendarEvent = window.calendarItem;
     args.recurrenceInfo = window.recurrenceInfo;
     args.startTime = gStartTime;
     args.endTime = gEndTime;
 
     var savedWindow = window;
     args.onOk = function(recurrenceInfo) {
         savedWindow.recurrenceInfo = recurrenceInfo;
@@ -3209,17 +3209,17 @@ function showTimezonePopup(event, dateTi
  */
 function editTimezone(aElementId, aDateTime, aCallback) {
     if (document.getElementById(aElementId)
         .hasAttribute("disabled")) {
         return;
     }
 
     // prepare the arguments that will be passed to the dialog
-    var args = new Object();
+    var args = {};
     args.time = aDateTime;
     args.calendar = getCurrentCalendar();
     args.onOk = function(datetime) {
         cal.saveRecentTimezone(datetime.timezone.tzid);
         return aCallback(datetime);
     };
 
     // open the dialog modally
--- a/calendar/lightning/content/messenger-overlay-sidebar.js
+++ b/calendar/lightning/content/messenger-overlay-sidebar.js
@@ -507,17 +507,17 @@ function ltnIntegrationNotification() {
 function ltnIntegrationCheck() {
     const kOptOut = "mail.calendar-integration.opt-out"; // default: false
     const kNotify = "calendar.integration.notify"; // default: true
     // don't do anything if the opt-out pref doesn't exist or is enabled by the user or the user has
     // already decided to keep Lightning
     if (!Preferences.get(kOptOut, true) && Preferences.get(kNotify, false)) {
         // action is only needed, if hasn't used Lightning before, so lets check whether this looks
         // like a default calendar setup
-        let cnt = new Object();
+        let cnt = {};
         let calMgr = cal.getCalendarManager();
         let cals = calMgr.getCalendars(cnt);
         let homeCalName = cal.calGetString("calendar", "homeCalendarName", null, "calendar");
         if (cnt.value == 1 &&
             calMgr.getCalendarPref_(cals[0], "type") == "storage" &&
             calMgr.getCalendarPref_(cals[0], "name") == homeCalName) {
             // this looks like a default setup, so let's see whether the calendar contains any items
             let pCal = cal.async.promisifyCalendar(cals[0]);
--- a/calendar/resources/content/publish.js
+++ b/calendar/resources/content/publish.js
@@ -8,17 +8,17 @@ Components.utils.import("resource://cale
 Components.utils.import("resource://gre/modules/Services.jsm");
 
 /**
  * publishCalendarData
  * Show publish dialog, ask for URL and publish all selected items.
  */
 function publishCalendarData()
 {
-   var args = new Object();
+   var args = {};
 
    args.onOk =  self.publishCalendarDataDialogResponse;
 
    openDialog("chrome://calendar/content/publishDialog.xul", "caPublishEvents",
               "chrome,titlebar,modal,resizable", args );
 }
 
 /**
@@ -48,17 +48,17 @@ function publishEntireCalendar(aCalendar
         if (count.value == 1) {
             // Do not ask user for calendar if only one calendar exists
             aCalendar = calendars[0];
         } else {
             // Ask user to select the calendar that should be published.
             // publishEntireCalendar() will be called again if OK is pressed
             // in the dialog and the selected calendar will be passed in.
             // Therefore return after openDialog().
-            let args = new Object();
+            let args = {};
             args.onOk = publishEntireCalendar;
             args.promptText = calGetString("calendar", "publishPrompt");
             openDialog("chrome://calendar/content/chooseCalendarDialog.xul",
                        "_blank", "chrome,titlebar,modal,resizable", args);
             return;
         }
     }
 
--- a/calendar/resources/content/publishDialog.js
+++ b/calendar/resources/content/publishDialog.js
@@ -29,17 +29,17 @@ function loadCalendarPublishDialog()
    gOnOkFunction = args.onOk;
 
    if (args.publishObject) {
       gPublishObject = args.publishObject;
       if (args.publishObject.remotePath) {
           document.getElementById( "publish-remotePath-textbox" ).value = args.publishObject.remotePath;
       }
    } else {
-      gPublishObject = new Object();
+      gPublishObject = {};
    }
    document.getElementById( "calendar-publishwindow" ).getButton( "accept" ).setAttribute( "label", publishButtonLabel );
 
    checkURLField( );
 
    var firstFocus = document.getElementById( "publish-remotePath-textbox" );
    firstFocus.focus();
 }