Fix ESLint errors and add eqeqeq rule (#66)
This commit is contained in:
parent
b5a6a2cb6a
commit
8bcfae7bed
3 changed files with 28 additions and 40 deletions
24
.eslintrc.js
24
.eslintrc.js
|
@ -1,25 +1,15 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true,
|
"browser": true,
|
||||||
"es6": true
|
"es6": true,
|
||||||
|
"node": true
|
||||||
},
|
},
|
||||||
"extends": "eslint:recommended",
|
"extends": "eslint:recommended",
|
||||||
"rules": {
|
"rules": {
|
||||||
"indent": [
|
"eqeqeq": "error",
|
||||||
"error",
|
"indent": ["error", 2],
|
||||||
2
|
"linebreak-style": ["error", "unix"],
|
||||||
],
|
"quotes": ["error", "double"],
|
||||||
"linebreak-style": [
|
"semi": ["error", "always"]
|
||||||
"error",
|
|
||||||
"unix"
|
|
||||||
],
|
|
||||||
"quotes": [
|
|
||||||
"error",
|
|
||||||
"double"
|
|
||||||
],
|
|
||||||
"semi": [
|
|
||||||
"error",
|
|
||||||
"always"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
42
index.js
42
index.js
|
@ -1,9 +1,7 @@
|
||||||
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||||
|
|
||||||
/* global require */
|
|
||||||
|
|
||||||
const { attachTo } = require("sdk/content/mod");
|
const { attachTo } = require("sdk/content/mod");
|
||||||
const {ContextualIdentityService} = require("resource://gre/modules/ContextualIdentityService.jsm");
|
const { ContextualIdentityService } = require("resource://gre/modules/ContextualIdentityService.jsm");
|
||||||
const self = require("sdk/self");
|
const self = require("sdk/self");
|
||||||
const { Style } = require("sdk/stylesheet/style");
|
const { Style } = require("sdk/stylesheet/style");
|
||||||
const tabs = require("sdk/tabs");
|
const tabs = require("sdk/tabs");
|
||||||
|
@ -41,14 +39,14 @@ let ContainerService = {
|
||||||
"sortTabs",
|
"sortTabs",
|
||||||
"openTab",
|
"openTab",
|
||||||
"queryIdentities",
|
"queryIdentities",
|
||||||
"getIdentity",
|
"getIdentity"
|
||||||
];
|
];
|
||||||
|
|
||||||
// Map of identities.
|
// Map of identities.
|
||||||
ContextualIdentityService.getIdentities().forEach(identity => {
|
ContextualIdentityService.getIdentities().forEach(identity => {
|
||||||
this._identitiesState[identity.userContextId] = {
|
this._identitiesState[identity.userContextId] = {
|
||||||
hiddenTabUrls: [],
|
hiddenTabUrls: [],
|
||||||
openTabs: 0,
|
openTabs: 0
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -91,7 +89,7 @@ let ContainerService = {
|
||||||
|
|
||||||
webExtension.startup().then(api => {
|
webExtension.startup().then(api => {
|
||||||
api.browser.runtime.onMessage.addListener((message, sender, sendReply) => {
|
api.browser.runtime.onMessage.addListener((message, sender, sendReply) => {
|
||||||
if ("method" in message && methods.indexOf(message.method) != -1) {
|
if ("method" in message && methods.indexOf(message.method) !== -1) {
|
||||||
sendReply(this[message.method](message));
|
sendReply(this[message.method](message));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -106,31 +104,31 @@ let ContainerService = {
|
||||||
// we map URLs to svg IDs.
|
// we map URLs to svg IDs.
|
||||||
let image, color;
|
let image, color;
|
||||||
|
|
||||||
if (identity.icon == "fingerprint" ||
|
if (identity.icon === "fingerprint" ||
|
||||||
identity.icon == "chrome://browser/skin/usercontext/personal.svg") {
|
identity.icon === "chrome://browser/skin/usercontext/personal.svg") {
|
||||||
image = "fingerprint";
|
image = "fingerprint";
|
||||||
} else if (identity.icon == "briefcase" ||
|
} else if (identity.icon === "briefcase" ||
|
||||||
identity.icon == "chrome://browser/skin/usercontext/work.svg") {
|
identity.icon === "chrome://browser/skin/usercontext/work.svg") {
|
||||||
image = "briefcase";
|
image = "briefcase";
|
||||||
} else if (identity.icon == "dollar" ||
|
} else if (identity.icon === "dollar" ||
|
||||||
identity.icon == "chrome://browser/skin/usercontext/banking.svg") {
|
identity.icon === "chrome://browser/skin/usercontext/banking.svg") {
|
||||||
image = "dollar";
|
image = "dollar";
|
||||||
} else if (identity.icon == "cart" ||
|
} else if (identity.icon === "cart" ||
|
||||||
identity.icon == "chrome://browser/skin/usercontext/shopping.svg") {
|
identity.icon === "chrome://browser/skin/usercontext/shopping.svg") {
|
||||||
image = "cart";
|
image = "cart";
|
||||||
} else {
|
} else {
|
||||||
image = "circle";
|
image = "circle";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (identity.color == "#00a7e0") {
|
if (identity.color === "#00a7e0") {
|
||||||
color = "blue";
|
color = "blue";
|
||||||
} else if (identity.color == "#f89c24") {
|
} else if (identity.color === "#f89c24") {
|
||||||
color = "orange";
|
color = "orange";
|
||||||
} else if (identity.color == "#7dc14c") {
|
} else if (identity.color === "#7dc14c") {
|
||||||
color = "green";
|
color = "green";
|
||||||
} else if (identity.color == "#ee5195") {
|
} else if (identity.color === "#ee5195") {
|
||||||
color = "pink";
|
color = "pink";
|
||||||
} else if (["blue", "turquoise", "green", "yellow", "orange", "red", "pink", "purple"].indexOf(identity.color) != -1) {
|
} else if (["blue", "turquoise", "green", "yellow", "orange", "red", "pink", "purple"].indexOf(identity.color) !== -1) {
|
||||||
color = identity.color;
|
color = identity.color;
|
||||||
} else {
|
} else {
|
||||||
color = "";
|
color = "";
|
||||||
|
@ -142,7 +140,7 @@ let ContainerService = {
|
||||||
color,
|
color,
|
||||||
userContextId: identity.userContextId,
|
userContextId: identity.userContextId,
|
||||||
hasHiddenTabs: !!this._identitiesState[identity.userContextId].hiddenTabUrls.length,
|
hasHiddenTabs: !!this._identitiesState[identity.userContextId].hiddenTabUrls.length,
|
||||||
hasOpenTabs: !!this._identitiesState[identity.userContextId].openTabs,
|
hasOpenTabs: !!this._identitiesState[identity.userContextId].openTabs
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -154,7 +152,7 @@ let ContainerService = {
|
||||||
let xulTab = viewFor(tab);
|
let xulTab = viewFor(tab);
|
||||||
let userContextId = parseInt(xulTab.getAttribute("usercontextid") || 0, 10);
|
let userContextId = parseInt(xulTab.getAttribute("usercontextid") || 0, 10);
|
||||||
|
|
||||||
if ("userContextId" in args && args.userContextId != userContextId) {
|
if ("userContextId" in args && args.userContextId !== userContextId) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,7 +294,7 @@ let ContainerService = {
|
||||||
let style = Style({ uri: self.data.url("chrome.css") });
|
let style = Style({ uri: self.data.url("chrome.css") });
|
||||||
|
|
||||||
attachTo(style, viewFor(window));
|
attachTo(style, viewFor(window));
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ContainerService.init();
|
ContainerService.init();
|
||||||
|
|
|
@ -111,7 +111,7 @@ browser.runtime.sendMessage({method: "queryIdentities"}).then(identities => {
|
||||||
showOrHideContainerTabs(identity.userContextId, true).then(() => {
|
showOrHideContainerTabs(identity.userContextId, true).then(() => {
|
||||||
browser.runtime.sendMessage({
|
browser.runtime.sendMessage({
|
||||||
method: "openTab",
|
method: "openTab",
|
||||||
userContextId: identity.userContextId,
|
userContextId: identity.userContextId
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
window.close();
|
window.close();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue