eslint-plugin-sfmc 4.8.0 → 4.8.2

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.
@@ -5,14 +5,14 @@
5
5
  | | |
6
6
  |---|---|
7
7
  | **Type** | `problem` |
8
- | **Default severity** | `warn` in `recommended` and `strict` |
8
+ | **Default severity** | `error` in `recommended` and `strict` |
9
9
  | **Fixable** | — |
10
10
 
11
11
  ## Why This Rule Exists
12
12
 
13
13
  A few Core Library methods **exist** and **resolve** at runtime — the namespace or instance exposes them as callables — but exhaustive live testing has found **no working invocation**: every attempted call fails (returns the string `"Error"` or throws), and the documented success path could not be reproduced.
14
14
 
15
- Because these methods DO exist, they remain in completions and in the generated `.d.ts` (unlike nonexistent members). This rule warns at the **call site** so you know the call will not work at runtime, using the `nonFunctionalAtRuntime` flag from the ssjs-data catalog.
15
+ Because these methods DO exist, they remain in completions and in the generated `.d.ts` (unlike nonexistent members). This rule flags an **error** at the **call site** — every tested invocation fails, so unlike a plain deprecation this is not "works but discouraged" — using the `nonFunctionalAtRuntime` flag from the ssjs-data catalog.
16
16
 
17
17
  ## Coverage
18
18
 
@@ -30,7 +30,7 @@ Flagged methods today: `FilterDefinition.Update`, `FilterDefinition.Remove`.
30
30
 
31
31
  | Setting | Values | Default |
32
32
  |---------|--------|---------|
33
- | severity | `"error"` \| `"warn"` \| `"off"` | `"warn"` |
33
+ | severity | `"error"` \| `"warn"` \| `"off"` | `"error"` |
34
34
 
35
35
  This rule has no configuration options.
36
36
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-sfmc",
3
- "version": "4.8.0",
3
+ "version": "4.8.2",
4
4
  "description": "ESLint plugin for Salesforce Marketing Cloud Engagement+Next - AMPscript, Server-Side JavaScript (SSJS) and Handlebars",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -42,13 +42,13 @@
42
42
  "eslint-plugin-mso-email": "^2.0.0",
43
43
  "handlebars-data": "^0.3.0",
44
44
  "mso-conditional-parser": "^2.0.1",
45
- "ssjs-data": "^1.1.0"
45
+ "ssjs-data": "^1.1.1"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "eslint": ">=9.0.0"
49
49
  },
50
50
  "scripts": {
51
- "test": "node --test tests/rules.test.js && node --test tests/fixtures.test.mjs && node --test tests/autofix-manual.test.mjs",
51
+ "test": "node --test tests/rules.test.js && node --test tests/deprecated-catalog.test.js && node --test tests/fixtures.test.mjs && node --test tests/autofix-manual.test.mjs",
52
52
  "test:autofix-manual": "node --test tests/autofix-manual.test.mjs",
53
53
  "test:fixtures": "node --test tests/fixtures.test.mjs",
54
54
  "test:fixtures:update": "node --test tests/fixtures.test.mjs -- --update-snapshots",
package/src/index.js CHANGED
@@ -262,7 +262,7 @@ const ssjsRecommendedRules = {
262
262
  'sfmc/ssjs-no-treatascontent-injection': 'warn',
263
263
  'sfmc/ssjs-arg-types': 'warn',
264
264
  'sfmc/ssjs-core-method-arity': 'warn',
265
- 'sfmc/ssjs-no-nonfunctional-method': 'warn',
265
+ 'sfmc/ssjs-no-nonfunctional-method': 'error',
266
266
  'sfmc/ssjs-no-clr-header-access': 'error',
267
267
  'sfmc/ssjs-require-string-clr-content': 'error',
268
268
  'sfmc/ssjs-http-property-value': 'error',
@@ -288,7 +288,7 @@ const ssjsStrictRules = {
288
288
  'sfmc/ssjs-no-treatascontent-injection': 'error',
289
289
  'sfmc/ssjs-arg-types': 'warn',
290
290
  'sfmc/ssjs-core-method-arity': 'error',
291
- 'sfmc/ssjs-no-nonfunctional-method': 'warn',
291
+ 'sfmc/ssjs-no-nonfunctional-method': 'error',
292
292
  'sfmc/ssjs-no-clr-header-access': 'error',
293
293
  'sfmc/ssjs-require-string-clr-content': 'error',
294
294
  'sfmc/ssjs-http-property-value': 'error',
@@ -228,7 +228,11 @@ export default {
228
228
  // the same statement (e.g. `var p = Portfolio.Init(...)`).
229
229
  if (coreObjectNames.has(objectPath) && methodName.toLowerCase() !== 'init') {
230
230
  const entry = findDeprecatedEntry(objectPath, methodName);
231
- if (entry) {
231
+ // A static-style call (`Class.Method(...)`) only matches a method
232
+ // that is actually callable that way — an entry explicitly flagged
233
+ // `isStatic: false` exists only on the instance, so it is not a
234
+ // "known" deprecated call in this form.
235
+ if (entry && entry.isStatic !== false) {
232
236
  context.report({
233
237
  node: property,
234
238
  messageId: 'deprecatedCoreStatic',
@@ -250,7 +254,12 @@ export default {
250
254
  }
251
255
  const resolvedClass = [rootCoreType, ...segments.slice(1)].join('.');
252
256
  const entry = findDeprecatedEntry(resolvedClass, methodName);
253
- if (entry) {
257
+ // An instance-style call (`<var>.Method(...)`) only matches a method
258
+ // explicitly flagged `isStatic: false` — a static-only method (e.g.
259
+ // `Send.RetrieveLists`) does not exist on the instance, so it is not
260
+ // a "known" deprecated call in this form (it should surface as an
261
+ // unknown-member problem elsewhere, not a misleading deprecation).
262
+ if (entry && entry.isStatic === false) {
254
263
  context.report({
255
264
  node: property,
256
265
  messageId: 'deprecatedCoreInstance',
@@ -53,10 +53,18 @@ export default {
53
53
  create(context) {
54
54
  const coreVariables = new Map(); // varName → className
55
55
 
56
- function checkNonFunctional(entry, callName, reportNode) {
56
+ // `isInstanceStyle` reflects the call syntax used (`<var>.Method(...)`
57
+ // vs `Class.Method(...)`). An entry only matches when its `isStatic`
58
+ // flag agrees with that call style — a static-only method does not
59
+ // exist on the instance (and vice versa), so it is not a "known"
60
+ // non-functional call in the wrong form.
61
+ function checkNonFunctional(entry, callName, reportNode, isInstanceStyle) {
57
62
  if (!entry) {
58
63
  return;
59
64
  }
65
+ if (isInstanceStyle ? entry.isStatic !== false : entry.isStatic === false) {
66
+ return;
67
+ }
60
68
  context.report({
61
69
  node: reportNode,
62
70
  messageId: 'nonFunctional',
@@ -112,7 +120,12 @@ export default {
112
120
  );
113
121
  if (classLookup) {
114
122
  const entry = classLookup.get(methodName.toLowerCase());
115
- checkNonFunctional(entry, `${coreType}.${methodName}`, callee.property);
123
+ checkNonFunctional(
124
+ entry,
125
+ `${coreType}.${methodName}`,
126
+ callee.property,
127
+ true,
128
+ );
116
129
  }
117
130
  return;
118
131
  }
@@ -128,6 +141,7 @@ export default {
128
141
  entry,
129
142
  `${objectName}.${methodName}`,
130
143
  callee.property,
144
+ false,
131
145
  );
132
146
  }
133
147
  return;
@@ -140,7 +154,12 @@ export default {
140
154
  const classLookup = coreNonFunctionalMethodLookup.get(objectPath.toLowerCase());
141
155
  if (classLookup) {
142
156
  const entry = classLookup.get(methodName.toLowerCase());
143
- checkNonFunctional(entry, `${objectPath}.${methodName}`, callee.property);
157
+ checkNonFunctional(
158
+ entry,
159
+ `${objectPath}.${methodName}`,
160
+ callee.property,
161
+ false,
162
+ );
144
163
  }
145
164
  return;
146
165
  }
@@ -162,6 +181,7 @@ export default {
162
181
  entry,
163
182
  `${resolvedPath}.${methodName}`,
164
183
  callee.property,
184
+ true,
165
185
  );
166
186
  }
167
187
  }