mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 21:19:43 -08:00
31391a5b19
feat(eslint-config): add custom eslint rule 'no-uncaugh-json-parse' Co-authored-by: Iván Ovejero <[email protected]>
24 lines
447 B
JavaScript
24 lines
447 B
JavaScript
'use strict';
|
|
|
|
const rules = require('./local-rules'),
|
|
RuleTester = require('eslint').RuleTester;
|
|
|
|
const ruleTester = new RuleTester();
|
|
|
|
ruleTester.run('no-uncaught-json-parse', rules['no-uncaught-json-parse'], {
|
|
valid: [
|
|
{
|
|
code: 'try { JSON.parse(foo) } catch (e) {}',
|
|
},
|
|
{
|
|
code: 'JSON.parse(JSON.stringify(foo))',
|
|
},
|
|
],
|
|
invalid: [
|
|
{
|
|
code: 'JSON.parse(foo)',
|
|
errors: [{ messageId: 'noUncaughtJsonParse' }],
|
|
},
|
|
],
|
|
});
|