From 48be78ced7852f350d456472db1b69b5d397d25d Mon Sep 17 00:00:00 2001 From: Allie Jones Date: Tue, 11 Feb 2020 12:13:36 -0500 Subject: [PATCH] fix(no-null-param): prevent exception when the data object is null --- lib/rules/no-null-param.js | 2 +- test/lib/rules/jquery-compat/no-null-param.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/rules/no-null-param.js b/lib/rules/no-null-param.js index 7fd44d4..a18e068 100644 --- a/lib/rules/no-null-param.js +++ b/lib/rules/no-null-param.js @@ -62,7 +62,7 @@ module.exports = { argumentObject = argumentObject['data'] } - if (typeof argumentObject !== "object") { return } + if (typeof argumentObject !== "object" || argumentObject === null) { return } let foundBadValue = badValueWalker(BANNED_VALUES)(argumentObject) diff --git a/test/lib/rules/jquery-compat/no-null-param.js b/test/lib/rules/jquery-compat/no-null-param.js index 16c2fb6..36f25c3 100644 --- a/test/lib/rules/jquery-compat/no-null-param.js +++ b/test/lib/rules/jquery-compat/no-null-param.js @@ -22,6 +22,9 @@ ruleTester.run('jquery-compat/no-null-param', rules['no-null-param'], { code: `var data = { foo: null }; data.foo = 42; $.ajax("hello", { data: data });` + }, + { + code: `$.ajax({ data: null });` } ], invalid: [