eslint-plugin-sfmc 5.4.4 → 5.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54,36 +54,30 @@ export default {
54
54
  function isParseJSONCall(node) {
55
55
  const callee = node.callee;
56
56
 
57
- // ParseJSON(...)
58
- if (callee.type === 'Identifier' && callee.name === 'ParseJSON') {
59
- return true;
60
- }
61
-
62
- // Platform.Function.ParseJSON(...)
63
57
  return (
64
- callee.type === 'MemberExpression' &&
65
- callee.property.type === 'Identifier' &&
66
- callee.property.name === 'ParseJSON' &&
67
- callee.object.type === 'MemberExpression' &&
68
- callee.object.property.type === 'Identifier' &&
69
- callee.object.property.name === 'Function' &&
70
- callee.object.object.type === 'Identifier' &&
71
- callee.object.object.name === 'Platform'
58
+ // ParseJSON(...)
59
+ (callee.type === 'Identifier' && callee.name === 'ParseJSON') ||
60
+ // Platform.Function.ParseJSON(...)
61
+ (callee.type === 'MemberExpression' &&
62
+ callee.property.type === 'Identifier' &&
63
+ callee.property.name === 'ParseJSON' &&
64
+ callee.object.type === 'MemberExpression' &&
65
+ callee.object.property.type === 'Identifier' &&
66
+ callee.object.property.name === 'Function' &&
67
+ callee.object.object.type === 'Identifier' &&
68
+ callee.object.object.name === 'Platform')
72
69
  );
73
70
  }
74
71
 
75
72
  function isAlreadySafe(argument) {
76
- // arg + '' or '' + arg
77
- if (
78
- argument.type === 'BinaryExpression' &&
79
- argument.operator === '+' &&
80
- (isEmptyString(argument.left) || isEmptyString(argument.right))
81
- ) {
82
- return true;
83
- }
84
-
85
- // String literal passed directly — already a string
86
- return argument.type === 'Literal' && typeof argument.value === 'string';
73
+ return (
74
+ // arg + '' or '' + arg
75
+ (argument.type === 'BinaryExpression' &&
76
+ argument.operator === '+' &&
77
+ (isEmptyString(argument.left) || isEmptyString(argument.right))) ||
78
+ // String literal passed directly — already a string
79
+ (argument.type === 'Literal' && typeof argument.value === 'string')
80
+ );
87
81
  }
88
82
 
89
83
  function isEmptyString(node) {
@@ -46,10 +46,11 @@ function isHttpConstructorMember(node) {
46
46
  * @returns {boolean} Whether the expression yields an HTTP request instance
47
47
  */
48
48
  function isHttpRequestInit(node) {
49
- return node
50
- ? (node.type === 'NewExpression' || node.type === 'CallExpression') &&
51
- isHttpConstructorMember(node.callee)
52
- : false;
49
+ return (
50
+ Boolean(node) &&
51
+ (node.type === 'NewExpression' || node.type === 'CallExpression') &&
52
+ isHttpConstructorMember(node.callee)
53
+ );
53
54
  }
54
55
 
55
56
  /**
@@ -327,11 +327,11 @@ function isTypeCompatible(actual, expected) {
327
327
  return true;
328
328
  }
329
329
  const allowed = expected.split('|').map((t) => t.trim());
330
- if (allowed.includes(actual)) {
331
- return true;
332
- }
333
- // 'array' is compatible with typed array variants
334
- return Boolean(allowed.includes('array') && (actual === 'string[]' || actual === 'number[]'));
330
+ return (
331
+ allowed.includes(actual) ||
332
+ // 'array' is compatible with typed array variants
333
+ (allowed.includes('array') && (actual === 'string[]' || actual === 'number[]'))
334
+ );
335
335
  }
336
336
 
337
337
  function isWSProxyConstructor(node) {