Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1329012 - Enable the no-useless-call rule for eslint and fix the …
Browse files Browse the repository at this point in the history
…nine errors that it caught. r=mossop

MozReview-Commit-ID: 57vvfJlyvfW
  • Loading branch information
msujaws committed Jan 5, 2017
1 parent 34f6c7d commit 67616b7
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion browser/base/content/browser-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions toolkit/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Expand Down
2 changes: 2 additions & 0 deletions toolkit/components/ctypes/tests/unit/test_jsctypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion toolkit/modules/Integration.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion toolkit/modules/Promise-backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion toolkit/modules/Task.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ this.Task = {
* called when the task terminates.
*/
spawn: function Task_spawn(aTask) {
return createAsyncFunction(aTask).call(undefined);
return createAsyncFunction(aTask)();
},

/**
Expand Down
2 changes: 1 addition & 1 deletion toolkit/mozapps/extensions/test/browser/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 67616b7

Please sign in to comment.