Skip to content

Commit

Permalink
fix(no-null-param): prevent exception when the data object is null
Browse files Browse the repository at this point in the history
  • Loading branch information
alliejones committed Feb 11, 2020
1 parent b5ebfbb commit 48be78c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/no-null-param.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions test/lib/rules/jquery-compat/no-null-param.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down

0 comments on commit 48be78c

Please sign in to comment.