eslint-plugin-sfmc 4.9.0 → 4.10.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.
package/README.md CHANGED
@@ -122,30 +122,30 @@ export default [...sfmc.configs['recommended-next'], ...sfmc.configs['embedded-n
122
122
 
123
123
  ## SSJS Rules (`ssjs-*`)
124
124
 
125
- | Rule | Default | Description |
126
- | ------------------------------------------------------------------------------------------- | ------------------------ | -------------------------------------------------------------------------- |
127
- | [`sfmc/ssjs-require-platform-load`](docs/rules/ssjs/require-platform-load.md) | `error` | Require `Platform.Load("core")` before Core or requiresCoreLoad globals |
128
- | [`sfmc/ssjs-no-unsupported-syntax`](docs/rules/ssjs/no-unsupported-syntax.md) | `error` | Flag ES6+ syntax not supported by SFMC |
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
- | [`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 (Classic Content classes, ErrorUtil) |
132
- | [`sfmc/ssjs-no-nonexistent-global`](docs/rules/ssjs/no-nonexistent-global.md) | `error` | Flag documented SSJS globals that throw ReferenceError at runtime |
133
- | [`sfmc/ssjs-no-property-call`](docs/rules/ssjs/no-property-call.md) | `error` | Disallow calling Platform.Request/Response properties as functions |
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` |
135
- | [`sfmc/ssjs-require-string-clr-content`](docs/rules/ssjs/require-string-clr-content.md) | `error` | Require wrapping `HttpResponse.content` with `String()` before use |
136
- | [`sfmc/ssjs-platform-function-arity`](docs/rules/ssjs/platform-function-arity.md) | `error` | Enforce correct arity for `Platform.Function.*` |
137
- | [`sfmc/ssjs-require-platform-load-order`](docs/rules/ssjs/require-platform-load-order.md) | `error` | Require `Platform.Load()` before Core usage in order |
138
- | [`sfmc/ssjs-no-hardcoded-credentials`](docs/rules/ssjs/no-hardcoded-credentials.md) | `error` | Flag hardcoded keys in encryption calls |
139
- | [`sfmc/ssjs-cache-loop-length`](docs/rules/ssjs/cache-loop-length.md) | `warn` | Require caching `.length` in for-loops |
140
- | [`sfmc/ssjs-require-hasownproperty`](docs/rules/ssjs/require-hasownproperty.md) | `warn` | Require `hasOwnProperty` guard in for-in loops |
141
- | [`sfmc/ssjs-prefer-platform-load-version`](docs/rules/ssjs/prefer-platform-load-version.md) | `warn` | Enforce a minimum `Platform.Load` version string |
142
- | [`sfmc/ssjs-no-unavailable-method`](docs/rules/ssjs/no-unavailable-method.md) | `warn` | Flag Array/String methods unavailable or broken in SFMC's ES3 engine |
143
- | [`sfmc/ssjs-no-nonfunctional-method`](docs/rules/ssjs/no-nonfunctional-method.md) | `warn` | Flag Core Library methods that never take effect at runtime |
144
- | [`sfmc/ssjs-prefer-parsejson-safe-arg`](docs/rules/ssjs/prefer-parsejson-safe-arg.md) | `warn` | Require string coercion on `ParseJSON` argument |
145
- | [`sfmc/ssjs-no-switch-default`](docs/rules/ssjs/no-switch-default.md) | `warn` | Disallow `default` clause in `switch` statements |
146
- | [`sfmc/ssjs-no-treatascontent-injection`](docs/rules/ssjs/no-treatascontent-injection.md) | `warn` | Flag dynamic string concatenation in `TreatAsContent` calls |
147
- | [`sfmc/ssjs-core-method-arity`](docs/rules/ssjs/core-method-arity.md) | `warn` | Enforce correct argument counts for Core Library object methods |
148
- | [`sfmc/ssjs-arg-types`](docs/rules/ssjs/arg-types.md) | `warn` | Check that literal arguments match expected parameter types |
125
+ | Rule | Default | Description |
126
+ | ------------------------------------------------------------------------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
127
+ | [`sfmc/ssjs-require-platform-load`](docs/rules/ssjs/require-platform-load.md) | `error` | Require `Platform.Load("core")` before Core or requiresCoreLoad globals |
128
+ | [`sfmc/ssjs-no-unsupported-syntax`](docs/rules/ssjs/no-unsupported-syntax.md) | `error` | Flag ES6+ syntax not supported by SFMC |
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
+ | [`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 deprecated SFMC SSJS APIs (Classic Content classes, ErrorUtil); reports a stronger "undefined at runtime" message when the loaded Core version no longer provides the API |
132
+ | [`sfmc/ssjs-no-nonexistent-global`](docs/rules/ssjs/no-nonexistent-global.md) | `error` | Flag documented SSJS globals that throw ReferenceError at runtime |
133
+ | [`sfmc/ssjs-no-property-call`](docs/rules/ssjs/no-property-call.md) | `error` | Disallow calling Platform.Request/Response properties as functions |
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` |
135
+ | [`sfmc/ssjs-require-string-clr-content`](docs/rules/ssjs/require-string-clr-content.md) | `error` | Require wrapping `HttpResponse.content` with `String()` before use |
136
+ | [`sfmc/ssjs-platform-function-arity`](docs/rules/ssjs/platform-function-arity.md) | `error` | Enforce correct arity for `Platform.Function.*` |
137
+ | [`sfmc/ssjs-require-platform-load-order`](docs/rules/ssjs/require-platform-load-order.md) | `error` | Require `Platform.Load()` before Core usage in order |
138
+ | [`sfmc/ssjs-no-hardcoded-credentials`](docs/rules/ssjs/no-hardcoded-credentials.md) | `error` | Flag hardcoded keys in encryption calls |
139
+ | [`sfmc/ssjs-cache-loop-length`](docs/rules/ssjs/cache-loop-length.md) | `warn` | Require caching `.length` in for-loops |
140
+ | [`sfmc/ssjs-require-hasownproperty`](docs/rules/ssjs/require-hasownproperty.md) | `warn` | Require `hasOwnProperty` guard in for-in loops |
141
+ | [`sfmc/ssjs-prefer-platform-load-version`](docs/rules/ssjs/prefer-platform-load-version.md) | `warn` | Enforce a minimum `Platform.Load` version string; autofix is withheld in files using `ErrorUtil` |
142
+ | [`sfmc/ssjs-no-unavailable-method`](docs/rules/ssjs/no-unavailable-method.md) | `warn` | Flag Array/String methods unavailable or broken in SFMC's ES3 engine |
143
+ | [`sfmc/ssjs-no-nonfunctional-method`](docs/rules/ssjs/no-nonfunctional-method.md) | `warn` | Flag Core Library methods that never take effect at runtime |
144
+ | [`sfmc/ssjs-prefer-parsejson-safe-arg`](docs/rules/ssjs/prefer-parsejson-safe-arg.md) | `warn` | Require string coercion on `ParseJSON` argument |
145
+ | [`sfmc/ssjs-no-switch-default`](docs/rules/ssjs/no-switch-default.md) | `warn` | Disallow `default` clause in `switch` statements |
146
+ | [`sfmc/ssjs-no-treatascontent-injection`](docs/rules/ssjs/no-treatascontent-injection.md) | `warn` | Flag dynamic string concatenation in `TreatAsContent` calls |
147
+ | [`sfmc/ssjs-core-method-arity`](docs/rules/ssjs/core-method-arity.md) | `warn` | Enforce correct argument counts for Core Library object methods |
148
+ | [`sfmc/ssjs-arg-types`](docs/rules/ssjs/arg-types.md) | `warn` | Check that literal arguments match expected parameter types |
149
149
 
150
150
  ## Handlebars Rules (`hbs-*`)
151
151
 
@@ -182,7 +182,7 @@ Severities above are the same in `embedded`, `strict`, `embedded-next`, and `str
182
182
 
183
183
  [`eslint-plugin-unicorn`](https://github.com/sindresorhus/eslint-plugin-unicorn) is a high-quality, widely used plugin that we **strongly recommend** — but it is built for modern JavaScript, not SFMC's **SSJS** runtime. SFMC SSJS runs on a JINT-based ES3/ES5-era engine that lacks many built-ins (`Array#includes`, `String#startsWith`, `Set`, `Map`, `Object.fromEntries`, `Math.trunc`, spread `...`, ES modules, `async`/`await`, …).
184
184
 
185
- If you enable unicorn's `recommended` set on SSJS, about **46** of its 300 recommended rules would either **autofix your code to a missing built-in** (breaking it at runtime) or **forbid a required SFMC workaround**. `eslint-plugin-sfmc` offers an **optional** override config that turns off exactly those 46 rules for SSJS.
185
+ If you enable unicorn's `recommended` set on SSJS, about **46** of its 308 recommended rules would either **autofix your code to a missing built-in** (breaking it at runtime) or **forbid a required SFMC workaround**. `eslint-plugin-sfmc` offers an **optional** override config that turns off exactly those 46 rules for SSJS.
186
186
 
187
187
  **Important — this is optional and only needed if you use unicorn.** `eslint-plugin-sfmc` does **not** depend on or load unicorn. The override configs are plain rules objects with **no** `plugins` key, so they only resolve when your own unicorn config (which registers the `unicorn` plugin) is loaded **earlier** in the flat-config array. Spread the sfmc override **after** it:
188
188
 
@@ -204,7 +204,7 @@ export default [
204
204
  | `sfmc.configs['unicorn-ssjs']` | `**/*.ssjs` | Turns off the 46 SFMC-incompatible unicorn rules for SSJS |
205
205
  | `sfmc.configs['unicorn-ssjs-embedded']` | `**/*.html/*.js` | Same 46-rule override for SSJS embedded in HTML |
206
206
 
207
- Only **46** of unicorn's 300 recommended rules are overridden — the other **254** stay active. If you don't use unicorn, omit these configs entirely. For the full rule-by-rule breakdown (with rationale and SFMC evidence links, pinned to unicorn v71.1.0), see [docs/unicorn-compatibility.md](docs/unicorn-compatibility.md).
207
+ Only **46** of unicorn's 308 recommended rules are overridden — the other **262** stay active. If you don't use unicorn, omit these configs entirely. For the full rule-by-rule breakdown (with rationale and SFMC evidence links, pinned to unicorn v73.0.0), see [docs/unicorn-compatibility.md](docs/unicorn-compatibility.md).
208
208
 
209
209
  ## Processors
210
210
 
@@ -22,6 +22,23 @@ plus the legacy `ErrorUtil` helper that only exists under the oldest Core versio
22
22
  | `Email.*` | `Email` class is deprecated in favor of Content Builder / Journey Builder sends |
23
23
  | `ErrorUtil.ThrowWSProxyError(…)` | Only exists under `Platform.Load("Core", "1")`; undefined in newer Core versions — check `result.Status` and `throw new Error(…)` instead |
24
24
 
25
+ ## `ErrorUtil` — two message variants
26
+
27
+ `ErrorUtil` is bound to a maximum Core version (`maxCoreVersion: "1"` in `ssjs-data`), so
28
+ the rule picks its wording from the `Platform.Load("Core", …)` version the file loads:
29
+
30
+ | Loaded Core version | Message | Meaning |
31
+ |---|---|---|
32
+ | `"1"`, or no version argument, or no `Platform.Load` at all | *"… is deprecated …"* | The call works today, but the API is retired — migrate away from it |
33
+ | Anything above `"1"` (`"1.1.1"`, `"1.1.5"`, `"2"`, …) | *"… is undefined under Platform.Load("Core", "…") …"* | `ErrorUtil` does not exist at runtime — the call throws a `TypeError` |
34
+
35
+ The applicable load is the nearest preceding `Platform.Load("Core", …)`; when every load
36
+ appears after the call, the first one in the file is used (it still governs at runtime).
37
+
38
+ Because bumping the Core version would break such a file,
39
+ [`sfmc/ssjs-prefer-platform-load-version`](./prefer-platform-load-version.md) withholds
40
+ its autofix whenever `ErrorUtil` is used.
41
+
25
42
  ## Examples
26
43
 
27
44
  ### ❌ Incorrect
@@ -51,6 +51,14 @@ What the fix does:
51
51
  - When the version argument is present but wrong: replaces the version string literal with the required version.
52
52
  - When the version argument is missing entirely: inserts `, "1.1.5"` after the `"core"` argument.
53
53
 
54
+ ### Files using `ErrorUtil` are reported but not fixed
55
+
56
+ `ErrorUtil` is provided only by `Platform.Load("Core", "1")` — under any newer version it is
57
+ `undefined` and calling it throws a `TypeError`. When the file contains an `ErrorUtil` usage,
58
+ the version is still reported but **no fix is attached**, so `eslint --fix` cannot silently
59
+ break working code. Migrate off `ErrorUtil` first (see
60
+ [`sfmc/ssjs-no-deprecated-function`](./no-deprecated-function.md)), then bump the version.
61
+
54
62
  ## Configuration Example
55
63
 
56
64
  ```js
@@ -1,15 +1,15 @@
1
1
  # `eslint-plugin-unicorn` compatibility with SFMC SSJS
2
2
 
3
- > **Compatibility analysis for [`eslint-plugin-unicorn@71.1.0`](https://github.com/sindresorhus/eslint-plugin-unicorn).**
3
+ > **Compatibility analysis for [`eslint-plugin-unicorn@73.0.0`](https://github.com/sindresorhus/eslint-plugin-unicorn).**
4
4
  >
5
- > ⚠️ **Version warning:** This classification was done against `eslint-plugin-unicorn` **v71.1.0** (300 recommended rules). Newer versions of unicorn may add, rename, or change rules that are **not** yet classified here. Re-audit this page whenever you upgrade unicorn — a rule added in a later version could autofix SSJS into runtime-breaking code without being in the override list below.
5
+ > ⚠️ **Version warning:** This classification was done against `eslint-plugin-unicorn` **v73.0.0** (308 recommended rules). Newer versions of unicorn may add, rename, or change rules that are **not** yet classified here. Re-audit this page whenever you upgrade unicorn — a rule added in a later version could autofix SSJS into runtime-breaking code without being in the override list below.
6
6
 
7
7
  `eslint-plugin-unicorn` is an excellent, actively maintained plugin that we **strongly recommend** — but it targets modern JavaScript engines, not the Salesforce Marketing Cloud **SSJS** runtime. SFMC SSJS runs on a JINT-based ES3/ES5-era engine that is missing many built-ins (`Array#includes`, `String#startsWith`, `Set`, `Map`, `Object.fromEntries`, `Math.trunc`, spread `...`, ES modules, `async`/`await`, …). See the SFMC evidence pages:
8
8
 
9
9
  - **ECMAScript built-ins support** — <https://ssjs.guide/ecmascript-builtins/>
10
10
  - **Engine limitations** — <https://ssjs.guide/engine-limitations/>
11
11
 
12
- Of unicorn's **300** recommended rules (v71.1.0), **254** are safe to keep on for SSJS and **46** should be turned off. `eslint-plugin-sfmc` ships an **optional** override config (`unicorn-ssjs` / `unicorn-ssjs-embedded`) that turns off exactly those 46 for SSJS files. `eslint-plugin-sfmc` does **not** depend on or load unicorn — the override only takes effect when you have loaded unicorn yourself. See [Section 1](#section-1--how-to-apply).
12
+ Of unicorn's **308** recommended rules (v73.0.0), **262** are safe to keep on for SSJS and **46** should be turned off. `eslint-plugin-sfmc` ships an **optional** override config (`unicorn-ssjs` / `unicorn-ssjs-embedded`) that turns off exactly those 46 for SSJS files. `eslint-plugin-sfmc` does **not** depend on or load unicorn — the override only takes effect when you have loaded unicorn yourself. See [Section 1](#section-1--how-to-apply).
13
13
 
14
14
  ---
15
15
 
@@ -41,7 +41,7 @@ If you don't use unicorn, omit these configs entirely — nothing else in `eslin
41
41
 
42
42
  ## Section 2 — Rules to override for SSJS (46)
43
43
 
44
- These 46 recommended rules either **autofix code to a missing built-in**, **forbid a documented SFMC workaround**, or **enforce ES-module / async / ES6-only syntax** the engine cannot run. The override config sets each to `'off'` for SSJS. All 46 are confirmed `recommended` in unicorn v71.1.0.
44
+ These 46 recommended rules either **autofix code to a missing built-in**, **forbid a documented SFMC workaround**, or **enforce ES-module / async / ES6-only syntax** the engine cannot run. The override config sets each to `'off'` for SSJS. All 46 are confirmed `recommended` in unicorn v73.0.0.
45
45
 
46
46
  ### Group A — autofix to a missing built-in / forbid a SFMC workaround (41)
47
47
 
@@ -103,11 +103,11 @@ These 46 recommended rules either **autofix code to a missing built-in**, **forb
103
103
 
104
104
  ---
105
105
 
106
- ## Section 3 — Rules OK as-is (254)
106
+ ## Section 3 — Rules OK as-is (262)
107
107
 
108
108
  These recommended rules are **not** disabled by the override config. They are either genuinely SFMC-safe (readability / best-practice rules that work on the ES3/ES5 engine) or **inert** on SSJS — many target the DOM, Node.js, Promises, TypeScript, or ES modules and therefore never fire on server-side SFMC code. Each links to its official unicorn documentation.
109
109
 
110
- <!-- BEGIN 254-OK-LIST -->
110
+ <!-- BEGIN 262-OK-LIST -->
111
111
  - [better-dom-traversing](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/better-dom-traversing.md)
112
112
  - [catch-error-name](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/catch-error-name.md)
113
113
  - [class-reference-in-static-methods](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/class-reference-in-static-methods.md)
@@ -150,8 +150,8 @@ These recommended rules are **not** disabled by the override config. They are ei
150
150
  - [no-array-from-fill](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-from-fill.md)
151
151
  - [no-array-method-this-argument](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-method-this-argument.md)
152
152
  - [no-array-reduce](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-reduce.md)
153
- - [no-array-sort](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-sort.md)
154
153
  - [no-array-sort-for-min-max](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-sort-for-min-max.md)
154
+ - [no-array-sort](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-sort.md)
155
155
  - [no-array-splice](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-splice.md)
156
156
  - [no-async-promise-finally](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-async-promise-finally.md)
157
157
  - [no-await-expression-member](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-await-expression-member.md)
@@ -195,6 +195,7 @@ These recommended rules are **not** disabled by the override config. They are ei
195
195
  - [no-magic-array-flat-depth](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-magic-array-flat-depth.md)
196
196
  - [no-mismatched-map-key](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-mismatched-map-key.md)
197
197
  - [no-misrefactored-assignment](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-misrefactored-assignment.md)
198
+ - [no-multiple-promise-resolver-calls](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-multiple-promise-resolver-calls.md)
198
199
  - [no-named-default](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-named-default.md)
199
200
  - [no-negated-array-predicate](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-negated-array-predicate.md)
200
201
  - [no-negated-comparison](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-negated-comparison.md)
@@ -213,6 +214,7 @@ These recommended rules are **not** disabled by the override config. They are ei
213
214
  - [no-redundant-comparison](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-redundant-comparison.md)
214
215
  - [no-return-array-push](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-return-array-push.md)
215
216
  - [no-selector-as-dom-name](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-selector-as-dom-name.md)
217
+ - [no-shorthand-property-overrides](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-shorthand-property-overrides.md)
216
218
  - [no-single-promise-in-promise-methods](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-single-promise-in-promise-methods.md)
217
219
  - [no-static-only-class](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-static-only-class.md)
218
220
  - [no-subtraction-comparison](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-subtraction-comparison.md)
@@ -221,6 +223,7 @@ These recommended rules are **not** disabled by the override config. They are ei
221
223
  - [no-this-outside-of-class](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-this-outside-of-class.md)
222
224
  - [no-top-level-assignment-in-function](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-top-level-assignment-in-function.md)
223
225
  - [no-top-level-side-effects](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-top-level-side-effects.md)
226
+ - [no-transition-all](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-transition-all.md)
224
227
  - [no-typeof-undefined](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-typeof-undefined.md)
225
228
  - [no-uncalled-method](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-uncalled-method.md)
226
229
  - [no-undeclared-class-members](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-undeclared-class-members.md)
@@ -243,6 +246,7 @@ These recommended rules are **not** disabled by the override config. They are ei
243
246
  - [no-unsafe-buffer-conversion](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unsafe-buffer-conversion.md)
244
247
  - [no-unsafe-promise-all-settled-values](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unsafe-promise-all-settled-values.md)
245
248
  - [no-unsafe-property-key](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unsafe-property-key.md)
249
+ - [no-unsafe-sqlite-interpolation](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unsafe-sqlite-interpolation.md)
246
250
  - [no-unsafe-string-replacement](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unsafe-string-replacement.md)
247
251
  - [no-unused-array-method-return](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unused-array-method-return.md)
248
252
  - [no-useless-boolean-cast](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-boolean-cast.md)
@@ -260,6 +264,7 @@ These recommended rules are **not** disabled by the override config. They are ei
260
264
  - [no-useless-logical-operand](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-logical-operand.md)
261
265
  - [no-useless-override](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-override.md)
262
266
  - [no-useless-promise-resolve-reject](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-promise-resolve-reject.md)
267
+ - [no-useless-re-export](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-re-export.md)
263
268
  - [no-useless-recursion](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-recursion.md)
264
269
  - [no-useless-spread](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-spread.md)
265
270
  - [no-useless-switch-case](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-switch-case.md)
@@ -272,8 +277,8 @@ These recommended rules are **not** disabled by the override config. They are ei
272
277
  - [operator-assignment](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/operator-assignment.md)
273
278
  - [prefer-abort-signal-any](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-abort-signal-any.md)
274
279
  - [prefer-abort-signal-timeout](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-abort-signal-timeout.md)
275
- - [prefer-add-event-listener](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-add-event-listener.md)
276
280
  - [prefer-add-event-listener-options](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-add-event-listener-options.md)
281
+ - [prefer-add-event-listener](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-add-event-listener.md)
277
282
  - [prefer-aggregate-error](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-aggregate-error.md)
278
283
  - [prefer-array-from-map](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-from-map.md)
279
284
  - [prefer-array-from-range](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-from-range.md)
@@ -290,6 +295,7 @@ These recommended rules are **not** disabled by the override config. They are ei
290
295
  - [prefer-default-parameters](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-default-parameters.md)
291
296
  - [prefer-direct-iteration](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-direct-iteration.md)
292
297
  - [prefer-dom-node-append](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-dom-node-append.md)
298
+ - [prefer-dom-node-html-methods](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-dom-node-html-methods.md)
293
299
  - [prefer-dom-node-remove](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-dom-node-remove.md)
294
300
  - [prefer-dom-node-replace-children](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-dom-node-replace-children.md)
295
301
  - [prefer-dom-node-text-content](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-dom-node-text-content.md)
@@ -305,8 +311,8 @@ These recommended rules are **not** disabled by the override config. They are ei
305
311
  - [prefer-identifier-import-export-specifiers](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-identifier-import-export-specifiers.md)
306
312
  - [prefer-includes-over-repeated-comparisons](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-includes-over-repeated-comparisons.md)
307
313
  - [prefer-iterable-in-constructor](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-iterable-in-constructor.md)
308
- - [prefer-iterator-to-array](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-iterator-to-array.md)
309
314
  - [prefer-iterator-to-array-at-end](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-iterator-to-array-at-end.md)
315
+ - [prefer-iterator-to-array](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-iterator-to-array.md)
310
316
  - [prefer-keyboard-event-key](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-keyboard-event-key.md)
311
317
  - [prefer-location-assign](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-location-assign.md)
312
318
  - [prefer-logical-operator-over-ternary](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-logical-operator-over-ternary.md)
@@ -340,6 +346,7 @@ These recommended rules are **not** disabled by the override config. They are ei
340
346
  - [prefer-split-limit](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-split-limit.md)
341
347
  - [prefer-switch](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-switch.md)
342
348
  - [prefer-ternary](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-ternary.md)
349
+ - [prefer-then-catch](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-then-catch.md)
343
350
  - [prefer-toggle-attribute](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-toggle-attribute.md)
344
351
  - [prefer-type-error](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-type-error.md)
345
352
  - [prefer-type-literal-last](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-type-literal-last.md)
@@ -357,10 +364,11 @@ These recommended rules are **not** disabled by the override config. They are ei
357
364
  - [require-number-to-fixed-digits-argument](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/require-number-to-fixed-digits-argument.md)
358
365
  - [require-passive-events](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/require-passive-events.md)
359
366
  - [require-proxy-trap-boolean-return](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/require-proxy-trap-boolean-return.md)
367
+ - [single-line-block-comment-style](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/single-line-block-comment-style.md)
360
368
  - [switch-case-braces](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/switch-case-braces.md)
361
369
  - [switch-case-break-position](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/switch-case-break-position.md)
362
370
  - [template-indent](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/template-indent.md)
363
371
  - [text-encoding-identifier-case](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/text-encoding-identifier-case.md)
364
372
  - [throw-new-error](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/throw-new-error.md)
365
- <!-- END 254-OK-LIST -->
373
+ <!-- END 262-OK-LIST -->
366
374
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-sfmc",
3
- "version": "4.9.0",
3
+ "version": "4.10.0",
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",
@@ -37,12 +37,12 @@
37
37
  ],
38
38
  "dependencies": {
39
39
  "@handlebars/parser": "^2.2.2",
40
- "ampscript-data": "^3.1.0",
41
- "ampscript-parser": "^0.3.0",
40
+ "ampscript-data": "^3.1.1",
41
+ "ampscript-parser": "^0.3.1",
42
42
  "eslint-plugin-mso-email": "^2.0.0",
43
- "handlebars-data": "^0.3.0",
43
+ "handlebars-data": "^0.3.1",
44
44
  "mso-conditional-parser": "^2.0.1",
45
- "ssjs-data": "^1.2.0"
45
+ "ssjs-data": "^1.4.0"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "eslint": ">=9.0.0"
@@ -64,15 +64,15 @@
64
64
  },
65
65
  "devDependencies": {
66
66
  "@eslint/js": "^10.0.1",
67
- "eslint": "^10.6.0",
67
+ "eslint": "^10.8.0",
68
68
  "eslint-config-prettier": "^10.1.8",
69
- "eslint-plugin-jsdoc": "^63.0.12",
69
+ "eslint-plugin-jsdoc": "^63.3.3",
70
70
  "eslint-plugin-prettier": "^5.5.6",
71
- "eslint-plugin-unicorn": "^71.1.0",
72
- "globals": "^17.7.0",
71
+ "eslint-plugin-unicorn": "^73.0.0",
72
+ "globals": "^17.9.0",
73
73
  "husky": "^9.1.7",
74
- "lint-staged": "^17.0.8",
75
- "prettier": "^3.9.4"
74
+ "lint-staged": "^17.3.0",
75
+ "prettier": "^3.9.6"
76
76
  },
77
77
  "lint-staged": {
78
78
  "*.{js,mjs,cjs}": [
package/src/index.js CHANGED
@@ -323,7 +323,9 @@ const hbsOffRules = {
323
323
  'sfmc/hbs-no-mcn-unsupported': 'off',
324
324
  };
325
325
 
326
- /** Shared languageOptions for linting virtual `.hbs` files. */
326
+ /**
327
+ * Shared languageOptions for linting virtual `.hbs` files.
328
+ */
327
329
  const hbsLanguageOptions = { parser: handlebarsParser };
328
330
 
329
331
  /**
@@ -353,7 +355,7 @@ function standaloneHandlebarsConfigs(configName) {
353
355
 
354
356
  /**
355
357
  * The 46 `eslint-plugin-unicorn` recommended rules (analysed against
356
- * unicorn v71.1.0) that are incompatible with the SFMC SSJS (JINT / ES3-ES5)
358
+ * unicorn v73.0.0) that are incompatible with the SFMC SSJS (JINT / ES3-ES5)
357
359
  * engine — they either autofix code to a missing built-in or forbid a required
358
360
  * SFMC workaround, or enforce ES-module / async / ES6-only syntax that the
359
361
  * engine cannot run. Each is mapped to `'off'`.
package/src/processor.js CHANGED
@@ -29,7 +29,9 @@ const SSJS_SCRIPT_OPEN_RE =
29
29
  /<script\b(?=[^>]*\brunat\s*=\s*['"]server['"])(?![^>]*\blanguage\s*=\s*['"]ampscript['"])[^>]*>/gi;
30
30
  const SCRIPT_CLOSE_G = /<\/script\s*>/gi;
31
31
 
32
- /** AMPscript region patterns blanked before the Handlebars parser runs. */
32
+ /**
33
+ * AMPscript region patterns blanked before the Handlebars parser runs.
34
+ */
33
35
  const AMPSCRIPT_REGION_PATTERNS = [
34
36
  /%%\[[\s\S]*?\]%%/g,
35
37
  /%%=[\s\S]*?=%%/g,
@@ -5,7 +5,9 @@
5
5
  * that ESLint diagnostics and editor diagnostics stay consistent.
6
6
  */
7
7
 
8
- /** Matches a `{!$namespace.Field}` built-in data binding token. */
8
+ /**
9
+ * Matches a `{!$namespace.Field}` built-in data binding token.
10
+ */
9
11
  export const BINDING_PATTERN = /\{!\$([A-Za-z0-9_.]+)\}/g;
10
12
 
11
13
  /**
@@ -12,9 +12,13 @@ import { BINDING_PATTERN, closestMatch } from './_shared.js';
12
12
  * than walking the AST.
13
13
  */
14
14
 
15
- /** Proper-cased built-in binding names, used for "did you mean" suggestions. */
15
+ /**
16
+ * Proper-cased built-in binding names, used for "did you mean" suggestions.
17
+ */
16
18
  const BINDING_NAME_LIST = BUILTIN_BINDINGS.map((b) => b.name);
17
- /** Map from lowercase binding name to its `{!$...}` token, for suggestion text. */
19
+ /**
20
+ * Map from lowercase binding name to its `{!$...}` token, for suggestion text.
21
+ */
18
22
  const BINDING_TOKEN_BY_NAME = new Map(BUILTIN_BINDINGS.map((b) => [b.name.toLowerCase(), b.token]));
19
23
 
20
24
  export default {
@@ -11,14 +11,18 @@ import { simpleHelperName } from './_shared.js';
11
11
  * sfmc-language-lsp.
12
12
  */
13
13
 
14
- /** AST node types that may carry an unsupported construct. */
14
+ /**
15
+ * AST node types that may carry an unsupported construct.
16
+ */
15
17
  const NODE_TYPES = unsupportedByNodeType.keys().toArray();
16
18
 
17
19
  // The handlebars-data messages contain literal `{{> ...}}`, `{{log}}`, etc. as
18
20
  // examples. ESLint treats `{{...}}` in a message template as an interpolation
19
21
  // placeholder, so the literal text is passed through a single `{{text}}`
20
22
  // placeholder instead of being baked into the template.
21
- /** messageId per construct id → passthrough template, declared statically. */
23
+ /**
24
+ * messageId per construct id → passthrough template, declared statically.
25
+ */
22
26
  const MESSAGES = Object.fromEntries(
23
27
  unsupportedByNodeType
24
28
  .values()
@@ -19,7 +19,9 @@
19
19
  * and rewrites the access to `getHeaderMap(resp)["name"]`.
20
20
  */
21
21
 
22
- /** Canonical helper inserted by the quick-fix, mirrored from ssjs.guide. */
22
+ /**
23
+ * Canonical helper inserted by the quick-fix, mirrored from ssjs.guide.
24
+ */
23
25
  const HEADER_MAP_HELPER = `/**
24
26
  * Build a plain { name: value } header map from an HttpResponse.
25
27
  * Reads only the for..in enumeration keys (shaped "[Name, Value]") so it never
@@ -12,7 +12,9 @@
12
12
  * both static (`Portfolio.Retrieve(...)`) and instance
13
13
  * (`var p = Portfolio.Init(...); p.Update(...)`) call styles, including
14
14
  * multi-part static/instance paths (`Send.Definition.Add(...)`).
15
- * - ErrorUtil.ThrowWSProxyError(...) — deprecated; only exists under Platform.Load("Core", "1")
15
+ * - ErrorUtil.ThrowWSProxyError(...) — deprecated; only exists under Platform.Load("Core", "1").
16
+ * When the file loads a Core version above the entry's `maxCoreVersion` the call is
17
+ * undefined at runtime, so the stronger `unavailableInCoreVersion` message is used.
16
18
  */
17
19
 
18
20
  import {
@@ -21,6 +23,7 @@ import {
21
23
  coreObjectNames,
22
24
  coreDeprecatedMethodLookup,
23
25
  ERROR_UTIL_METHODS,
26
+ maxCoreVersionLookup,
24
27
  } from 'ssjs-data';
25
28
 
26
29
  // Lookup Map: lowercase name → entry, for SSJS_GLOBALS entries that are deprecated.
@@ -93,6 +96,77 @@ function getCoreInitType(node) {
93
96
  return objectPath && coreObjectNames.has(objectPath) ? objectPath : null;
94
97
  }
95
98
 
99
+ /**
100
+ * Detect `Platform.Load("core", …)` and return the version literal it loads.
101
+ *
102
+ * @param {object} node - a CallExpression node
103
+ * @returns {string|null} the version string, '' when the version argument is
104
+ * missing or not a string literal, or null when this is not a core load
105
+ */
106
+ function getCoreLoadVersion(node) {
107
+ const callee = node.callee;
108
+ if (
109
+ callee.type !== 'MemberExpression' ||
110
+ callee.object.type !== 'Identifier' ||
111
+ callee.object.name !== 'Platform' ||
112
+ callee.property.type !== 'Identifier' ||
113
+ callee.property.name !== 'Load'
114
+ ) {
115
+ return null;
116
+ }
117
+ const arguments_ = node.arguments;
118
+ if (
119
+ arguments_.length === 0 ||
120
+ arguments_[0].type !== 'Literal' ||
121
+ typeof arguments_[0].value !== 'string' ||
122
+ arguments_[0].value.toLowerCase() !== 'core'
123
+ ) {
124
+ return null;
125
+ }
126
+ const versionArgument = arguments_[1];
127
+ if (
128
+ versionArgument &&
129
+ versionArgument.type === 'Literal' &&
130
+ typeof versionArgument.value === 'string'
131
+ ) {
132
+ return versionArgument.value;
133
+ }
134
+ return '';
135
+ }
136
+
137
+ /**
138
+ * Split a Core version string into three numeric segments, padding missing
139
+ * ones with 0 so "1" and "1.0.0" are equivalent.
140
+ *
141
+ * @param {string} version - version string, e.g. "1" or "1.1.5"
142
+ * @returns {number[]} three numeric segments
143
+ */
144
+ function parseCoreVersion(version) {
145
+ const parts = version.split('.').map((p) => Number(p) || 0);
146
+ while (parts.length < 3) {
147
+ parts.push(0);
148
+ }
149
+ return parts;
150
+ }
151
+
152
+ /**
153
+ * Compare two Core version strings ("1", "1.1.5", …) numerically.
154
+ *
155
+ * @param {string} a - left version
156
+ * @param {string} b - right version
157
+ * @returns {number} negative when a < b, 0 when equal, positive when a > b
158
+ */
159
+ function compareCoreVersions(a, b) {
160
+ const left = parseCoreVersion(a);
161
+ const right = parseCoreVersion(b);
162
+ for (const [index, element] of left.entries()) {
163
+ if (element !== right[index]) {
164
+ return element - right[index];
165
+ }
166
+ }
167
+ return 0;
168
+ }
169
+
96
170
  /**
97
171
  * Extract the trailing "Deprecated — ..." sentence from a deprecated
98
172
  * method's `description` so the message surfaces each class's specific
@@ -121,6 +195,8 @@ export default {
121
195
  "'{{method}}' called on a {{className}} variable is deprecated. {{note}}",
122
196
  deprecatedErrorUtil:
123
197
  "'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.",
198
+ unavailableInCoreVersion:
199
+ '\'ErrorUtil.{{name}}\' is undefined under Platform.Load("Core", "{{version}}") — it only exists in Core version "{{max}}", so this call throws a TypeError at runtime. Check \'result.Status\' and \'throw new Error(...)\' instead.',
124
200
  },
125
201
  schema: [],
126
202
  },
@@ -129,6 +205,11 @@ export default {
129
205
  // Track variable names assigned via <CoreClass>.Init(...) → resolved class name,
130
206
  // e.g. `var p = Portfolio.Init(...)` → coreVariables.set('p', 'Portfolio').
131
207
  const coreVariables = new Map();
208
+ // Every Platform.Load("core", <version>) in the file, as { line, version }.
209
+ const coreLoads = [];
210
+ // ErrorUtil call sites, resolved to the applicable Core version on Program:exit
211
+ // (a load may appear after the usage in source order).
212
+ const errorUtilityUsages = [];
132
213
 
133
214
  return {
134
215
  VariableDeclaration(node) {
@@ -160,6 +241,13 @@ export default {
160
241
  CallExpression(node) {
161
242
  const callee = node.callee;
162
243
 
244
+ // ── Platform.Load("core", <version>) — remember for ErrorUtil ──
245
+ const loadedVersion = getCoreLoadVersion(node);
246
+ if (loadedVersion !== null) {
247
+ coreLoads.push({ line: node.loc.start.line, version: loadedVersion });
248
+ return;
249
+ }
250
+
163
251
  // ── Bare globals: ContentArea(…) and ContentAreaByName(…) ──────
164
252
  if (callee.type === 'Identifier') {
165
253
  const entry = DEPRECATED_GLOBALS.get(callee.name.toLowerCase());
@@ -203,16 +291,14 @@ export default {
203
291
  }
204
292
 
205
293
  // ── ErrorUtil.ThrowWSProxyError(…) — deprecated ───────────────
294
+ // Reported on Program:exit: the wording depends on the loaded Core
295
+ // version, which may be declared after this call site.
206
296
  if (
207
297
  callee.object.type === 'Identifier' &&
208
298
  callee.object.name === 'ErrorUtil' &&
209
299
  ERRORUTIL_DEPRECATED.has(methodName.toLowerCase())
210
300
  ) {
211
- context.report({
212
- node: property,
213
- messageId: 'deprecatedErrorUtil',
214
- data: { name: methodName },
215
- });
301
+ errorUtilityUsages.push({ node: property, name: methodName });
216
302
  return;
217
303
  }
218
304
 
@@ -271,6 +357,44 @@ export default {
271
357
  });
272
358
  }
273
359
  },
360
+
361
+ 'Program:exit'() {
362
+ const maxCoreVersion = maxCoreVersionLookup.get('errorutil')?.maxCoreVersion;
363
+ for (const usage of errorUtilityUsages) {
364
+ // The applicable load is the nearest preceding one; when the file
365
+ // only loads Core after the usage, that load still governs at
366
+ // runtime, so fall back to the first load in the file.
367
+ const usageLine = usage.node.loc.start.line;
368
+ const preceding = coreLoads.filter((l) => l.line <= usageLine);
369
+ const applicable = preceding.length > 0 ? preceding.at(-1) : coreLoads[0];
370
+
371
+ if (
372
+ maxCoreVersion &&
373
+ applicable &&
374
+ applicable.version &&
375
+ compareCoreVersions(applicable.version, maxCoreVersion) > 0
376
+ ) {
377
+ context.report({
378
+ node: usage.node,
379
+ messageId: 'unavailableInCoreVersion',
380
+ data: {
381
+ name: usage.name,
382
+ version: applicable.version,
383
+ max: maxCoreVersion,
384
+ },
385
+ });
386
+ continue;
387
+ }
388
+
389
+ // No core load at all, no version argument, or a version within the
390
+ // supported range — ssjs-require-platform-load owns the missing-load case.
391
+ context.report({
392
+ node: usage.node,
393
+ messageId: 'deprecatedErrorUtil',
394
+ data: { name: usage.name },
395
+ });
396
+ }
397
+ },
274
398
  };
275
399
  },
276
400
  };
@@ -4,6 +4,10 @@
4
4
  * Warns when Platform.Load("Core", version) uses a version string other
5
5
  * than the recommended "1.1.5". Older versions like "1" or "1.1.1" miss
6
6
  * bug-fixes and features available in the latest Core library release.
7
+ *
8
+ * The autofix is withheld for files that use `ErrorUtil`, which only exists
9
+ * under Core "1" — bumping the version there would turn working code into a
10
+ * runtime TypeError. Such files must migrate off ErrorUtil first.
7
11
  */
8
12
 
9
13
  const DEFAULT_VERSION = '1.1.5';
@@ -36,8 +40,18 @@ export default {
36
40
  create(context) {
37
41
  const options = context.options[0] || {};
38
42
  const expectedVersion = options.version || DEFAULT_VERSION;
43
+ // Pending reports — resolved on Program:exit so the ErrorUtil scan is
44
+ // complete before deciding whether to attach a fixer.
45
+ const pendingReports = [];
46
+ let isUsesErrorUtility = false;
39
47
 
40
48
  return {
49
+ MemberExpression(node) {
50
+ if (node.object.type === 'Identifier' && node.object.name === 'ErrorUtil') {
51
+ isUsesErrorUtility = true;
52
+ }
53
+ },
54
+
41
55
  CallExpression(node) {
42
56
  const callee = node.callee;
43
57
  if (
@@ -61,13 +75,11 @@ export default {
61
75
  }
62
76
 
63
77
  if (arguments_.length < 2) {
64
- context.report({
78
+ pendingReports.push({
65
79
  node,
66
- messageId: 'outdatedVersion',
67
- data: { actual: '(none)', expected: expectedVersion },
68
- fix(fixer) {
69
- return fixer.insertTextAfter(arguments_[0], `, "${expectedVersion}"`);
70
- },
80
+ actual: '(none)',
81
+ fix: (fixer) =>
82
+ fixer.insertTextAfter(arguments_[0], `, "${expectedVersion}"`),
71
83
  });
72
84
  return;
73
85
  }
@@ -78,13 +90,23 @@ export default {
78
90
  typeof versionArgument.value === 'string' &&
79
91
  versionArgument.value !== expectedVersion
80
92
  ) {
81
- context.report({
93
+ pendingReports.push({
82
94
  node: versionArgument,
95
+ actual: versionArgument.value,
96
+ fix: (fixer) => fixer.replaceText(versionArgument, `"${expectedVersion}"`),
97
+ });
98
+ }
99
+ },
100
+
101
+ 'Program:exit'() {
102
+ for (const report of pendingReports) {
103
+ context.report({
104
+ node: report.node,
83
105
  messageId: 'outdatedVersion',
84
- data: { actual: versionArgument.value, expected: expectedVersion },
85
- fix(fixer) {
86
- return fixer.replaceText(versionArgument, `"${expectedVersion}"`);
87
- },
106
+ data: { actual: report.actual, expected: expectedVersion },
107
+ // Bumping the Core version would make ErrorUtil undefined at
108
+ // runtime, so the fix is withheld and only the report remains.
109
+ ...(!isUsesErrorUtility && { fix: report.fix }),
88
110
  });
89
111
  }
90
112
  },