Bug 1280898 - Set up eslint for calendar files - enable no-empty rule. r=MakeMyDay
MozReview-Commit-ID: GTKBMVIjnmC --HG-- extra : rebase_source : ba4d6809febc5eb2ef88d245884f8ef3997bba14
This commit is contained in:
Родитель
4a9acce0d7
Коммит
6d91eb032b
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -120,13 +120,10 @@
|
|||
|
||||
<constructor><![CDATA[
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
Components.utils.import("resource://gre/modules/Preferences.jsm");
|
||||
|
||||
this.weekStartOffset = Preferences.get("calendar.week.start", 0);
|
||||
|
||||
this.weekStartOffset = 0;
|
||||
try {
|
||||
this.weekStartOffset =
|
||||
Services.prefs.getIntPref("calendar.week.start");
|
||||
} catch (ex) {
|
||||
}
|
||||
var props =
|
||||
Services.strings.createBundle(
|
||||
"chrome://calendar/locale/dateFormat.properties");
|
||||
|
|
|
@ -22,7 +22,9 @@ var calendarExtract = {
|
|||
|
||||
try {
|
||||
langName = cal.calGetString("languageNames", langName, null, "global");
|
||||
} catch (ex) {}
|
||||
} catch (ex) {
|
||||
// If no language name is found that is ok, keep the technical term
|
||||
}
|
||||
|
||||
let label = cal.calGetString("calendar", "extractUsing", [langName]);
|
||||
if (localeParts[3] != "") {
|
||||
|
@ -115,7 +117,10 @@ var calendarExtract = {
|
|||
sel = document.getElementById("multimessage")
|
||||
.contentDocument.querySelector(".iframe-container iframe")
|
||||
.contentDocument.getSelection();
|
||||
} catch (ex) {}
|
||||
} catch (ex) {
|
||||
// If Thunderbird Conversations is not installed that is fine,
|
||||
// we will just have a null selection.
|
||||
}
|
||||
}
|
||||
let collected = extractor.extract(title, content, date, sel);
|
||||
|
||||
|
|
|
@ -562,8 +562,6 @@ function updateRecurrenceRange() {
|
|||
|
||||
var durationSelection = document.getElementById("recurrence-duration")
|
||||
.selectedItem.value;
|
||||
if (durationSelection == "forever") {
|
||||
}
|
||||
|
||||
if (durationSelection == "ntimes") {
|
||||
rangeTimesCount.removeAttribute("disabled");
|
||||
|
|
|
@ -129,6 +129,7 @@ var gCategoriesPane = {
|
|||
try {
|
||||
currentColor = categoryPrefBranch.getCharPref(categoryNameFix);
|
||||
} catch (ex) {
|
||||
// If the pref doesn't exist, don't bail out here.
|
||||
}
|
||||
|
||||
if (list.selectedItem) {
|
||||
|
@ -157,6 +158,7 @@ var gCategoriesPane = {
|
|||
try {
|
||||
categoryPrefBranch.clearUserPref(categoryNameFix);
|
||||
} catch (ex) {
|
||||
// If the pref doesn't exist, don't bail out here.
|
||||
}
|
||||
|
||||
// Remove category entry from listbox and gCategoryList.
|
||||
|
|
|
@ -155,6 +155,7 @@ cal.auth = {
|
|||
}
|
||||
}
|
||||
} catch (exc) {
|
||||
// If no logins are found, fall through to the return statement below.
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -260,7 +260,9 @@ cal.getEmailIdentityOfCalendar = function calGetEmailIdentityOfCalendar(aCalenda
|
|||
let identity = null;
|
||||
try {
|
||||
account = MailServices.accounts.defaultAccount;
|
||||
} catch (exc) {}
|
||||
} catch (exc) {
|
||||
// If no default account can be found that is fine
|
||||
}
|
||||
|
||||
for (let i = 0; accounts && (i < accounts.length) && (!account || !identity); ++i) {
|
||||
if (!account) { // Pick an account only if none was set (i.e there is no default account)
|
||||
|
|
|
@ -914,14 +914,10 @@ function _log(message, flag) {
|
|||
* properties should be logged.
|
||||
*/
|
||||
function LOG(aArg) {
|
||||
var shouldLog = false;
|
||||
try {
|
||||
shouldLog = Services.prefs.getBoolPref("calendar.debug.log");
|
||||
} catch (ex) {}
|
||||
|
||||
if (!shouldLog) {
|
||||
if (!Preferences.get("calendar.debug.log", false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ASSERT(aArg, "Bad log argument.", false);
|
||||
var string = aArg;
|
||||
// We should just dump() both String objects, and string primitives.
|
||||
|
|
|
@ -67,11 +67,12 @@ ltnMimeConverter.prototype = {
|
|||
let msgWindow = null;
|
||||
try {
|
||||
let msgUrl = this.uri.QueryInterface(Components.interfaces.nsIMsgMailNewsUrl);
|
||||
// msgWindow is optional in some scenarios
|
||||
// (e.g. gloda in action, throws NS_ERROR_INVALID_POINTER then)
|
||||
msgWindow = msgUrl.msgWindow;
|
||||
} catch (exc) {
|
||||
// msgWindow is optional in some scenarios
|
||||
// (e.g. gloda in action, throws NS_ERROR_INVALID_POINTER then)
|
||||
}
|
||||
|
||||
if (msgWindow) {
|
||||
let sinkProps = msgWindow.msgHeaderSink.properties;
|
||||
sinkProps.setPropertyAsInterface("itipItem", itipItem);
|
||||
|
|
|
@ -64,6 +64,7 @@ function ltnInitMailIdentitiesRow() {
|
|||
}
|
||||
menuListSelectItem("email-identity-menulist", sel ? sel.key : "none");
|
||||
} catch (exc) {
|
||||
// Don't select anything if the message identity can't be found
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -606,8 +606,7 @@ function LtnObserveDisplayDeckChange(event) {
|
|||
return;
|
||||
}
|
||||
|
||||
var id = null;
|
||||
try { id = deck.selectedPanel.id; } catch (e) { }
|
||||
let id = deck.selectedPanel && deck.selectedPanel.id;
|
||||
|
||||
// Switch back to mail mode in case we find that this
|
||||
// notification has been fired but we're still in calendar or task mode.
|
||||
|
|
|
@ -424,6 +424,7 @@ calICSCalendar.prototype = {
|
|||
httpChannel = request.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
requestSucceeded = httpChannel.requestSucceeded;
|
||||
} catch (e) {
|
||||
// This may fail if it was not a http channel, handled later on.
|
||||
}
|
||||
|
||||
if (httpChannel) {
|
||||
|
@ -675,12 +676,13 @@ calICSCalendar.prototype = {
|
|||
let file = backupDir.clone();
|
||||
file.append(filteredFiles[i].name);
|
||||
|
||||
// This can fail because of some crappy code in nsILocalFile.
|
||||
// That's not the end of the world. We can try to remove the
|
||||
// file the next time around.
|
||||
try {
|
||||
file.remove(false);
|
||||
} catch (ex) {}
|
||||
} catch (ex) {
|
||||
// This can fail because of some crappy code in
|
||||
// nsILocalFile. That's not the end of the world. We can
|
||||
// try to remove the file the next time around.
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,9 @@ calMemoryCalendar.prototype = {
|
|||
|
||||
try {
|
||||
listener.onDeleteCalendar(calendar, Components.results.NS_OK, null);
|
||||
} catch (ex) {}
|
||||
} catch (ex) {
|
||||
// Don't bail out if the listener fails
|
||||
}
|
||||
},
|
||||
|
||||
mRelaxedMode: undefined,
|
||||
|
|
|
@ -1546,6 +1546,7 @@ upgrade.v22 = function upgrade_v22(db, version) {
|
|||
try {
|
||||
ritem.count = aCount;
|
||||
} catch (exc) {
|
||||
// Don't fail if setting an invalid count
|
||||
}
|
||||
} else {
|
||||
if (aEndDate) {
|
||||
|
@ -1562,6 +1563,7 @@ upgrade.v22 = function upgrade_v22(db, version) {
|
|||
try {
|
||||
ritem.interval = aInterval;
|
||||
} catch (exc) {
|
||||
// Don't fail if setting an invalid interval
|
||||
}
|
||||
|
||||
let rtypes = {
|
||||
|
|
|
@ -812,6 +812,8 @@ calWcapSession.prototype = {
|
|||
return calendar;
|
||||
}
|
||||
} catch (exc) {
|
||||
// Fall through to the return statement below in case the uncached
|
||||
// calendar can't be retrieved.
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
|
|
@ -75,7 +75,9 @@ function onSelectProvider(type) {
|
|||
try {
|
||||
tempCal = Components.classes["@mozilla.org/calendar/calendar;1?type=" + type]
|
||||
.createInstance(Components.interfaces.calICalendar);
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
// keep tempCal undefined if the calendar can not be created
|
||||
}
|
||||
|
||||
if (tempCal && tempCal.getProperty("cache.always")) {
|
||||
cache.oldValue = cache.checked;
|
||||
|
|
|
@ -84,7 +84,9 @@
|
|||
var text = document.getAnonymousElementByAttribute(this, "anonid", "date-textbox");
|
||||
try {
|
||||
text.value = this.formatDate(val);
|
||||
} catch (ex) {}
|
||||
} catch (ex) {
|
||||
// Don't fail if date formatting fails.
|
||||
}
|
||||
return val;
|
||||
]]></setter>
|
||||
</property>
|
||||
|
@ -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 @@
|
|||
<parameter name="aValue"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
// Try/catch this, since some people are apparently
|
||||
// interested in using the datepicker in remote apps, where
|
||||
// calGetString wouldn't exist
|
||||
try {
|
||||
var noon = calGetString("dateFormat", "noon");
|
||||
if (aValue.toLowerCase() == noon.toLowerCase()) {
|
||||
|
@ -1705,6 +1708,9 @@
|
|||
return new Date(0, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
} catch (ex) {
|
||||
// Try/catch this, since some people are apparently
|
||||
// interested in using the datepicker in remote apps, where
|
||||
// calGetString wouldn't exist
|
||||
}
|
||||
|
||||
var time = null;
|
||||
|
|
|
@ -213,7 +213,9 @@ var publishingListener = {
|
|||
channel = request.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
requestSucceeded = channel.requestSucceeded;
|
||||
} catch (e) {
|
||||
// Don't fail if it is not a http channel, will be handled below
|
||||
}
|
||||
|
||||
if (channel && !requestSucceeded) {
|
||||
Services.prompt.alert(null, calGetString("calendar", "genericErrorTitle"),
|
||||
props.formatStringFromName('httpPutError', [channel.responseStatus, channel.responseStatusText], 2));
|
||||
|
|
|
@ -145,7 +145,9 @@ function test_audio_alarm() {
|
|||
try {
|
||||
alarm.addAttendee(attendee);
|
||||
do_throw("AUDIO alarm should not be able to save attendees");
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
// TODO looks like this test is disabled. Why?
|
||||
}
|
||||
|
||||
// Test attachments
|
||||
let sound = cal.createAttachment();
|
||||
|
@ -169,7 +171,9 @@ function test_audio_alarm() {
|
|||
try {
|
||||
alarm.addAttachment(sound2);
|
||||
do_throw("Adding a second attachment should fail for type AUDIO");
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
// TODO looks like this test is disabled. Why?
|
||||
}
|
||||
|
||||
// Deleting should work
|
||||
alarm.deleteAttachment(sound);
|
||||
|
|
|
@ -230,7 +230,9 @@ GDataServer.prototype = {
|
|||
try {
|
||||
body = JSON.parse(NetUtil.readInputStreamToString(request.bodyInputStream,
|
||||
request.bodyInputStream.available()));
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
// Don't bail if json parsing failed.
|
||||
}
|
||||
|
||||
this.lastMethod = method;
|
||||
return nextHandler(request, response, method, parameters, body);
|
||||
|
|
Загрузка…
Ссылка в новой задаче