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.
- package/README.md +38 -36
- package/docs/rules/amp/arg-types.md +13 -2
- package/docs/rules/amp/prefer-boolean-literal.md +50 -0
- package/docs/unicorn-compatibility.md +22 -15
- package/package.json +11 -11
- package/src/ampscript-processor.js +1 -5
- package/src/index.js +12 -4
- package/src/processor.js +1 -5
- package/src/rules/amp/argument-types.js +48 -12
- package/src/rules/amp/function-arity.js +6 -11
- package/src/rules/amp/naming-convention.js +7 -9
- package/src/rules/amp/no-loop-counter-assign.js +12 -11
- package/src/rules/amp/prefer-attribute-value.js +6 -11
- package/src/rules/amp/prefer-boolean-literal.js +99 -0
- package/src/rules/amp/require-variable-declaration.js +15 -14
- package/src/rules/hbs/_shared.js +8 -18
- package/src/rules/hbs/no-mcn-unsupported.js +3 -4
- package/src/rules/ssjs/cache-loop-length.js +8 -11
- package/src/rules/ssjs/http-property-value.js +7 -11
- package/src/rules/ssjs/no-clr-header-access.js +7 -16
- package/src/rules/ssjs/no-deprecated-function.js +9 -14
- package/src/rules/ssjs/no-invalid-property-access.js +7 -11
- package/src/rules/ssjs/no-mcn-unsupported.js +5 -4
- package/src/rules/ssjs/no-property-call.js +4 -4
- package/src/rules/ssjs/no-treatascontent-injection.js +7 -10
- package/src/rules/ssjs/no-unavailable-method.js +14 -14
- package/src/rules/ssjs/no-unknown-function.js +39 -37
- package/src/rules/ssjs/platform-function-arity.js +54 -57
- package/src/rules/ssjs/prefer-parsejson-safe-argument.js +1 -4
- package/src/rules/ssjs/require-hasownproperty.js +70 -91
- package/src/rules/ssjs/require-platform-load-order.js +3 -7
- package/src/rules/ssjs/require-platform-load.js +1 -4
- package/src/rules/ssjs/require-string-clr-content.js +5 -14
- package/src/rules/ssjs/ssjs-argument-types.js +22 -28
- package/src/rules/ssjs/ssjs-core-method-arity.js +20 -24
- package/src/rules/ssjs/ssjs-no-nonfunctional-method.js +20 -26
- package/src/ssjs-processor.js +1 -5
|
@@ -79,10 +79,7 @@ export default {
|
|
|
79
79
|
|
|
80
80
|
CallExpression(node) {
|
|
81
81
|
const callee = node.callee;
|
|
82
|
-
if (callee.type !== 'MemberExpression') {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
if (callee.property.type !== 'Identifier') {
|
|
82
|
+
if (callee.type !== 'MemberExpression' || callee.property.type !== 'Identifier') {
|
|
86
83
|
return;
|
|
87
84
|
}
|
|
88
85
|
const methodName = callee.property.name;
|
|
@@ -141,23 +138,21 @@ export default {
|
|
|
141
138
|
// Instance sub-path: de.Rows.Add(...) where `de` is a tracked
|
|
142
139
|
// DataExtension.Init(...) instance. Substitute the instance's
|
|
143
140
|
// core type for the leftmost identifier and resolve the class key.
|
|
144
|
-
if (objectPath) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
callee.property,
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
141
|
+
if (!objectPath) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const segments = objectPath.split('.');
|
|
145
|
+
const rootCoreType = coreVariables.get(segments[0]);
|
|
146
|
+
if (!rootCoreType) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const resolvedPath = [rootCoreType, ...segments.slice(1)].join('.');
|
|
150
|
+
const classLookup = coreMethodArityLookup.get(resolvedPath.toLowerCase());
|
|
151
|
+
if (!classLookup) {
|
|
152
|
+
return;
|
|
160
153
|
}
|
|
154
|
+
const entry = classLookup.get(methodName.toLowerCase());
|
|
155
|
+
checkArity(entry, node.arguments, `${resolvedPath}.${methodName}`, callee.property);
|
|
161
156
|
},
|
|
162
157
|
};
|
|
163
158
|
},
|
|
@@ -168,10 +163,11 @@ function getCoreInitType(node) {
|
|
|
168
163
|
return null;
|
|
169
164
|
}
|
|
170
165
|
const callee = node.callee;
|
|
171
|
-
if (
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
166
|
+
if (
|
|
167
|
+
callee.type !== 'MemberExpression' ||
|
|
168
|
+
callee.property.type !== 'Identifier' ||
|
|
169
|
+
callee.property.name !== 'Init'
|
|
170
|
+
) {
|
|
175
171
|
return null;
|
|
176
172
|
}
|
|
177
173
|
if (callee.object.type === 'Identifier' && coreObjectNames.has(callee.object.name)) {
|
|
@@ -101,10 +101,7 @@ export default {
|
|
|
101
101
|
|
|
102
102
|
CallExpression(node) {
|
|
103
103
|
const callee = node.callee;
|
|
104
|
-
if (callee.type !== 'MemberExpression') {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
if (callee.property.type !== 'Identifier') {
|
|
104
|
+
if (callee.type !== 'MemberExpression' || callee.property.type !== 'Identifier') {
|
|
108
105
|
return;
|
|
109
106
|
}
|
|
110
107
|
const methodName = callee.property.name;
|
|
@@ -167,25 +164,21 @@ export default {
|
|
|
167
164
|
// Instance sub-path: de.Rows.Add(...) where `de` is a tracked
|
|
168
165
|
// Init(...) instance. Substitute the instance's core type for the
|
|
169
166
|
// leftmost identifier and resolve the class key.
|
|
170
|
-
if (objectPath) {
|
|
171
|
-
|
|
172
|
-
const rootCoreType = coreVariables.get(segments[0]);
|
|
173
|
-
if (rootCoreType) {
|
|
174
|
-
const resolvedPath = [rootCoreType, ...segments.slice(1)].join('.');
|
|
175
|
-
const classLookup = coreNonFunctionalMethodLookup.get(
|
|
176
|
-
resolvedPath.toLowerCase(),
|
|
177
|
-
);
|
|
178
|
-
if (classLookup) {
|
|
179
|
-
const entry = classLookup.get(methodName.toLowerCase());
|
|
180
|
-
checkNonFunctional(
|
|
181
|
-
entry,
|
|
182
|
-
`${resolvedPath}.${methodName}`,
|
|
183
|
-
callee.property,
|
|
184
|
-
true,
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
167
|
+
if (!objectPath) {
|
|
168
|
+
return;
|
|
188
169
|
}
|
|
170
|
+
const segments = objectPath.split('.');
|
|
171
|
+
const rootCoreType = coreVariables.get(segments[0]);
|
|
172
|
+
if (!rootCoreType) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const resolvedPath = [rootCoreType, ...segments.slice(1)].join('.');
|
|
176
|
+
const classLookup = coreNonFunctionalMethodLookup.get(resolvedPath.toLowerCase());
|
|
177
|
+
if (!classLookup) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const entry = classLookup.get(methodName.toLowerCase());
|
|
181
|
+
checkNonFunctional(entry, `${resolvedPath}.${methodName}`, callee.property, true);
|
|
189
182
|
},
|
|
190
183
|
};
|
|
191
184
|
},
|
|
@@ -202,10 +195,11 @@ function getCoreInitType(node) {
|
|
|
202
195
|
return null;
|
|
203
196
|
}
|
|
204
197
|
const callee = node.callee;
|
|
205
|
-
if (
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
198
|
+
if (
|
|
199
|
+
callee.type !== 'MemberExpression' ||
|
|
200
|
+
callee.property.type !== 'Identifier' ||
|
|
201
|
+
callee.property.name !== 'Init'
|
|
202
|
+
) {
|
|
209
203
|
return null;
|
|
210
204
|
}
|
|
211
205
|
if (callee.object.type === 'Identifier' && coreObjectNames.has(callee.object.name)) {
|
package/src/ssjs-processor.js
CHANGED