зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1160496 - Enable eslint rules for Loop: General code format. r=Standard8
This commit is contained in:
Родитель
a8a1204a19
Коммит
19eccd05d6
|
@ -35,9 +35,6 @@
|
|||
// Eslint built-in rules are documented at <http://eslint.org/docs/rules/>
|
||||
"camelcase": 0, // TODO: Remove (use default)
|
||||
"consistent-return": 0, // TODO: Remove (use default)
|
||||
"curly": 0, // TODO: Remove (use default)
|
||||
"dot-notation": 0, // TODO: Remove (use default)
|
||||
"eol-last": 0, // TODO: Remove (use default)
|
||||
"eqeqeq": 0, // TBD. Might need to be separate for content & chrome
|
||||
"global-strict": 0, // Leave as zero (this will be unsupported in eslint 1.0.0)
|
||||
"key-spacing": 0, // TODO: Remove (use default)
|
||||
|
@ -60,10 +57,7 @@
|
|||
"no-use-before-define": 0, // TODO: Remove (use default)
|
||||
"no-wrap-func": 0, // TODO: Remove (use default)
|
||||
"quotes": 0, // [2, "double", "avoid-escape"],
|
||||
"space-infix-ops": 0, // TODO: Remove (use default)
|
||||
"space-return-throw-case": 0, // TODO: Remove (use default)
|
||||
"strict": 0, // [2, "function"],
|
||||
"yoda": 0, // [2, "never"],
|
||||
// eslint-plugin-react rules. These are documented at
|
||||
// <https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules>
|
||||
"react/jsx-quotes": [2, "double", "avoid-escape"],
|
||||
|
|
|
@ -693,7 +693,7 @@ loop.contacts = (function(_, mozL10n) {
|
|||
};
|
||||
var tel = this.state.tel.trim();
|
||||
if (!!tel) {
|
||||
contact["tel"] = [{
|
||||
contact.tel = [{
|
||||
pref: true,
|
||||
type: ["fxos"],
|
||||
value: tel
|
||||
|
|
|
@ -693,7 +693,7 @@ loop.contacts = (function(_, mozL10n) {
|
|||
};
|
||||
var tel = this.state.tel.trim();
|
||||
if (!!tel) {
|
||||
contact["tel"] = [{
|
||||
contact.tel = [{
|
||||
pref: true,
|
||||
type: ["fxos"],
|
||||
value: tel
|
||||
|
|
|
@ -461,8 +461,9 @@ loop.roomViews = (function(mozL10n) {
|
|||
},
|
||||
|
||||
render: function() {
|
||||
if (!this.state.show && !this.state.editMode)
|
||||
if (!this.state.show && !this.state.editMode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var url = this._getURL();
|
||||
var thumbnail = url && url.thumbnail || "";
|
||||
|
|
|
@ -461,8 +461,9 @@ loop.roomViews = (function(mozL10n) {
|
|||
},
|
||||
|
||||
render: function() {
|
||||
if (!this.state.show && !this.state.editMode)
|
||||
if (!this.state.show && !this.state.editMode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var url = this._getURL();
|
||||
var thumbnail = url && url.thumbnail || "";
|
||||
|
|
|
@ -464,7 +464,7 @@ loop.store.ActiveRoomStore = (function() {
|
|||
this._setRefreshTimeout(actionData.expires);
|
||||
|
||||
// Only send media telemetry on one side of the call: the desktop side.
|
||||
actionData["sendTwoWayMediaTelemetry"] = this._isDesktop;
|
||||
actionData.sendTwoWayMediaTelemetry = this._isDesktop;
|
||||
|
||||
this._sdkDriver.connectSession(actionData);
|
||||
|
||||
|
|
|
@ -120,10 +120,12 @@ loop.shared.mixins = (function() {
|
|||
if (!menu) {
|
||||
return;
|
||||
}
|
||||
if (menu.style.maxWidth)
|
||||
if (menu.style.maxWidth) {
|
||||
menu.style.maxWidth = "none";
|
||||
if (menu.style.maxHeight)
|
||||
}
|
||||
if (menu.style.maxHeight) {
|
||||
menu.style.maxHeight = "none";
|
||||
}
|
||||
|
||||
// Correct the position of the menu only if necessary.
|
||||
var x, y, boundingBox, boundingRect;
|
||||
|
@ -453,7 +455,7 @@ loop.shared.mixins = (function() {
|
|||
remoteVideoDimensions.streamWidth = leadingAxis === "width" ?
|
||||
remoteVideoDimensions.width : slaveAxisSize;
|
||||
remoteVideoDimensions.streamHeight = leadingAxis === "height" ?
|
||||
remoteVideoDimensions.height: slaveAxisSize;
|
||||
remoteVideoDimensions.height : slaveAxisSize;
|
||||
} else {
|
||||
// If the leading axis is not "full" then we need to adjust it, based
|
||||
// on the length of the leading axis.
|
||||
|
@ -462,7 +464,7 @@ loop.shared.mixins = (function() {
|
|||
remoteVideoDimensions.streamWidth = leadingAxis === "height" ?
|
||||
remoteVideoDimensions.width : leadingAxisSize;
|
||||
remoteVideoDimensions.streamHeight = leadingAxis === "width" ?
|
||||
remoteVideoDimensions.height: leadingAxisSize;
|
||||
remoteVideoDimensions.height : leadingAxisSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,12 +29,18 @@ loop.validate = (function() {
|
|||
* @return {String}
|
||||
*/
|
||||
function typeName(obj) {
|
||||
if (obj === null)
|
||||
if (obj === null) {
|
||||
return "null";
|
||||
if (typeof obj === "function")
|
||||
}
|
||||
|
||||
if (typeof obj === "function") {
|
||||
return obj.name || obj.toString().match(/^function\s?([^\s(]*)/)[1];
|
||||
if (typeof obj.constructor === "function")
|
||||
}
|
||||
|
||||
if (typeof obj.constructor === "function") {
|
||||
return typeName(obj.constructor);
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
|
@ -93,8 +99,9 @@ loop.validate = (function() {
|
|||
return typeof values[name] !== "undefined";
|
||||
});
|
||||
var diff = difference(Object.keys(this.schema), definedProperties);
|
||||
if (diff.length > 0)
|
||||
if (diff.length > 0) {
|
||||
throw new TypeError("missing required " + diff.join(", "));
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -106,8 +106,9 @@ const getPreferred = function(contact, which = "email") {
|
|||
* @param {Boolean} encode Whether to URLEncode the param string
|
||||
*/
|
||||
const getUrlParam = function(paramValue, prefName, encode = true) {
|
||||
if (Services.prefs.getPrefType(prefName))
|
||||
if (Services.prefs.getPrefType(prefName)) {
|
||||
paramValue = Services.prefs.getCharPref(prefName);
|
||||
}
|
||||
paramValue = Services.urlFormatter.formatURL(paramValue);
|
||||
|
||||
return encode ? encodeURIComponent(paramValue) : paramValue;
|
||||
|
|
|
@ -324,8 +324,9 @@ let LoopCallsInternal = {
|
|||
* @return true if the call is opened, false if it is not opened (i.e. busy)
|
||||
*/
|
||||
startDirectCall: function(contact, callType) {
|
||||
if ("id" in this.conversationInProgress)
|
||||
if ("id" in this.conversationInProgress) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var callData = {
|
||||
contact: contact,
|
||||
|
|
|
@ -724,8 +724,9 @@ let MozLoopServiceInternal = {
|
|||
* @returns {Map} a map of element ids with localized string values
|
||||
*/
|
||||
get localizedStrings() {
|
||||
if (gLocalizedStrings.size)
|
||||
if (gLocalizedStrings.size) {
|
||||
return gLocalizedStrings;
|
||||
}
|
||||
|
||||
let stringBundle =
|
||||
Services.strings.createBundle("chrome://browser/locale/loop/loop.properties");
|
||||
|
@ -765,7 +766,7 @@ let MozLoopServiceInternal = {
|
|||
|
||||
let ai = Services.appinfo;
|
||||
let uuid = uuidgen.generateUUID().toString();
|
||||
uuid = uuid.substr(1, uuid.length-2); // remove uuid curly braces
|
||||
uuid = uuid.substr(1, uuid.length - 2); // remove uuid curly braces
|
||||
|
||||
let directory = OS.Path.join(OS.Constants.Path.profileDir,
|
||||
"saved-telemetry-pings");
|
||||
|
@ -895,7 +896,7 @@ let MozLoopServiceInternal = {
|
|||
var pair = pc.id.split("("); //)
|
||||
if (pair.length == 2) {
|
||||
pc.id = pair[0] + "(session=" + context.sessionId +
|
||||
(context.callId? " call=" + context.callId : "") + " " + pair[1]; //)
|
||||
(context.callId ? " call=" + context.callId : "") + " " + pair[1]; //)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ loop.standaloneRoomViews = (function(mozL10n) {
|
|||
);
|
||||
}
|
||||
case ROOM_STATES.ENDED: {
|
||||
if (this.props.roomUsed)
|
||||
if (this.props.roomUsed) {
|
||||
return (
|
||||
React.createElement("div", {className: "ended-conversation"},
|
||||
React.createElement(sharedViews.FeedbackView, {
|
||||
|
@ -134,6 +134,7 @@ loop.standaloneRoomViews = (function(mozL10n) {
|
|||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// In case the room was not used (no one was here), we
|
||||
// bypass the feedback form.
|
||||
|
|
|
@ -126,7 +126,7 @@ loop.standaloneRoomViews = (function(mozL10n) {
|
|||
);
|
||||
}
|
||||
case ROOM_STATES.ENDED: {
|
||||
if (this.props.roomUsed)
|
||||
if (this.props.roomUsed) {
|
||||
return (
|
||||
<div className="ended-conversation">
|
||||
<sharedViews.FeedbackView
|
||||
|
@ -134,6 +134,7 @@ loop.standaloneRoomViews = (function(mozL10n) {
|
|||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// In case the room was not used (no one was here), we
|
||||
// bypass the feedback form.
|
||||
|
|
|
@ -115,7 +115,7 @@ describe("loop.Client", function() {
|
|||
|
||||
sinon.assert.calledOnce(callback);
|
||||
sinon.assert.calledWithExactly(callback, sinon.match(function(err) {
|
||||
return err.code == 400 && "invalid token" == err.message;
|
||||
return err.code == 400 && err.message == "invalid token";
|
||||
}));
|
||||
});
|
||||
|
||||
|
|
|
@ -476,7 +476,7 @@ describe("loop.contacts", function() {
|
|||
var contact = {fakeField: [{value: "foobar"}]};
|
||||
loop.contacts._setPreferred(contact, "fakeField", "");
|
||||
|
||||
expect(contact["fakeField"][0].value).to.eql("");
|
||||
expect(contact.fakeField[0].value).to.eql("");
|
||||
});
|
||||
|
||||
it("should set the value on the object if the new value is empty," +
|
||||
|
@ -484,7 +484,7 @@ describe("loop.contacts", function() {
|
|||
var contact = {fakeField: [{value: "foobar"}]};
|
||||
loop.contacts._setPreferred(contact, "fakeField", "barbaz");
|
||||
|
||||
expect(contact["fakeField"][0].value).to.eql("barbaz");
|
||||
expect(contact.fakeField[0].value).to.eql("barbaz");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -54,8 +54,9 @@ describe("loop.conversationViews", function () {
|
|||
send: function() {},
|
||||
abort: function() {},
|
||||
getResponseHeader: function(header) {
|
||||
if (header === "Content-Type")
|
||||
if (header === "Content-Type") {
|
||||
return "audio/ogg";
|
||||
}
|
||||
},
|
||||
responseType: null,
|
||||
response: new ArrayBuffer(10),
|
||||
|
@ -87,7 +88,7 @@ describe("loop.conversationViews", function () {
|
|||
};
|
||||
sinon.stub(fakeMozLoop, "getLoopPref", function(pref) {
|
||||
if (pref === "fake") {
|
||||
return"http://fakeurl";
|
||||
return "http://fakeurl";
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -390,8 +390,10 @@ describe("loop.panel", function() {
|
|||
beforeEach(function() {
|
||||
supportUrl = "https://example.com";
|
||||
navigator.mozLoop.getLoopPref = function(pref) {
|
||||
if (pref === "support_url")
|
||||
if (pref === "support_url") {
|
||||
return supportUrl;
|
||||
}
|
||||
|
||||
return "unseen";
|
||||
};
|
||||
});
|
||||
|
|
|
@ -240,14 +240,16 @@ function promiseTabLoadEvent(tab, url, eventType="load") {
|
|||
}
|
||||
|
||||
let timeout = setTimeout(() => {
|
||||
if (tab.linkedBrowser)
|
||||
if (tab.linkedBrowser) {
|
||||
tab.linkedBrowser.removeEventListener(eventType, handle, true);
|
||||
}
|
||||
reject(new Error("Timed out while waiting for a '" + eventType + "'' event"));
|
||||
}, 30000);
|
||||
|
||||
tab.linkedBrowser.addEventListener(eventType, handle, true, true);
|
||||
if (url)
|
||||
if (url) {
|
||||
tab.linkedBrowser.loadURI(url);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ describe("loop.Dispatcher", function () {
|
|||
|
||||
dispatcher.register(object, ["getWindowData"]);
|
||||
|
||||
expect(dispatcher._eventData["getWindowData"][0]).eql(object);
|
||||
expect(dispatcher._eventData.getWindowData[0]).eql(object);
|
||||
});
|
||||
|
||||
it("should register multiple store against an action name", function() {
|
||||
|
@ -34,8 +34,8 @@ describe("loop.Dispatcher", function () {
|
|||
dispatcher.register(object1, ["getWindowData"]);
|
||||
dispatcher.register(object2, ["getWindowData"]);
|
||||
|
||||
expect(dispatcher._eventData["getWindowData"][0]).eql(object1);
|
||||
expect(dispatcher._eventData["getWindowData"][1]).eql(object2);
|
||||
expect(dispatcher._eventData.getWindowData[0]).eql(object1);
|
||||
expect(dispatcher._eventData.getWindowData[1]).eql(object2);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -33,8 +33,9 @@ describe("loop.shared.views", function() {
|
|||
send: function() {},
|
||||
abort: function() {},
|
||||
getResponseHeader: function(header) {
|
||||
if (header === "Content-Type")
|
||||
if (header === "Content-Type") {
|
||||
return "audio/ogg";
|
||||
}
|
||||
},
|
||||
responseType: null,
|
||||
response: new ArrayBuffer(10),
|
||||
|
@ -552,8 +553,9 @@ describe("loop.shared.views", function() {
|
|||
|
||||
beforeEach(function() {
|
||||
// In standalone, navigator.mozLoop does not exists
|
||||
if (navigator.hasOwnProperty("mozLoop"))
|
||||
if (navigator.hasOwnProperty("mozLoop")) {
|
||||
sandbox.stub(navigator, "mozLoop", undefined);
|
||||
}
|
||||
});
|
||||
|
||||
it("should play a connected sound, once, on session:connected",
|
||||
|
|
|
@ -13,7 +13,7 @@ describe("loop.standaloneMedia._MultiplexGum", function() {
|
|||
navigator.getUserMedia ||
|
||||
navigator.mozGetUserMedia ||
|
||||
navigator.webkitGetUserMedia ||
|
||||
(window["TBPlugin"] && TBPlugin.getUserMedia);
|
||||
(window.TBPlugin && TBPlugin.getUserMedia);
|
||||
|
||||
var sandbox;
|
||||
var multiplexGum;
|
||||
|
|
|
@ -40,8 +40,9 @@ describe("loop.webapp", function() {
|
|||
send: function() {},
|
||||
abort: function() {},
|
||||
getResponseHeader: function(header) {
|
||||
if (header === "Content-Type")
|
||||
if (header === "Content-Type") {
|
||||
return "audio/ogg";
|
||||
}
|
||||
},
|
||||
responseType: null,
|
||||
response: new ArrayBuffer(10),
|
||||
|
@ -1013,8 +1014,9 @@ describe("loop.webapp", function() {
|
|||
});
|
||||
|
||||
afterEach(function() {
|
||||
if (oldLocalStorageValue !== null)
|
||||
if (oldLocalStorageValue !== null) {
|
||||
localStorage.setItem("has-seen-tos", oldLocalStorageValue);
|
||||
}
|
||||
});
|
||||
|
||||
it("should show the TOS", function() {
|
||||
|
|
|
@ -462,7 +462,7 @@ add_task(function* test_refresh() {
|
|||
// Test if push updates function as expected.
|
||||
add_task(function* test_roomUpdates() {
|
||||
gExpectedUpdates.push("_nxD4V4FflQ");
|
||||
gExpectedLeaves["_nxD4V4FflQ"] = [
|
||||
gExpectedLeaves._nxD4V4FflQ = [
|
||||
"2a1787a6-4a73-43b5-ae3e-906ec1e763cb",
|
||||
"781f012b-f1ea-4ce1-9105-7cfc36fb4ec7"
|
||||
];
|
||||
|
@ -471,21 +471,21 @@ add_task(function* test_roomUpdates() {
|
|||
gExpectedUpdates.length === 0);
|
||||
|
||||
gExpectedUpdates.push("_nxD4V4FflQ");
|
||||
gExpectedJoins["_nxD4V4FflQ"] = ["2a1787a6-4a73-43b5-ae3e-906ec1e763cb"];
|
||||
gExpectedJoins._nxD4V4FflQ = ["2a1787a6-4a73-43b5-ae3e-906ec1e763cb"];
|
||||
roomsPushNotification("2", kChannelGuest);
|
||||
yield waitForCondition(() => Object.getOwnPropertyNames(gExpectedJoins).length === 0 &&
|
||||
gExpectedUpdates.length === 0);
|
||||
|
||||
gExpectedUpdates.push("_nxD4V4FflQ");
|
||||
gExpectedJoins["_nxD4V4FflQ"] = ["781f012b-f1ea-4ce1-9105-7cfc36fb4ec7"];
|
||||
gExpectedLeaves["_nxD4V4FflQ"] = ["2a1787a6-4a73-43b5-ae3e-906ec1e763cb"];
|
||||
gExpectedJoins._nxD4V4FflQ = ["781f012b-f1ea-4ce1-9105-7cfc36fb4ec7"];
|
||||
gExpectedLeaves._nxD4V4FflQ = ["2a1787a6-4a73-43b5-ae3e-906ec1e763cb"];
|
||||
roomsPushNotification("3", kChannelGuest);
|
||||
yield waitForCondition(() => Object.getOwnPropertyNames(gExpectedLeaves).length === 0 &&
|
||||
Object.getOwnPropertyNames(gExpectedJoins).length === 0 &&
|
||||
gExpectedUpdates.length === 0);
|
||||
|
||||
gExpectedUpdates.push("_nxD4V4FflQ");
|
||||
gExpectedJoins["_nxD4V4FflQ"] = [
|
||||
gExpectedJoins._nxD4V4FflQ = [
|
||||
"2a1787a6-4a73-43b5-ae3e-906ec1e763cb",
|
||||
"5de6281c-6568-455f-af08-c0b0a973100e"];
|
||||
roomsPushNotification("4", kChannelGuest);
|
||||
|
@ -507,7 +507,7 @@ add_task(function* test_channelIdsRespected() {
|
|||
MozLoopServiceInternal.fxAOAuthProfile = { email: "fake@invalid.com" };
|
||||
|
||||
gExpectedUpdates.push("_nxD4V4FflQ");
|
||||
gExpectedLeaves["_nxD4V4FflQ"] = [
|
||||
gExpectedLeaves._nxD4V4FflQ = [
|
||||
"2a1787a6-4a73-43b5-ae3e-906ec1e763cb",
|
||||
"5de6281c-6568-455f-af08-c0b0a973100e"
|
||||
];
|
||||
|
|
Загрузка…
Ссылка в новой задаче