eslint-plugin-sfmc 4.7.0 → 4.8.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 +1 -1
- package/docs/rules/ssjs/no-deprecated-function.md +11 -8
- package/docs/rules/ssjs/no-nonfunctional-method.md +3 -3
- package/package.json +2 -2
- package/src/index.js +2 -2
- package/src/rules/ssjs/no-deprecated-function.js +147 -80
- package/src/rules/ssjs/ssjs-no-nonfunctional-method.js +23 -3
package/README.md
CHANGED
|
@@ -128,7 +128,7 @@ export default [...sfmc.configs['recommended-next'], ...sfmc.configs['embedded-n
|
|
|
128
128
|
| [`sfmc/ssjs-no-unsupported-syntax`](docs/rules/ssjs/no-unsupported-syntax.md) | `error` | Flag ES6+ syntax not supported by SFMC |
|
|
129
129
|
| [`sfmc/ssjs-no-unknown-function`](docs/rules/ssjs/no-unknown-function.md) | `error` | Disallow unknown methods on Platform.\*, HTTP, Core Library, and WSProxy |
|
|
130
130
|
| [`sfmc/ssjs-no-mcn-unsupported`](docs/rules/ssjs/no-mcn-unsupported.md) | off (`error` in `-next`) | Flag all SSJS API usage as unsupported in Marketing Cloud Next |
|
|
131
|
-
| [`sfmc/ssjs-no-deprecated-function`](docs/rules/ssjs/no-deprecated-function.md) | `error` | Flag use of deprecated SFMC SSJS APIs (
|
|
131
|
+
| [`sfmc/ssjs-no-deprecated-function`](docs/rules/ssjs/no-deprecated-function.md) | `error` | Flag use of deprecated SFMC SSJS APIs (Classic Content classes, ErrorUtil) |
|
|
132
132
|
| [`sfmc/ssjs-no-nonexistent-global`](docs/rules/ssjs/no-nonexistent-global.md) | `error` | Flag documented SSJS globals that throw ReferenceError at runtime |
|
|
133
133
|
| [`sfmc/ssjs-no-property-call`](docs/rules/ssjs/no-property-call.md) | `error` | Disallow calling Platform.Request/Response properties as functions |
|
|
134
134
|
| [`sfmc/ssjs-no-clr-header-access`](docs/rules/ssjs/no-clr-header-access.md) | `error` | Disallow CLR-unsafe reads of `HttpResponse.headers`; read via `for..in` |
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# `sfmc/ssjs-no-deprecated-function`
|
|
2
2
|
|
|
3
|
-
Flags calls to deprecated SFMC SSJS APIs, chiefly
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Flags calls to deprecated SFMC SSJS APIs, chiefly legacy **Classic Content / Classic
|
|
4
|
+
Email Studio** Core Library classes (Content Areas, Portfolios, Templates, Sends, and
|
|
5
|
+
Send Definitions), which have been superseded by Content Builder and Journey Builder,
|
|
6
|
+
plus the legacy `ErrorUtil` helper that only exists under the oldest Core version.
|
|
6
7
|
|
|
7
8
|
## What is flagged
|
|
8
9
|
|
|
@@ -12,11 +13,13 @@ legacy `ErrorUtil` helper that only exists under the oldest Core version.
|
|
|
12
13
|
| `ContentAreaByName(…)` | Global alias; Content Areas are deprecated |
|
|
13
14
|
| `Platform.Function.ContentArea(…)` | Content Areas are deprecated |
|
|
14
15
|
| `Platform.Function.ContentAreaByName(…)` | Content Areas are deprecated |
|
|
15
|
-
| `ContentAreaObj.Init(…)` | ContentAreaObj class is deprecated |
|
|
16
|
-
|
|
|
17
|
-
| `
|
|
18
|
-
|
|
|
19
|
-
|
|
|
16
|
+
| `ContentAreaObj.Init(…)` / `.Add(…)` / `.Retrieve(…)` | `ContentAreaObj` class is deprecated |
|
|
17
|
+
| `<contentAreaVar>.Update(…)` / `.Remove()` | Instance method on a deprecated `ContentAreaObj` variable |
|
|
18
|
+
| `Portfolio.Init(…)` / `.Add(…)` / `.Retrieve(…)` (and instance `.Update(…)` / `.Remove()`) | `Portfolio` class is deprecated (legacy Classic Content) |
|
|
19
|
+
| `Template.Init(…)` / `.Add(…)` / `.Retrieve(…)` (and instance `.Update(…)`) | `Template` class is deprecated (legacy Classic Content) |
|
|
20
|
+
| `Send.Init(…)` / `.Add(…)` / `.Retrieve(…)` (and instance `.RetrieveLists(…)` / `.Remove()` / `.CancelSend()`) | `Send` class is deprecated (legacy Classic Content send) |
|
|
21
|
+
| `Send.Definition.Init(…)` / `.Add(…)` (and instance methods, e.g. `.Send()`) | `Send.Definition` class is deprecated (legacy Classic Content send definition) |
|
|
22
|
+
| `Email.*` | `Email` class is deprecated in favor of Content Builder / Journey Builder sends |
|
|
20
23
|
| `ErrorUtil.ThrowWSProxyError(…)` | Only exists under `Platform.Load("Core", "1")`; undefined in newer Core versions — check `result.Status` and `throw new Error(…)` instead |
|
|
21
24
|
|
|
22
25
|
## Examples
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
| | |
|
|
6
6
|
|---|---|
|
|
7
7
|
| **Type** | `problem` |
|
|
8
|
-
| **Default severity** | `
|
|
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
|
|
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"` | `"
|
|
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.
|
|
3
|
+
"version": "4.8.1",
|
|
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,7 +42,7 @@
|
|
|
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.
|
|
45
|
+
"ssjs-data": "^1.1.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"eslint": ">=9.0.0"
|
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': '
|
|
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': '
|
|
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',
|
|
@@ -7,18 +7,19 @@
|
|
|
7
7
|
* - ContentAreaByName(...) — bare alias (use Platform.Function.ContentAreaByName instead)
|
|
8
8
|
* - Platform.Function.ContentArea(...)
|
|
9
9
|
* - Platform.Function.ContentAreaByName(...)
|
|
10
|
-
* -
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
10
|
+
* - Any Core Library class flagged `deprecated` in ssjs-data's coreDeprecatedMethodLookup
|
|
11
|
+
* (currently ContentAreaObj, Email, Portfolio, Template, Send, Send.Definition) —
|
|
12
|
+
* both static (`Portfolio.Retrieve(...)`) and instance
|
|
13
|
+
* (`var p = Portfolio.Init(...); p.Update(...)`) call styles, including
|
|
14
|
+
* multi-part static/instance paths (`Send.Definition.Add(...)`).
|
|
15
15
|
* - ErrorUtil.ThrowWSProxyError(...) — deprecated; only exists under Platform.Load("Core", "1")
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import {
|
|
19
19
|
platformFunctionLookup,
|
|
20
20
|
SSJS_GLOBALS,
|
|
21
|
-
|
|
21
|
+
coreObjectNames,
|
|
22
|
+
coreDeprecatedMethodLookup,
|
|
22
23
|
ERROR_UTIL_METHODS,
|
|
23
24
|
} from 'ssjs-data';
|
|
24
25
|
|
|
@@ -28,28 +29,83 @@ const DEPRECATED_GLOBALS = new Map(
|
|
|
28
29
|
SSJS_GLOBALS.filter((g) => g.deprecated).map((g) => [g.name.toLowerCase(), g]),
|
|
29
30
|
);
|
|
30
31
|
|
|
31
|
-
// Build sets of deprecated static and instance methods from ssjs-data.
|
|
32
|
-
// Exclude 'Init' — that call is already implicitly covered when we track the
|
|
33
|
-
// returned instance and flag its instance methods. Reporting it here as well
|
|
34
|
-
// would produce a duplicate error on the same statement.
|
|
35
|
-
const CONTENT_AREA_STATIC_DEPRECATED = new Set(
|
|
36
|
-
CONTENT_AREA_OBJ_METHODS.filter(
|
|
37
|
-
(m) => m.deprecated && m.isStatic && m.name.toLowerCase() !== 'init',
|
|
38
|
-
).map((m) => m.name.toLowerCase()),
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
const CONTENT_AREA_INSTANCE_DEPRECATED = new Set(
|
|
42
|
-
CONTENT_AREA_OBJ_METHODS.filter((m) => m.deprecated && !m.isStatic).map((m) =>
|
|
43
|
-
m.name.toLowerCase(),
|
|
44
|
-
),
|
|
45
|
-
);
|
|
46
|
-
|
|
47
32
|
// Deprecated ErrorUtil methods (e.g. ThrowWSProxyError). Used to flag calls like
|
|
48
33
|
// ErrorUtil.ThrowWSProxyError(result), which only exists under Platform.Load("Core", "1").
|
|
34
|
+
// ErrorUtil is not part of ssjs-data's coreObjectNames / coreDeprecatedMethodLookup (it has
|
|
35
|
+
// no Init-based instance form), so it is handled as its own special case.
|
|
49
36
|
const ERRORUTIL_DEPRECATED = new Set(
|
|
50
37
|
ERROR_UTIL_METHODS.filter((m) => m.deprecated).map((m) => m.name.toLowerCase()),
|
|
51
38
|
);
|
|
52
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Look up a deprecated method entry for a Core Library class.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} className - Core Library class name (e.g. "Portfolio", "Send.Definition")
|
|
44
|
+
* @param {string} methodName - method name (e.g. "Retrieve")
|
|
45
|
+
* @returns {object|null} the ssjs-data method entry, or null when not deprecated
|
|
46
|
+
*/
|
|
47
|
+
function findDeprecatedEntry(className, methodName) {
|
|
48
|
+
const classLookup = coreDeprecatedMethodLookup.get(className.toLowerCase());
|
|
49
|
+
if (!classLookup) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return classLookup.get(methodName.toLowerCase()) || null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Build a dotted member path string from a MemberExpression / Identifier chain.
|
|
57
|
+
*
|
|
58
|
+
* @param {object} node - the object node
|
|
59
|
+
* @returns {string|null} The dotted path, or null when the chain contains
|
|
60
|
+
* anything other than plain identifiers/member accesses.
|
|
61
|
+
*/
|
|
62
|
+
function getMemberPath(node) {
|
|
63
|
+
if (node.type === 'Identifier') {
|
|
64
|
+
return node.name;
|
|
65
|
+
}
|
|
66
|
+
if (node.type === 'MemberExpression' && node.property.type === 'Identifier') {
|
|
67
|
+
const object = getMemberPath(node.object);
|
|
68
|
+
return object ? `${object}.${node.property.name}` : null;
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Resolve the Core Library class name for a `Class.Init(...)` /
|
|
75
|
+
* `A.B.Init(...)` call expression, e.g. `Portfolio.Init(...)` or
|
|
76
|
+
* `Send.Definition.Init(...)`.
|
|
77
|
+
*
|
|
78
|
+
* @param {object} node - the init expression node
|
|
79
|
+
* @returns {string|null} The resolved core class name, or null
|
|
80
|
+
*/
|
|
81
|
+
function getCoreInitType(node) {
|
|
82
|
+
if (!node || node.type !== 'CallExpression') {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
const callee = node.callee;
|
|
86
|
+
if (callee.type !== 'MemberExpression' || callee.property.type !== 'Identifier') {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
if (callee.property.name !== 'Init') {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
const objectPath = getMemberPath(callee.object);
|
|
93
|
+
return objectPath && coreObjectNames.has(objectPath) ? objectPath : null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Extract the trailing "Deprecated — ..." sentence from a deprecated
|
|
98
|
+
* method's `description` so the message surfaces each class's specific
|
|
99
|
+
* reasoning (falls back to a generic note when none is present).
|
|
100
|
+
*
|
|
101
|
+
* @param {object} entry - ssjs-data method entry
|
|
102
|
+
* @returns {string} The deprecation sentence
|
|
103
|
+
*/
|
|
104
|
+
function deprecationNote(entry) {
|
|
105
|
+
const match = /deprecated\s*—\s*(.+)$/i.exec(entry.description || '');
|
|
106
|
+
return match ? `Deprecated — ${match[1]}` : 'This API is deprecated.';
|
|
107
|
+
}
|
|
108
|
+
|
|
53
109
|
export default {
|
|
54
110
|
meta: {
|
|
55
111
|
type: 'suggestion',
|
|
@@ -60,10 +116,9 @@ export default {
|
|
|
60
116
|
deprecatedGlobal: "'{{name}}' is deprecated. {{replacement}}",
|
|
61
117
|
deprecatedPlatformFunction:
|
|
62
118
|
"'Platform.Function.{{name}}' is deprecated. Use a supported alternative.",
|
|
63
|
-
deprecatedCoreStatic:
|
|
64
|
-
"'ContentAreaObj.{{name}}' is deprecated. Content Areas are no longer supported.",
|
|
119
|
+
deprecatedCoreStatic: "'{{name}}' is deprecated. {{note}}",
|
|
65
120
|
deprecatedCoreInstance:
|
|
66
|
-
"'{{method}}' called on a
|
|
121
|
+
"'{{method}}' called on a {{className}} variable is deprecated. {{note}}",
|
|
67
122
|
deprecatedErrorUtil:
|
|
68
123
|
"'ErrorUtil.{{name}}' is deprecated — it only exists under Platform.Load(\"Core\", \"1\") and is undefined in newer Core versions. Check 'result.Status' and 'throw new Error(...)' instead.",
|
|
69
124
|
},
|
|
@@ -71,26 +126,34 @@ export default {
|
|
|
71
126
|
},
|
|
72
127
|
|
|
73
128
|
create(context) {
|
|
74
|
-
// Track variable names assigned via
|
|
75
|
-
|
|
129
|
+
// Track variable names assigned via <CoreClass>.Init(...) → resolved class name,
|
|
130
|
+
// e.g. `var p = Portfolio.Init(...)` → coreVariables.set('p', 'Portfolio').
|
|
131
|
+
const coreVariables = new Map();
|
|
76
132
|
|
|
77
133
|
return {
|
|
78
134
|
VariableDeclaration(node) {
|
|
79
135
|
for (const declaration of node.declarations) {
|
|
80
136
|
if (
|
|
81
|
-
declaration.init
|
|
82
|
-
declaration.id
|
|
83
|
-
declaration.id.type
|
|
84
|
-
isContentAreaObjectInit(declaration.init)
|
|
137
|
+
!declaration.init ||
|
|
138
|
+
!declaration.id ||
|
|
139
|
+
declaration.id.type !== 'Identifier'
|
|
85
140
|
) {
|
|
86
|
-
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const coreType = getCoreInitType(declaration.init);
|
|
144
|
+
if (coreType) {
|
|
145
|
+
coreVariables.set(declaration.id.name, coreType);
|
|
87
146
|
}
|
|
88
147
|
}
|
|
89
148
|
},
|
|
90
149
|
|
|
91
150
|
AssignmentExpression(node) {
|
|
92
|
-
if (node.left.type
|
|
93
|
-
|
|
151
|
+
if (node.left.type !== 'Identifier') {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const coreType = getCoreInitType(node.right);
|
|
155
|
+
if (coreType) {
|
|
156
|
+
coreVariables.set(node.left.name, coreType);
|
|
94
157
|
}
|
|
95
158
|
},
|
|
96
159
|
|
|
@@ -113,15 +176,11 @@ export default {
|
|
|
113
176
|
return;
|
|
114
177
|
}
|
|
115
178
|
|
|
116
|
-
if (callee.type !== 'MemberExpression') {
|
|
179
|
+
if (callee.type !== 'MemberExpression' || callee.property.type !== 'Identifier') {
|
|
117
180
|
return;
|
|
118
181
|
}
|
|
119
182
|
|
|
120
183
|
const property = callee.property;
|
|
121
|
-
if (property.type !== 'Identifier') {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
184
|
const methodName = property.name;
|
|
126
185
|
|
|
127
186
|
// ── Platform.Function.ContentArea(…) / ContentAreaByName(…) ───
|
|
@@ -143,20 +202,6 @@ export default {
|
|
|
143
202
|
return;
|
|
144
203
|
}
|
|
145
204
|
|
|
146
|
-
// ── ContentAreaObj.Init/Add/Retrieve(…) — static deprecated ───
|
|
147
|
-
if (
|
|
148
|
-
callee.object.type === 'Identifier' &&
|
|
149
|
-
callee.object.name === 'ContentAreaObj' &&
|
|
150
|
-
CONTENT_AREA_STATIC_DEPRECATED.has(methodName.toLowerCase())
|
|
151
|
-
) {
|
|
152
|
-
context.report({
|
|
153
|
-
node: property,
|
|
154
|
-
messageId: 'deprecatedCoreStatic',
|
|
155
|
-
data: { name: methodName },
|
|
156
|
-
});
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
205
|
// ── ErrorUtil.ThrowWSProxyError(…) — deprecated ───────────────
|
|
161
206
|
if (
|
|
162
207
|
callee.object.type === 'Identifier' &&
|
|
@@ -171,39 +216,61 @@ export default {
|
|
|
171
216
|
return;
|
|
172
217
|
}
|
|
173
218
|
|
|
174
|
-
|
|
175
|
-
if (
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
)
|
|
219
|
+
const objectPath = getMemberPath(callee.object);
|
|
220
|
+
if (!objectPath) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// ── Static call: Portfolio.Retrieve(…) / Send.Definition.Add(…) ──
|
|
225
|
+
// Exclude Init — that call is already implicitly covered when we
|
|
226
|
+
// track the returned instance and flag its instance methods.
|
|
227
|
+
// Reporting it here as well would produce a duplicate error on
|
|
228
|
+
// the same statement (e.g. `var p = Portfolio.Init(...)`).
|
|
229
|
+
if (coreObjectNames.has(objectPath) && methodName.toLowerCase() !== 'init') {
|
|
230
|
+
const entry = findDeprecatedEntry(objectPath, methodName);
|
|
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) {
|
|
236
|
+
context.report({
|
|
237
|
+
node: property,
|
|
238
|
+
messageId: 'deprecatedCoreStatic',
|
|
239
|
+
data: {
|
|
240
|
+
name: `${objectPath}.${methodName}`,
|
|
241
|
+
note: deprecationNote(entry),
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// ── Instance call: <var>.Update(…) / <var>.SubPath.Method(…) where
|
|
249
|
+
// `var` was assigned from a tracked <CoreClass>.Init(...) call ────
|
|
250
|
+
const segments = objectPath.split('.');
|
|
251
|
+
const rootCoreType = coreVariables.get(segments[0]);
|
|
252
|
+
if (!rootCoreType) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const resolvedClass = [rootCoreType, ...segments.slice(1)].join('.');
|
|
256
|
+
const entry = findDeprecatedEntry(resolvedClass, methodName);
|
|
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) {
|
|
180
263
|
context.report({
|
|
181
264
|
node: property,
|
|
182
265
|
messageId: 'deprecatedCoreInstance',
|
|
183
|
-
data: {
|
|
266
|
+
data: {
|
|
267
|
+
method: methodName,
|
|
268
|
+
className: resolvedClass,
|
|
269
|
+
note: deprecationNote(entry),
|
|
270
|
+
},
|
|
184
271
|
});
|
|
185
272
|
}
|
|
186
273
|
},
|
|
187
274
|
};
|
|
188
275
|
},
|
|
189
276
|
};
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Returns true if `node` is a `ContentAreaObj.Init(…)` call.
|
|
193
|
-
*
|
|
194
|
-
* @param {import('eslint').Rule.Node} node - AST node to inspect
|
|
195
|
-
* @returns {boolean} true when the node is a ContentAreaObj.Init call
|
|
196
|
-
*/
|
|
197
|
-
function isContentAreaObjectInit(node) {
|
|
198
|
-
if (!node || node.type !== 'CallExpression') {
|
|
199
|
-
return false;
|
|
200
|
-
}
|
|
201
|
-
const callee = node.callee;
|
|
202
|
-
return (
|
|
203
|
-
callee.type === 'MemberExpression' &&
|
|
204
|
-
callee.object.type === 'Identifier' &&
|
|
205
|
-
callee.object.name === 'ContentAreaObj' &&
|
|
206
|
-
callee.property.type === 'Identifier' &&
|
|
207
|
-
callee.property.name === 'Init'
|
|
208
|
-
);
|
|
209
|
-
}
|
|
@@ -53,10 +53,18 @@ export default {
|
|
|
53
53
|
create(context) {
|
|
54
54
|
const coreVariables = new Map(); // varName → className
|
|
55
55
|
|
|
56
|
-
|
|
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(
|
|
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(
|
|
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
|
}
|