Bug 1329012 - Enable the no-useless-call rule for eslint and fix the nine errors that it caught. r=mossop

MozReview-Commit-ID: 57vvfJlyvfW

--HG--
extra : rebase_source : 793106837614bc6756409712d8683a64f2096522
This commit is contained in:
Jared Wein 2017-01-05 12:56:53 -05:00
Родитель 5fb888d27d
Коммит ba08da0b5d
7 изменённых файлов: 10 добавлений и 5 удалений

Просмотреть файл

@ -72,7 +72,7 @@ var gPluginHandler = {
case "managePlugins":
case "openHelpPage":
case "openPluginUpdatePage":
this[msg.data.name].call(this, msg.data.pluginTag);
this[msg.data.name](msg.data.pluginTag);
break;
}
break;

Просмотреть файл

@ -196,6 +196,9 @@ module.exports = {
// No using variables before defined
// "no-use-before-define": ["error", "nofunc"],
// Disallow unnecessary .call() and .apply()
"no-useless-call": "error",
// No using with
"no-with": "error",

Просмотреть файл

@ -2493,6 +2493,7 @@ function run_function_tests(library) {
do_check_eq(ptr("function pointers rule!"), 23);
// Test that we can call via call and apply
/* eslint-disable no-useless-call */
do_check_eq(ptr.call(null, "function pointers rule!"), 23);
do_check_eq(ptr.apply(null, ["function pointers rule!"]), 23);
@ -2501,6 +2502,7 @@ function run_function_tests(library) {
let p = p_t();
do_check_throws(function() { p.call(null, "woo"); }, TypeError);
do_check_throws(function() { p.apply(null, ["woo"]); }, TypeError);
/* eslint-enable no-useless-call */
// Test the function pointers still behave as regular pointers
do_check_false(ptr.isNull(), "PointerType methods should still be valid");

Просмотреть файл

@ -233,7 +233,7 @@ this.IntegrationPoint.prototype = {
try {
// Obtain a new set of methods from the next override function in the
// list, specifying the current combined object as the base argument.
let override = overrideFn.call(null, combined);
let override = overrideFn(combined);
// Retrieve a list of property descriptors from the returned object, and
// use them to build a new combined object whose prototype points to the

Просмотреть файл

@ -382,7 +382,7 @@ this.Promise = function Promise(aExecutor) {
.bind(PromiseWalker, this, STATUS_REJECTED);
try {
aExecutor.call(undefined, resolve, reject);
aExecutor(resolve, reject);
} catch (ex) {
reject(ex);
}

Просмотреть файл

@ -163,7 +163,7 @@ this.Task = {
* called when the task terminates.
*/
spawn: function Task_spawn(aTask) {
return createAsyncFunction(aTask).call(undefined);
return createAsyncFunction(aTask)();
},
/**

Просмотреть файл

@ -1418,7 +1418,7 @@ MockInstall.prototype = {
for (let listener of this.testListeners) {
try {
if (aMethod in listener)
if (listener[aMethod].call(listener, this, this.addon) === false)
if (listener[aMethod](this, this.addon) === false)
result = false;
} catch (e) {
ok(false, "Test listener threw exception: " + e);