fix(core): amend typing for jsonParse() options (#4423)

* 📘 Amend typing for `jsonParse()` options

* ✏️ Update rule message and description

* 🔀 Cherrypick Adi's work

* 🐛 Account for falsy fallback values

* ♻️ Use `else if`

*  Add explicit error message as type

*  Consolidate utils tests

* ♻️ Use optional chaining

* 🔥 Remove patchy type error

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Iván Ovejero
2022-10-24 12:48:16 +02:00
committed by GitHub
parent d7c8fefe19
commit 1732324965
3 changed files with 32 additions and 12 deletions

View File

@@ -30,12 +30,14 @@ module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Calls to JSON.parse() must be surrounded with a try/catch block.',
description:
'Calls to `JSON.parse()` must be replaced with `jsonParse()` from `n8n-workflow` or surrounded with a try/catch block.',
recommended: 'error',
},
schema: [],
messages: {
noUncaughtJsonParse: 'Surround the JSON.parse() call with a try/catch block.',
noUncaughtJsonParse:
'Use `jsonParse()` from `n8n-workflow` or surround the `JSON.parse()` call with a try/catch block.',
},
},
defaultOptions: [],