Permalink
Browse files

Merge pull request #1199 from Standard8/enable-eslint

Enable ESLint using the mozilla/recommended rules.
2 parents e4781cd + b250907 commit 80bb08fb86ef22a45ad62b7703a76e38b48ab0bd @protz committed on GitHub Jun 15, 2017
View
@@ -0,0 +1,10 @@
+# Don't ignore .eslintrc.js
+!.eslintrc.js
+
+# Third party libraries.
+content/js/**
+content/gallery/js/jquery.lightbox-0.5.js
+
+# Ignore sub-module directories
+modules/stdlib/**
+content/pdfjs/**
View
@@ -0,0 +1,50 @@
+"use strict";
+
+/* eslint sort-keys: "error" */
+
+module.exports = {
+ "env": {
+ "browser": true,
+ "es6": true,
+ },
+ // "globals": {
+ // },
+ "extends": [
+ "plugin:mozilla/recommended"
+ ],
+ "plugins": [
+ "mozilla"
+ ],
+ "rules": {
+ // These are all rules that mozilla/recommended set, but we currently
+ // don't pass. We should enable these over time.
+ "brace-style": "off",
+ "comma-spacing": "off",
+ "complexity": ["error", 34],
+ "consistent-return": "off",
+ "key-spacing": "off",
+ "keyword-spacing": "off",
+ "mozilla/avoid-nsISupportsString-preferences": "off",
+ "mozilla/avoid-removeChild": "off",
+ "mozilla/no-useless-parameters": "off",
+ "mozilla/no-useless-removeEventListener": "off",
+ "mozilla/use-ownerGlobal": "off",
+ "no-else-return": "off",
+ "no-extra-bind": "off",
+ "no-extra-semi": "off",
+ "no-lonely-if": "off",
+ "no-multi-spaces": "off",
+ "no-native-reassign": "off",
+ "no-nested-ternary": "off",
+ "no-trailing-spaces": "off",
+ "no-undef": "off",
+ "no-unused-vars": "off",
+ "no-useless-call": "off",
+ "object-shorthand": "off",
+ "quotes": "off",
+ "space-before-blocks": "off",
+ "space-before-function-paren": "off",
+ "space-infix-ops": "off",
+ "spaced-comment": "off",
+ }
+};
View
@@ -3,3 +3,4 @@ gconv.jar
conversations.xpi
.vimsession
.DS_Store
+node_modules
View
@@ -0,0 +1,3 @@
+language: node_js
+node_js:
+- '8'
@@ -132,7 +132,7 @@ function init({ chunks }) {
// Strangely enough, I can't get my typed array to cross the chrome/content
// boundary, so let's make the data cross the boundary as a chunk of
// strings...
- let length = chunks.reduce(function (acc, v) acc + v.length, 0);
+ let length = chunks.reduce((acc, v) => acc + v.length, 0);
//Log.debug("chunk0", chunks[0]);
let buffer = new ArrayBuffer(length);
let array = new Uint8Array(buffer);
@@ -151,4 +151,3 @@ function init({ chunks }) {
viewer = new Viewer();
viewer.load(buffer);
}
-
@@ -229,7 +229,7 @@ BzComposeSession.prototype = {
// Remove the old stored draft, don't use onDiscard, because the
// compose params might have changed in the meanwhile.
if (id)
- SimpleStorage.spin(function () {
+ SimpleStorage.spin(function* () {
yield ss.remove(id);
yield SimpleStorage.kWorkDone;
});
View
@@ -172,7 +172,7 @@ function newComposeSessionByDraftIf() {
return;
}
- SimpleStorage.spin(function () {
+ SimpleStorage.spin(function* () {
let r = yield ss.get(id);
if (r) {
gComposeSession = createComposeSession(x => x.draft(r));
@@ -289,7 +289,7 @@ function onDiscard(event) {
gComposeSession = null;
let id = Conversations.currentConversation.id;
if (id)
- SimpleStorage.spin(function () {
+ SimpleStorage.spin(function* () {
let r = yield ss.remove(id);
gDraftListener.notifyDraftChanged("removed");
yield SimpleStorage.kWorkDone;
@@ -312,7 +312,7 @@ function onSave(k) {
// Second codepath. Heh, got some work to do.
Log.debug("Saving because there's a compose session");
- SimpleStorage.spin(function () {
+ SimpleStorage.spin(function* () {
let id = Conversations.currentConversation.id; // Gloda ID
if (id) {
yield ss.set(id, {
@@ -460,7 +460,7 @@ ComposeSession.prototype = {
*/
cycleSender: function (dir) {
let self = this;
- let index = getIdentities().findIndex(function (ident) ident.identity == self.params.identity);
+ let index = getIdentities().findIndex((ident) => ident.identity == self.params.identity);
index = (index + dir + getIdentities().length) % getIdentities().length;
this.params.identity = getIdentities()[index].identity;
this.senderNameElem.text(this.params.identity.email);
@@ -545,7 +545,7 @@ ComposeSession.prototype = {
},
draft: function ({ msgUri }) {
- let last = function (a) a[a.length-1];
+ let last = (a) => a[a.length-1];
let msgHdr = msgUriToMsgHdr(msgUri);
self.params.msgHdr = msgHdr || last(Conversations.currentConversation.msgHdrs);
self.params.subject = "Re: "+self.params.msgHdr.mime2DecodedSubject;
@@ -1259,7 +1259,7 @@ function createStateListener (aComposeSession, aMsgHdrs, aId) {
// Remove the old stored draft, don't use onDiscard, because the compose
// params might have changed in the meanwhile.
if (aId)
- SimpleStorage.spin(function () {
+ SimpleStorage.spin(function* () {
yield ss.remove(aId);
yield SimpleStorage.kWorkDone;
});
View
@@ -70,7 +70,6 @@ function PrefCustomization({ name, type, value }) {
this.type = type;
this.name = name;
this.desiredValue = value;
- return
}
PrefCustomization.prototype = {
@@ -104,7 +103,7 @@ MixIn(PrefCustomization, SimpleCustomization.prototype);
function MultipleCustomization(aParams) {
- this.customizations = !!aParams ? aParams.map(p => new PrefCustomization(p)) : [];
+ this.customizations = aParams ? aParams.map(p => new PrefCustomization(p)) : [];
}
MultipleCustomization.prototype = {
@@ -332,8 +331,12 @@ let Customizations = {
try {
account.incomingServer.QueryInterface(Ci.nsIImapIncomingServer);
isImap = true;
- } catch (e if e.result == Cr.NS_NOINTERFACE) {
- isImap = false;
+ } catch (e) {
+ if (e.result == Cr.NS_NOINTERFACE) {
+ isImap = false;
+ } else {
+ throw e;
+ }
}
if (!isImap)
continue;
View
@@ -547,7 +547,10 @@ Message.prototype = {
let url = this.bugzillaInfos["url"];
let uri = Services.io.newURI(url, null, null);
data.bugzillaUrl = url;
- } catch (e if e.result == Cr.NS_ERROR_MALFORMED_URI) {
+ } catch (e) {
+ if (e.result != Cr.NS_ERROR_MALFORMED_URI) {
+ throw e;
+ }
// why not?
}
}
View
@@ -80,7 +80,7 @@ MonkeyPatch.prototype = {
undo: function _MonkeyPatch_undo(aReason) {
let f;
- while (f = this._undoFuncs.pop()) {
+ while ((f = this._undoFuncs.pop())) {
try {
f(aReason);
} catch (e) {
@@ -251,7 +251,7 @@ MonkeyPatch.prototype = {
// So our solution kinda works, but registering the thing at jsm load-time
// would work as well.
}
- this.pushUndo(function () window.gDBView.removeColumnHandler("betweenCol"));
+ this.pushUndo(() => window.gDBView.removeColumnHandler("betweenCol"));
},
registerFontPrefObserver: function _MonkeyPatch_registerFontPref (aHtmlpane) {
View
@@ -193,7 +193,11 @@ function convertForwardedToBlockquote(aDoc) {
};
try {
walk(aDoc.body);
- } catch ( { found } if found) { }
+ } catch ( { found }) {
+ if (!found) {
+ throw new Error();
+ }
+ }
}
/* If [b1] is a blockquote followed by [ns] whitespace nodes followed by [b2],
@@ -62,8 +62,9 @@ let hook = {
let iframeDoc = iframe.contentDocument;
let links = iframeDoc.getElementsByTagName("a");
// Don't detect links in quotations.
- [x.skip = true
- for (x of iframeDoc.querySelectorAll("blockquote a"))];
+ for (x of iframe.querySelectorAll("blockquote a")) {
+ x.skip = true;
+ }
let seen = {};
// Examine all links in the message.
for (let a of links) {
@@ -90,7 +91,7 @@ let hook = {
Log.debug("Load event", req.responseXML, req.responseText);
if (!req.responseXML)
return;
- let getAttr = function (attrName)
+ let getAttr = (attrName) =>
req.responseXML.getElementsByTagName(attrName)[0].textContent;
self.insertDesc(getAttr("title"), getAttr("author_name"), getAttr("url"), a.href, aDomNode);
});
Oops, something went wrong.

0 comments on commit 80bb08f

Please sign in to comment.