eslint-plugin-sfmc 5.1.0 → 5.2.1

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.
Files changed (37) hide show
  1. package/README.md +38 -36
  2. package/docs/rules/amp/arg-types.md +13 -2
  3. package/docs/rules/amp/prefer-boolean-literal.md +50 -0
  4. package/docs/unicorn-compatibility.md +22 -15
  5. package/package.json +11 -11
  6. package/src/ampscript-processor.js +1 -5
  7. package/src/index.js +12 -4
  8. package/src/processor.js +1 -5
  9. package/src/rules/amp/argument-types.js +48 -12
  10. package/src/rules/amp/function-arity.js +6 -11
  11. package/src/rules/amp/naming-convention.js +7 -9
  12. package/src/rules/amp/no-loop-counter-assign.js +12 -11
  13. package/src/rules/amp/prefer-attribute-value.js +6 -11
  14. package/src/rules/amp/prefer-boolean-literal.js +99 -0
  15. package/src/rules/amp/require-variable-declaration.js +15 -14
  16. package/src/rules/hbs/_shared.js +8 -18
  17. package/src/rules/hbs/no-mcn-unsupported.js +3 -4
  18. package/src/rules/ssjs/cache-loop-length.js +8 -11
  19. package/src/rules/ssjs/http-property-value.js +7 -11
  20. package/src/rules/ssjs/no-clr-header-access.js +7 -16
  21. package/src/rules/ssjs/no-deprecated-function.js +9 -14
  22. package/src/rules/ssjs/no-invalid-property-access.js +7 -11
  23. package/src/rules/ssjs/no-mcn-unsupported.js +5 -4
  24. package/src/rules/ssjs/no-property-call.js +4 -4
  25. package/src/rules/ssjs/no-treatascontent-injection.js +7 -10
  26. package/src/rules/ssjs/no-unavailable-method.js +14 -14
  27. package/src/rules/ssjs/no-unknown-function.js +39 -37
  28. package/src/rules/ssjs/platform-function-arity.js +54 -57
  29. package/src/rules/ssjs/prefer-parsejson-safe-argument.js +1 -4
  30. package/src/rules/ssjs/require-hasownproperty.js +70 -91
  31. package/src/rules/ssjs/require-platform-load-order.js +3 -7
  32. package/src/rules/ssjs/require-platform-load.js +1 -4
  33. package/src/rules/ssjs/require-string-clr-content.js +5 -14
  34. package/src/rules/ssjs/ssjs-argument-types.js +22 -28
  35. package/src/rules/ssjs/ssjs-core-method-arity.js +20 -24
  36. package/src/rules/ssjs/ssjs-no-nonfunctional-method.js +20 -26
  37. package/src/ssjs-processor.js +1 -5
@@ -111,10 +111,9 @@ export default {
111
111
  (c) =>
112
112
  c.type === 'Block' && c.range[0] === 0 && /^\s*global\b/.test(c.value),
113
113
  );
114
- if (leadingGlobal) {
115
- return fixer.insertTextAfterRange(leadingGlobal.range, '\n\n' + entry.polyfill);
116
- }
117
- return fixer.insertTextBeforeRange([0, 0], entry.polyfill + '\n\n');
114
+ return leadingGlobal
115
+ ? fixer.insertTextAfterRange(leadingGlobal.range, '\n\n' + entry.polyfill)
116
+ : fixer.insertTextBeforeRange([0, 0], entry.polyfill + '\n\n');
118
117
  };
119
118
  }
120
119
 
@@ -230,17 +229,18 @@ export default {
230
229
  }
231
230
 
232
231
  // ── Prototype methods with NO polyfill: .trimStart(), .flat(), … ─
233
- if (knownUnsupportedByPrototypeName.has(lowerMethod)) {
234
- if (ignored.has(methodName)) {
235
- return;
236
- }
237
- // Skip known SFMC top-level objects to avoid false positives.
238
- if (receiver.type === 'Identifier' && SFMC_RECEIVERS.has(receiver.name)) {
239
- return;
240
- }
241
- const entry = knownUnsupportedByPrototypeName.get(lowerMethod);
242
- pendingReports.push({ node: property, entry, noPolyfill: true });
232
+ if (!knownUnsupportedByPrototypeName.has(lowerMethod)) {
233
+ return;
234
+ }
235
+ if (ignored.has(methodName)) {
236
+ return;
237
+ }
238
+ // Skip known SFMC top-level objects to avoid false positives.
239
+ if (receiver.type === 'Identifier' && SFMC_RECEIVERS.has(receiver.name)) {
240
+ return;
243
241
  }
242
+ const entry = knownUnsupportedByPrototypeName.get(lowerMethod);
243
+ pendingReports.push({ node: property, entry, noPolyfill: true });
244
244
  },
245
245
 
246
246
  'Program:exit'() {
@@ -139,43 +139,44 @@ export default {
139
139
  }
140
140
 
141
141
  // ── Instance method calls (Core Library / WSProxy) ────────────
142
- if (callee.object.type === 'Identifier') {
143
- const objectName = callee.object.name;
142
+ if (callee.object.type !== 'Identifier') {
143
+ return;
144
+ }
145
+ const objectName = callee.object.name;
144
146
 
145
- // Core library: var de = DataExtension.Init("key"); de.Foo();
146
- const coreType = coreVariables.get(objectName);
147
- if (coreType) {
148
- const objectDefinition = coreObjectLookup.get(coreType);
149
- if (objectDefinition) {
150
- const knownMethods = new Set(
151
- objectDefinition.methods.map((m) => m.toLowerCase()),
152
- );
153
- if (!knownMethods.has(methodName.toLowerCase())) {
154
- context.report({
155
- node: property,
156
- messageId: 'unknownCoreMethod',
157
- data: {
158
- method: methodName,
159
- objectType: coreType,
160
- available: objectDefinition.methods.join(', '),
161
- },
162
- });
163
- }
147
+ // Core library: var de = DataExtension.Init("key"); de.Foo();
148
+ const coreType = coreVariables.get(objectName);
149
+ if (coreType) {
150
+ const objectDefinition = coreObjectLookup.get(coreType);
151
+ if (objectDefinition) {
152
+ const knownMethods = new Set(
153
+ objectDefinition.methods.map((m) => m.toLowerCase()),
154
+ );
155
+ if (!knownMethods.has(methodName.toLowerCase())) {
156
+ context.report({
157
+ node: property,
158
+ messageId: 'unknownCoreMethod',
159
+ data: {
160
+ method: methodName,
161
+ objectType: coreType,
162
+ available: objectDefinition.methods.join(', '),
163
+ },
164
+ });
164
165
  }
165
- return;
166
166
  }
167
+ return;
168
+ }
167
169
 
168
- // WSProxy: var api = new Script.Util.WSProxy(); api.Foo();
169
- if (
170
- wsproxyVariables.has(objectName) &&
171
- !wsproxyMethodNames.has(methodName.toLowerCase())
172
- ) {
173
- context.report({
174
- node: property,
175
- messageId: 'unknownWsproxyMethod',
176
- data: { name: methodName },
177
- });
178
- }
170
+ // WSProxy: var api = new Script.Util.WSProxy(); api.Foo();
171
+ if (
172
+ wsproxyVariables.has(objectName) &&
173
+ !wsproxyMethodNames.has(methodName.toLowerCase())
174
+ ) {
175
+ context.report({
176
+ node: property,
177
+ messageId: 'unknownWsproxyMethod',
178
+ data: { name: methodName },
179
+ });
179
180
  }
180
181
  },
181
182
  };
@@ -194,10 +195,11 @@ function getCoreInitType(node) {
194
195
  return null;
195
196
  }
196
197
  const callee = node.callee;
197
- if (callee.type !== 'MemberExpression') {
198
- return null;
199
- }
200
- if (callee.property.type !== 'Identifier' || callee.property.name !== 'Init') {
198
+ if (
199
+ callee.type !== 'MemberExpression' ||
200
+ callee.property.type !== 'Identifier' ||
201
+ callee.property.name !== 'Init'
202
+ ) {
201
203
  return null;
202
204
  }
203
205
  if (callee.object.type === 'Identifier' && coreObjectNames.has(callee.object.name)) {
@@ -15,10 +15,9 @@ import { platformFunctionLookup } from 'ssjs-data';
15
15
  * @returns {string} The rendered list.
16
16
  */
17
17
  function formatArities(arities) {
18
- if (arities.length === 1) {
19
- return String(arities[0]);
20
- }
21
- return `${arities.slice(0, -1).join(', ')} or ${arities.at(-1)}`;
18
+ return arities.length === 1
19
+ ? String(arities[0])
20
+ : `${arities.slice(0, -1).join(', ')} or ${arities.at(-1)}`;
22
21
  }
23
22
 
24
23
  export default {
@@ -42,63 +41,61 @@ export default {
42
41
  return {
43
42
  CallExpression(node) {
44
43
  const callee = node.callee;
45
- if (callee.type !== 'MemberExpression') {
46
- return;
47
- }
48
-
49
44
  if (
50
- callee.object.type === 'MemberExpression' &&
51
- callee.object.object.type === 'Identifier' &&
52
- callee.object.object.name === 'Platform' &&
53
- callee.object.property.type === 'Identifier' &&
54
- callee.object.property.name === 'Function' &&
55
- callee.property.type === 'Identifier'
45
+ callee.type !== 'MemberExpression' ||
46
+ callee.object.type !== 'MemberExpression' ||
47
+ callee.object.object.type !== 'Identifier' ||
48
+ callee.object.object.name !== 'Platform' ||
49
+ callee.object.property.type !== 'Identifier' ||
50
+ callee.object.property.name !== 'Function' ||
51
+ callee.property.type !== 'Identifier'
56
52
  ) {
57
- const methodName = callee.property.name;
58
- const entry = platformFunctionLookup.get(methodName.toLowerCase());
59
- if (!entry) {
60
- return;
61
- }
53
+ return;
54
+ }
55
+ const methodName = callee.property.name;
56
+ const entry = platformFunctionLookup.get(methodName.toLowerCase());
57
+ if (!entry) {
58
+ return;
59
+ }
62
60
 
63
- const actual = node.arguments.length;
61
+ const actual = node.arguments.length;
64
62
 
65
- if (actual < entry.minArgs) {
66
- context.report({
67
- node: callee.property,
68
- messageId: 'tooFewArgs',
69
- data: {
70
- name: entry.name,
71
- min: String(entry.minArgs),
72
- actual: String(actual),
73
- },
74
- });
75
- } else if (actual > entry.maxArgs) {
76
- context.report({
77
- node: callee.property,
78
- messageId: 'tooManyArgs',
79
- data: {
80
- name: entry.name,
81
- max: String(entry.maxArgs),
82
- actual: String(actual),
83
- },
84
- });
85
- } else if (
86
- Array.isArray(entry.validArities) &&
87
- !entry.validArities.includes(actual)
88
- ) {
89
- // Discontinuous overload: actual is within [minArgs, maxArgs]
90
- // but not one of the exact permitted arities (e.g. HTTPGet
91
- // accepts only 1 or 6 arguments; 2-5 throw at runtime).
92
- context.report({
93
- node: callee.property,
94
- messageId: 'invalidArity',
95
- data: {
96
- name: entry.name,
97
- arities: formatArities(entry.validArities),
98
- actual: String(actual),
99
- },
100
- });
101
- }
63
+ if (actual < entry.minArgs) {
64
+ context.report({
65
+ node: callee.property,
66
+ messageId: 'tooFewArgs',
67
+ data: {
68
+ name: entry.name,
69
+ min: String(entry.minArgs),
70
+ actual: String(actual),
71
+ },
72
+ });
73
+ } else if (actual > entry.maxArgs) {
74
+ context.report({
75
+ node: callee.property,
76
+ messageId: 'tooManyArgs',
77
+ data: {
78
+ name: entry.name,
79
+ max: String(entry.maxArgs),
80
+ actual: String(actual),
81
+ },
82
+ });
83
+ } else if (
84
+ Array.isArray(entry.validArities) &&
85
+ !entry.validArities.includes(actual)
86
+ ) {
87
+ // Discontinuous overload: actual is within [minArgs, maxArgs]
88
+ // but not one of the exact permitted arities (e.g. HTTPGet
89
+ // accepts only 1 or 6 arguments; 2-5 throw at runtime).
90
+ context.report({
91
+ node: callee.property,
92
+ messageId: 'invalidArity',
93
+ data: {
94
+ name: entry.name,
95
+ arities: formatArities(entry.validArities),
96
+ actual: String(actual),
97
+ },
98
+ });
102
99
  }
103
100
  },
104
101
  };
@@ -27,10 +27,7 @@ export default {
27
27
  create(context) {
28
28
  return {
29
29
  CallExpression(node) {
30
- if (!isParseJSONCall(node)) {
31
- return;
32
- }
33
- if (node.arguments.length === 0) {
30
+ if (!isParseJSONCall(node) || node.arguments.length === 0) {
34
31
  return;
35
32
  }
36
33
 
@@ -35,70 +35,69 @@ export default {
35
35
 
36
36
  const hasGuard = statements.some((statement) => containsHasOwnProperty(statement));
37
37
 
38
- if (!hasGuard) {
39
- const keyName = getKeyName(node.left);
40
- const objectText = context.sourceCode.getText(node.right);
41
-
42
- if (!keyName) {
43
- context.report({
44
- node,
45
- messageId: 'missingGuard',
46
- });
47
- return;
48
- }
38
+ if (hasGuard) {
39
+ return;
40
+ }
41
+ const keyName = getKeyName(node.left);
42
+ const objectText = context.sourceCode.getText(node.right);
49
43
 
44
+ if (!keyName) {
50
45
  context.report({
51
46
  node,
52
47
  messageId: 'missingGuard',
53
- fix(fixer) {
54
- const sourceCode = context.sourceCode;
55
- const innerStatements =
56
- body.type === 'BlockStatement' ? body.body : [body];
57
-
58
- // Single-line loops keep compact output to avoid reformatting
59
- // code the author intentionally wrote on one line.
60
- const isSingleLine = node.loc.start.line === node.loc.end.line;
61
- if (isSingleLine) {
62
- const compactBody = innerStatements
63
- .map((statement) => sourceCode.getText(statement))
64
- .join(' ');
65
- return fixer.replaceText(
66
- body,
67
- `{ if (${objectText}.hasOwnProperty(${keyName})) { ${compactBody} } }`,
68
- );
69
- }
70
-
71
- // Multi-line loops: emit a properly-indented guard block.
72
- const loopLine = sourceCode.lines[node.loc.start.line - 1] ?? '';
73
- const baseIndent = (loopLine.match(/^[\t ]*/) ?? [''])[0];
74
- const firstStatement = innerStatements[0];
75
- const firstStatementLine = firstStatement
76
- ? (sourceCode.lines[firstStatement.loc.start.line - 1] ?? '')
77
- : '';
78
- const firstStatementIndent = (firstStatementLine.match(/^[\t ]*/) ?? [
79
- '',
80
- ])[0];
81
- const unit =
82
- firstStatementIndent.length > baseIndent.length
83
- ? firstStatementIndent.slice(baseIndent.length)
84
- : ' '.repeat(4);
85
- const guardIndent = baseIndent + unit;
86
- const statementIndent = guardIndent + unit;
87
-
88
- const guardedBody = innerStatements
89
- .map(
90
- (statement) =>
91
- `${statementIndent}${sourceCode.getText(statement)}`,
92
- )
93
- .join('\n');
48
+ });
49
+ return;
50
+ }
94
51
 
52
+ context.report({
53
+ node,
54
+ messageId: 'missingGuard',
55
+ fix(fixer) {
56
+ const sourceCode = context.sourceCode;
57
+ const innerStatements = body.type === 'BlockStatement' ? body.body : [body];
58
+
59
+ // Single-line loops keep compact output to avoid reformatting
60
+ // code the author intentionally wrote on one line.
61
+ const isSingleLine = node.loc.start.line === node.loc.end.line;
62
+ if (isSingleLine) {
63
+ const compactBody = innerStatements
64
+ .map((statement) => sourceCode.getText(statement))
65
+ .join(' ');
95
66
  return fixer.replaceText(
96
67
  body,
97
- `{\n${guardIndent}if (${objectText}.hasOwnProperty(${keyName})) {\n${guardedBody}\n${guardIndent}}\n${baseIndent}}`,
68
+ `{ if (${objectText}.hasOwnProperty(${keyName})) { ${compactBody} } }`,
98
69
  );
99
- },
100
- });
101
- }
70
+ }
71
+
72
+ // Multi-line loops: emit a properly-indented guard block.
73
+ const loopLine = sourceCode.lines[node.loc.start.line - 1] ?? '';
74
+ const baseIndent = (loopLine.match(/^[\t ]*/) ?? [''])[0];
75
+ const firstStatement = innerStatements[0];
76
+ const firstStatementLine = firstStatement
77
+ ? (sourceCode.lines[firstStatement.loc.start.line - 1] ?? '')
78
+ : '';
79
+ const firstStatementIndent = (firstStatementLine.match(/^[\t ]*/) ?? [
80
+ '',
81
+ ])[0];
82
+ const unit =
83
+ firstStatementIndent.length > baseIndent.length
84
+ ? firstStatementIndent.slice(baseIndent.length)
85
+ : ' '.repeat(4);
86
+ const guardIndent = baseIndent + unit;
87
+ const statementIndent = guardIndent + unit;
88
+
89
+ const guardedBody = innerStatements
90
+ .map(
91
+ (statement) => `${statementIndent}${sourceCode.getText(statement)}`,
92
+ )
93
+ .join('\n');
94
+
95
+ return fixer.replaceText(
96
+ body,
97
+ `{\n${guardIndent}if (${objectText}.hasOwnProperty(${keyName})) {\n${guardedBody}\n${guardIndent}}\n${baseIndent}}`,
98
+ );
99
+ },
100
+ });
102
101
  },
103
102
  };
104
103
  },
@@ -120,19 +119,12 @@ function containsHasOwnProperty(node) {
120
119
  return true;
121
120
  }
122
121
 
123
- if (current.type === 'IfStatement') {
124
- return (
125
- hasOwnPropertyTest(current.test) ||
126
- containsHasOwnProperty(current.consequent) ||
127
- containsHasOwnProperty(current.alternate)
128
- );
129
- }
130
-
131
- if (current.type === 'BlockStatement') {
132
- return current.body.some((child) => containsHasOwnProperty(child));
133
- }
134
-
135
- return false;
122
+ return current.type === 'IfStatement'
123
+ ? hasOwnPropertyTest(current.test) ||
124
+ containsHasOwnProperty(current.consequent) ||
125
+ containsHasOwnProperty(current.alternate)
126
+ : current.type === 'BlockStatement' &&
127
+ current.body.some((child) => containsHasOwnProperty(child));
136
128
  }
137
129
 
138
130
  function hasOwnPropertyTest(node) {
@@ -143,24 +135,14 @@ function hasOwnPropertyTest(node) {
143
135
  current = current.argument;
144
136
  }
145
137
 
146
- if (!current) {
147
- return false;
148
- }
149
-
150
- if (
151
- current.type === 'CallExpression' &&
152
- current.callee.type === 'MemberExpression' &&
153
- current.callee.property.type === 'Identifier' &&
154
- current.callee.property.name === 'hasOwnProperty'
155
- ) {
156
- return true;
157
- }
158
-
159
- if (current.type === 'LogicalExpression') {
160
- return hasOwnPropertyTest(current.left) || hasOwnPropertyTest(current.right);
161
- }
162
-
163
- return false;
138
+ return current
139
+ ? (current.type === 'CallExpression' &&
140
+ current.callee.type === 'MemberExpression' &&
141
+ current.callee.property.type === 'Identifier' &&
142
+ current.callee.property.name === 'hasOwnProperty') ||
143
+ (current.type === 'LogicalExpression' &&
144
+ (hasOwnPropertyTest(current.left) || hasOwnPropertyTest(current.right)))
145
+ : false;
164
146
  }
165
147
 
166
148
  /**
@@ -175,8 +157,5 @@ function getKeyName(left) {
175
157
  const id = left.declarations[0].id;
176
158
  return id.type === 'Identifier' ? id.name : null;
177
159
  }
178
- if (left.type === 'Identifier') {
179
- return left.name;
180
- }
181
- return null;
160
+ return left.type === 'Identifier' ? left.name : null;
182
161
  }
@@ -103,14 +103,10 @@ function getCoreObjectUsage(node) {
103
103
  return `${callee.object.object.name}.${callee.object.property.name}`;
104
104
  }
105
105
 
106
- if (
107
- callee.object.type === 'Identifier' &&
106
+ return callee.object.type === 'Identifier' &&
108
107
  TOP_LEVEL_CORE_NAMES.has(callee.object.name) &&
109
108
  callee.property.type === 'Identifier' &&
110
109
  callee.property.name === 'Init'
111
- ) {
112
- return callee.object.name;
113
- }
114
-
115
- return null;
110
+ ? callee.object.name
111
+ : null;
116
112
  }
@@ -105,10 +105,7 @@ function getCoreObjectUsage(node) {
105
105
 
106
106
  // Bare call: Now(), Write(), GUID(), Base64Encode(), Redirect(), …
107
107
  if (callee.type === 'Identifier') {
108
- if (CORE_LOAD_DEPENDENT_GLOBALS.has(callee.name.toLowerCase())) {
109
- return callee.name;
110
- }
111
- return null;
108
+ return CORE_LOAD_DEPENDENT_GLOBALS.has(callee.name.toLowerCase()) ? callee.name : null;
112
109
  }
113
110
 
114
111
  if (callee.type !== 'MemberExpression') {
@@ -46,16 +46,10 @@ function isHttpConstructorMember(node) {
46
46
  * @returns {boolean} Whether the expression yields an HTTP request instance
47
47
  */
48
48
  function isHttpRequestInit(node) {
49
- if (!node) {
50
- return false;
51
- }
52
- if (node.type === 'NewExpression') {
53
- return isHttpConstructorMember(node.callee);
54
- }
55
- if (node.type === 'CallExpression') {
56
- return isHttpConstructorMember(node.callee);
57
- }
58
- return false;
49
+ return node
50
+ ? (node.type === 'NewExpression' || node.type === 'CallExpression') &&
51
+ isHttpConstructorMember(node.callee)
52
+ : false;
59
53
  }
60
54
 
61
55
  /**
@@ -153,10 +147,7 @@ export default {
153
147
 
154
148
  // resp.content — non-computed member read on a tracked response var.
155
149
  'MemberExpression[computed=false]'(node) {
156
- if (!isTrackedContentMember(node)) {
157
- return;
158
- }
159
- if (isWrappedInString(node)) {
150
+ if (!isTrackedContentMember(node) || isWrappedInString(node)) {
160
151
  return;
161
152
  }
162
153
  pending.push(node);
@@ -143,10 +143,7 @@ export default {
143
143
  return;
144
144
  }
145
145
 
146
- if (callee.type !== 'MemberExpression') {
147
- return;
148
- }
149
- if (callee.property.type !== 'Identifier') {
146
+ if (callee.type !== 'MemberExpression' || callee.property.type !== 'Identifier') {
150
147
  return;
151
148
  }
152
149
  const methodName = callee.property.name;
@@ -228,14 +225,16 @@ export default {
228
225
 
229
226
  // Multi-part static: DataExtension.Rows.Add(...), TriggeredSend.Tracking.Clicks.Retrieve(...)
230
227
  const objectPath = getMemberPath(callee.object);
231
- if (objectPath && coreObjectNames.has(objectPath)) {
232
- const classLookup = coreMethodArityLookup.get(objectPath.toLowerCase());
233
- if (classLookup) {
234
- const entry = classLookup.get(methodName.toLowerCase());
235
- if (entry) {
236
- checkArguments(entry, node.arguments, `${objectPath}.${methodName}`);
237
- }
238
- }
228
+ if (!objectPath || !coreObjectNames.has(objectPath)) {
229
+ return;
230
+ }
231
+ const classLookup = coreMethodArityLookup.get(objectPath.toLowerCase());
232
+ if (!classLookup) {
233
+ return;
234
+ }
235
+ const entry = classLookup.get(methodName.toLowerCase());
236
+ if (entry) {
237
+ checkArguments(entry, node.arguments, `${objectPath}.${methodName}`);
239
238
  }
240
239
  },
241
240
  };
@@ -247,10 +246,11 @@ function getCoreInitType(node) {
247
246
  return null;
248
247
  }
249
248
  const callee = node.callee;
250
- if (callee.type !== 'MemberExpression') {
251
- return null;
252
- }
253
- if (callee.property.type !== 'Identifier' || callee.property.name !== 'Init') {
249
+ if (
250
+ callee.type !== 'MemberExpression' ||
251
+ callee.property.type !== 'Identifier' ||
252
+ callee.property.name !== 'Init'
253
+ ) {
254
254
  return null;
255
255
  }
256
256
  if (callee.object.type === 'Identifier' && coreObjectNames.has(callee.object.name)) {
@@ -313,19 +313,13 @@ function inferArgumentType(node) {
313
313
  ) {
314
314
  return 'string[]';
315
315
  }
316
- if (
317
- elements.every(
318
- (element) => element.type === 'Literal' && typeof element.value === 'number',
319
- )
320
- ) {
321
- return 'number[]';
322
- }
323
- return 'array';
316
+ return elements.every(
317
+ (element) => element.type === 'Literal' && typeof element.value === 'number',
318
+ )
319
+ ? 'number[]'
320
+ : 'array';
324
321
  }
325
- if (node.type === 'ObjectExpression') {
326
- return 'object';
327
- }
328
- return null;
322
+ return node.type === 'ObjectExpression' ? 'object' : null;
329
323
  }
330
324
 
331
325
  function isTypeCompatible(actual, expected) {