зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1469384 - Allow no-useless-removeEventListener to not throw if only one argument is given to an addEventListener call. r=florian
Differential Revision: https://phabricator.services.mozilla.com/D5882 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
999b3d3c52
Коммит
e749f1b196
|
@ -30,7 +30,9 @@ module.exports = function(context) {
|
|||
}
|
||||
|
||||
let listener = node.arguments[1];
|
||||
if (listener.type != "FunctionExpression" || !listener.body ||
|
||||
if (!listener ||
|
||||
listener.type != "FunctionExpression" ||
|
||||
!listener.body ||
|
||||
listener.body.type != "BlockStatement" ||
|
||||
!listener.body.body.length ||
|
||||
listener.body.body[0].type != "ExpressionStatement" ||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "eslint-plugin-mozilla",
|
||||
"version": "0.16.0",
|
||||
"version": "0.16.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "eslint-plugin-mozilla",
|
||||
"version": "0.16.0",
|
||||
"version": "0.16.1",
|
||||
"description": "A collection of rules that help enforce JavaScript coding standard in the Mozilla project.",
|
||||
"keywords": [
|
||||
"eslint",
|
||||
|
|
|
@ -57,7 +57,10 @@ ruleTester.run("no-useless-removeEventListener", rule, {
|
|||
// Should not reject when there's 2 different variables
|
||||
"elt.addEventListener(event1, function listener() {" +
|
||||
" elt.removeEventListener(event2, listener);" +
|
||||
"});"
|
||||
"});",
|
||||
|
||||
// Should not fail if this is a different type of event listener function.
|
||||
"myfunc.addEventListener(listener);",
|
||||
],
|
||||
invalid: [
|
||||
invalidCode("elt.addEventListener('click', function listener() {" +
|
||||
|
|
Загрузка…
Ссылка в новой задаче