From 6d91eb032bd4a9cf1cf7b55796619ebf00fe8a7f Mon Sep 17 00:00:00 2001 From: eslint Date: Fri, 8 Jul 2016 11:19:26 +0200 Subject: [PATCH] Bug 1280898 - Set up eslint for calendar files - enable no-empty rule. r=MakeMyDay MozReview-Commit-ID: GTKBMVIjnmC --HG-- extra : rebase_source : ba4d6809febc5eb2ef88d245884f8ef3997bba14 --- calendar/.eslintrc | 8 +++++++- calendar/base/backend/icaljs/calICSService.js | 5 ++++- calendar/base/content/calendar-clipboard.js | 5 ++++- calendar/base/content/calendar-daypicker.xml | 9 +++------ calendar/base/content/calendar-extract.js | 9 +++++++-- .../calendar-event-dialog-recurrence.js | 2 -- .../base/content/preferences/categories.js | 2 ++ calendar/base/modules/calAuthUtils.jsm | 1 + calendar/base/modules/calProviderUtils.jsm | 4 +++- calendar/base/src/calUtils.js | 8 ++------ .../lightningTextCalendarConverter.js | 5 +++-- calendar/lightning/content/lightning-utils.js | 1 + .../content/messenger-overlay-sidebar.js | 3 +-- calendar/providers/ics/calICSCalendar.js | 10 ++++++---- calendar/providers/memory/calMemoryCalendar.js | 4 +++- .../providers/storage/calStorageUpgrade.jsm | 2 ++ calendar/providers/wcap/calWcapSession.js | 2 ++ calendar/resources/content/calendarCreation.js | 4 +++- .../datetimepickers/datetimepickers.xml | 18 ++++++++++++------ calendar/resources/content/publish.js | 2 ++ calendar/test/unit/test_alarm.js | 8 ++++++-- calendar/test/unit/test_gdata_provider.js | 4 +++- 22 files changed, 77 insertions(+), 39 deletions(-) diff --git a/calendar/.eslintrc b/calendar/.eslintrc index 8bbebfee81..a27506884b 100644 --- a/calendar/.eslintrc +++ b/calendar/.eslintrc @@ -183,6 +183,13 @@ // Always require use of semicolons wherever they are valid. "semi": [2, "always"], + // Disallow empty statements. This will report an error for: + // try { something(); } catch (e) {} + // but will not report it for: + // try { something(); } catch (e) { /* Silencing the error because ...*/ } + // which is a valid use case. + "no-empty": 2, + // Will enable these rules later "block-spacing": 0, "no-lonely-if": 0, @@ -190,7 +197,6 @@ "computed-property-spacing": 0, "consistent-return": 0, "no-redeclare": 0, - "no-empty": 0, // The following rules will not be enabled currently, but are kept here for // easier updates in the future. diff --git a/calendar/base/backend/icaljs/calICSService.js b/calendar/base/backend/icaljs/calICSService.js index baaecb2d29..c2dacf44cc 100644 --- a/calendar/base/backend/icaljs/calICSService.js +++ b/calendar/base/backend/icaljs/calICSService.js @@ -416,7 +416,10 @@ calIcalComponent.prototype = { if (dt && dt.timezone) { this._getNextParentVCalendar().addTimezoneReference(dt.timezone); } - } catch (e) {} + } catch (e) { + // If there is an issue adding the timezone reference, don't make + // that break adding the property. + } let jsprop = unwrapSingle(ICAL.Property, prop); this.innerObject.addProperty(jsprop); diff --git a/calendar/base/content/calendar-clipboard.js b/calendar/base/content/calendar-clipboard.js index 0ce0fc3587..baf87bbb68 100644 --- a/calendar/base/content/calendar-clipboard.js +++ b/calendar/base/content/calendar-clipboard.js @@ -134,7 +134,10 @@ function pasteFromClipboard() { .createInstance(Components.interfaces.calIIcsParser); try { icsParser.parseString(data); - } catch (e) {} + } catch (e) { + // Ignore parser errors from the clipboard data, if it fails + // there will just be 0 items. + } let items = icsParser.getItems({}); if (items.length == 0) { diff --git a/calendar/base/content/calendar-daypicker.xml b/calendar/base/content/calendar-daypicker.xml index 9b94d3f6c9..12508458b4 100644 --- a/calendar/base/content/calendar-daypicker.xml +++ b/calendar/base/content/calendar-daypicker.xml @@ -120,13 +120,10 @@ @@ -101,7 +103,9 @@ // format fails if year <= 1600 on win2k, so try format first. try { prettyDate = this.formatDate(date); - } catch (ex) {} // fall thru + } catch (ex) { + // Don't fail if date formatting fails. + } } if (date && prettyDate) { this.mValue = date; @@ -302,7 +306,9 @@ let formattedValue = null; try { formattedValue = this.formatDate(aValue); - } catch (ex) {} // fall thru + } catch (ex) { + // formattedValue is checked for a value below + } if (formattedValue) { // format succeeded, safe to set value @@ -1691,9 +1697,6 @@