Skip to content

Latest commit

 

History

History
36 lines (24 loc) · 575 Bytes

no-parse-json.md

File metadata and controls

36 lines (24 loc) · 575 Bytes

Disallow $.parseJSON

As of jQuery 1.9+ $.parseJSON is identical to native JSON.parse and will not attempt to "fix" invalid JSON.

To retain the old behaviour and "fix" invalid falsy behaviour, use:

JSON.parse(input || 'null')

Rule Details

Examples of incorrect code for this rule:

$.parseJSON(input)
jQuery.parseJSON(input)

Examples of correct code for this rule:

JSON.parse(input)
JSON.parse(input || 'null')

Further Reading