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
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Unified ESLint plugin for **Salesforce Marketing Cloud** — linting rules for b
|
|
|
8
8
|
npm install eslint-plugin-sfmc --save-dev
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
Requires ESLint **10.
|
|
11
|
+
Requires ESLint **10.0.0+** (flat config) and Node.js **22+**. The ESLint minimum is a breaking requirement change; all 12 public configuration shapes remain unchanged (six objects and six multi-config arrays). Optional composition with `eslint-plugin-unicorn@76` requires ESLint **10.4.0+**, matching Unicorn 76's upstream peer range; the base SFMC plugin and its non-Unicorn configs remain supported from ESLint 10.0.0.
|
|
12
12
|
|
|
13
13
|
## Quick Start
|
|
14
14
|
|
|
@@ -61,13 +61,14 @@ Add the following to your `.vscode/settings.json`:
|
|
|
61
61
|
|
|
62
62
|
SFMC rule metadata links to the owning plugin version's documentation under `blob/v<package-version>/docs/rules/`. These links also work with custom plugin namespaces. Local development uses the package version deterministically; links for a prospective release may not resolve until that version and its documentation are tagged and published. ESLint parser failures (`ruleId: null`) have no rule metadata link. Core and third-party rules retain their own documentation metadata.
|
|
63
63
|
|
|
64
|
-
### 5.
|
|
64
|
+
### 5.2.0 release notes
|
|
65
65
|
|
|
66
|
-
-
|
|
67
|
-
- Added
|
|
68
|
-
-
|
|
66
|
+
- Added `sfmc/amp-prefer-boolean-literal` at `warn` severity in the recommended configs. It recognizes all eight accepted boolean-like forms and recommends bare `true` or `false`.
|
|
67
|
+
- Added safe autofixes and editor quick fixes for numeric and quoted boolean alternatives while leaving invalid values to `sfmc/amp-arg-types`.
|
|
68
|
+
- Updated `ampscript-data` to `^4.1.0` and `ssjs-data` to `^2.1.1`, including the complete boolean-like parameter metadata used by both AMPscript rules.
|
|
69
|
+
- No existing rule IDs, public configuration shapes, or supported inputs were removed or changed incompatibly.
|
|
69
70
|
|
|
70
|
-
Version **5.
|
|
71
|
+
Version **5.2.0** exports 53 SFMC rules. Every rule retains version-pinned documentation metadata, and release checks verify the tagged documentation and packed npm artifact.
|
|
71
72
|
|
|
72
73
|
## Configs
|
|
73
74
|
|
|
@@ -108,30 +109,31 @@ export default [...sfmc.configs['recommended-next'], ...sfmc.configs['embedded-n
|
|
|
108
109
|
|
|
109
110
|
## AMPscript Rules (`amp-*`)
|
|
110
111
|
|
|
111
|
-
| Rule | Default | Description
|
|
112
|
-
| ------------------------------------------------------------------------------------------- | ------------------------ |
|
|
113
|
-
| [`sfmc/amp-no-unknown-function`](docs/rules/amp/no-unknown-function.md) | `error` | Disallow calls to unknown AMPscript functions
|
|
114
|
-
| [`sfmc/amp-no-mcn-unsupported`](docs/rules/amp/no-mcn-unsupported.md) | off (`error` in `-next`) | Flag AMPscript functions unavailable in the targeted MCN API version (`apiVersion`)
|
|
115
|
-
| [`sfmc/amp-function-arity`](docs/rules/amp/function-arity.md) | `error` | Enforce correct argument counts
|
|
116
|
-
| [`sfmc/amp-arg-types`](docs/rules/amp/arg-types.md) | `error` | Check that literal arguments match expected parameter types and allowed values
|
|
117
|
-
| [`sfmc/amp-
|
|
118
|
-
| [`sfmc/amp-
|
|
119
|
-
| [`sfmc/amp-no-
|
|
120
|
-
| [`sfmc/amp-no-
|
|
121
|
-
| [`sfmc/amp-no-
|
|
122
|
-
| [`sfmc/amp-no-
|
|
123
|
-
| [`sfmc/amp-no-
|
|
124
|
-
| [`sfmc/amp-no-
|
|
125
|
-
| [`sfmc/amp-
|
|
126
|
-
| [`sfmc/amp-
|
|
127
|
-
| [`sfmc/amp-
|
|
128
|
-
| [`sfmc/amp-
|
|
129
|
-
| [`sfmc/amp-no-
|
|
130
|
-
| [`sfmc/amp-no-
|
|
131
|
-
| [`sfmc/amp-no-nested-
|
|
132
|
-
| [`sfmc/amp-
|
|
133
|
-
| [`sfmc/amp-
|
|
134
|
-
| [`sfmc/amp-
|
|
112
|
+
| Rule | Default | Description |
|
|
113
|
+
| ------------------------------------------------------------------------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
114
|
+
| [`sfmc/amp-no-unknown-function`](docs/rules/amp/no-unknown-function.md) | `error` | Disallow calls to unknown AMPscript functions |
|
|
115
|
+
| [`sfmc/amp-no-mcn-unsupported`](docs/rules/amp/no-mcn-unsupported.md) | off (`error` in `-next`) | Flag AMPscript functions unavailable in the targeted MCN API version (`apiVersion`) |
|
|
116
|
+
| [`sfmc/amp-function-arity`](docs/rules/amp/function-arity.md) | `error` | Enforce correct argument counts |
|
|
117
|
+
| [`sfmc/amp-arg-types`](docs/rules/amp/arg-types.md) | `error` | Check that literal arguments match expected parameter types and allowed values |
|
|
118
|
+
| [`sfmc/amp-prefer-boolean-literal`](docs/rules/amp/prefer-boolean-literal.md) | `warn` | All catalogued boolean-like parameters accept exactly eight forms: bare `true`/`false`, numeric `1`/`0`, or quoted `"true"`/`"false"`/`"1"`/`"0"` (either quote style; words case-insensitive); recommends and auto-fixes to bare booleans |
|
|
119
|
+
| [`sfmc/amp-set-requires-target`](docs/rules/amp/set-requires-target.md) | `error` | Require `set` to have a target variable |
|
|
120
|
+
| [`sfmc/amp-no-smart-quotes`](docs/rules/amp/no-smart-quotes.md) | `error` | Disallow smart/curly quotes in strings |
|
|
121
|
+
| [`sfmc/amp-no-var-redeclaration`](docs/rules/amp/no-var-redeclaration.md) | `warn` | Disallow re-declaring a variable with `var` |
|
|
122
|
+
| [`sfmc/amp-no-empty-block`](docs/rules/amp/no-empty-block.md) | `warn` | Disallow empty `%%[ ]%%` blocks |
|
|
123
|
+
| [`sfmc/amp-no-loop-counter-assign`](docs/rules/amp/no-loop-counter-assign.md) | `warn` | Disallow assigning to the `for` loop counter |
|
|
124
|
+
| [`sfmc/amp-no-inline-statement`](docs/rules/amp/no-inline-statement.md) | `warn` | Disallow statements inside inline expressions |
|
|
125
|
+
| [`sfmc/amp-no-deprecated-function`](docs/rules/amp/no-deprecated-function.md) | `warn` | Flag deprecated functions and suggest replacements |
|
|
126
|
+
| [`sfmc/amp-no-nonfunctional-function`](docs/rules/amp/no-nonfunctional-function.md) | `error` | Flag functions that resolve but have no working runtime invocation |
|
|
127
|
+
| [`sfmc/amp-naming-convention`](docs/rules/amp/naming-convention.md) | `warn` | Enforce variable naming convention |
|
|
128
|
+
| [`sfmc/amp-no-empty-then`](docs/rules/amp/no-empty-then.md) | `warn` | Disallow IF with empty THEN branch |
|
|
129
|
+
| [`sfmc/amp-require-rowcount-check`](docs/rules/amp/require-rowcount-check.md) | `warn` | Require RowCount check before FOR on LookupRows |
|
|
130
|
+
| [`sfmc/amp-no-html-comment`](docs/rules/amp/no-html-comment.md) | `warn` | Disallow HTML comments inside AMPscript blocks |
|
|
131
|
+
| [`sfmc/amp-no-js-line-comment`](docs/rules/amp/no-js-line-comment.md) | `warn` | Disallow JS-style `//` line comments in AMPscript |
|
|
132
|
+
| [`sfmc/amp-no-nested-script-tag`](docs/rules/amp/no-nested-script-tag.md) | `error` | Disallow `<script>` tags nested inside AMPscript script tags |
|
|
133
|
+
| [`sfmc/amp-no-nested-ampscript-delimiter`](docs/rules/amp/no-nested-ampscript-delimiter.md) | `error` | Disallow AMPscript delimiters nested inside AMPscript blocks |
|
|
134
|
+
| [`sfmc/amp-prefer-attribute-value`](docs/rules/amp/prefer-attribute-value.md) | off | Prefer `AttributeValue()` over bare personalization |
|
|
135
|
+
| [`sfmc/amp-require-variable-declaration`](docs/rules/amp/require-variable-declaration.md) | off | Require `var` before `set` |
|
|
136
|
+
| [`sfmc/amp-no-email-excluded-function`](docs/rules/amp/no-email-excluded-function.md) | off | Flag functions unavailable in email context |
|
|
135
137
|
|
|
136
138
|
## SSJS Rules (`ssjs-*`)
|
|
137
139
|
|
|
@@ -199,9 +201,9 @@ Severities above are the same in `embedded`, `strict`, `embedded-next`, and `str
|
|
|
199
201
|
|
|
200
202
|
[`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`, `Math.trunc`, spread `...`, ES modules, `async`/`await`, …). CloudPage probes found zero-argument string `slice()` throwing after a working `"Hello".substring()` call. Native `Object.fromEntries`, `toReversed`, `toSorted`, `toSpliced`, `replaceAll`, `matchAll` and `structuredClone` were unavailable: `typeof` returned `undefined` and direct calls threw, both without Core and with Core 1.1.1 or 1.1.5.
|
|
201
203
|
|
|
202
|
-
For Unicorn **
|
|
204
|
+
For Unicorn **76.0.0**, the SSJS compatibility overrides disable **60** of its **315** enabled recommended rules: API/syntax incompatibilities, recorded runtime-semantic hazards, and diagnostic-only pressure toward unsafe changes. Some paths are conditionally inert under strict ES5 parsing. The other **255** remain active; this classification is not a blanket runtime-safety guarantee or new live SFMC verification.
|
|
203
205
|
|
|
204
|
-
**Unicorn is optional; the
|
|
206
|
+
**Unicorn is optional; Unicorn 76 composition is upstream-supported on ESLint 10.4.0+, while the base SFMC plugin supports ESLint 10.0.0+.** The higher integration floor comes from `eslint-plugin-unicorn@76`'s declared ESLint peer range and does not raise `eslint-plugin-sfmc`'s package-wide peer minimum. When you enable Unicorn, the matching SSJS protections are required. Include `unicorn-ssjs` when Unicorn covers standalone SSJS and `unicorn-ssjs-embedded` when it covers embedded SSJS. The example below covers both scopes, so both overrides are required. `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. Insert each sfmc override **object** directly **after** it; only the `recommended` and `embedded` arrays are spread:
|
|
205
207
|
|
|
206
208
|
```js
|
|
207
209
|
import sfmc from 'eslint-plugin-sfmc';
|
|
@@ -215,19 +217,19 @@ export default [
|
|
|
215
217
|
},
|
|
216
218
|
...sfmc.configs.recommended,
|
|
217
219
|
...sfmc.configs.embedded, // AMPscript + SSJS embedded in HTML (<script runat="server">)
|
|
218
|
-
sfmc.configs['unicorn-ssjs'], // REQUIRED: protect standalone SSJS from the
|
|
220
|
+
sfmc.configs['unicorn-ssjs'], // REQUIRED: protect standalone SSJS from the 60 incompatible rules
|
|
219
221
|
sfmc.configs['unicorn-ssjs-embedded'], // REQUIRED: protect SSJS embedded in HTML
|
|
220
222
|
];
|
|
221
223
|
```
|
|
222
224
|
|
|
223
225
|
| Config | Files | What it does |
|
|
224
226
|
| --------------------------------------- | ---------------- | --------------------------------------------------------- |
|
|
225
|
-
| `sfmc.configs['unicorn-ssjs']` | `**/*.ssjs` | Turns off the
|
|
226
|
-
| `sfmc.configs['unicorn-ssjs-embedded']` | `**/*.html/*.js` | Same
|
|
227
|
+
| `sfmc.configs['unicorn-ssjs']` | `**/*.ssjs` | Turns off the 60 SFMC-incompatible unicorn rules for SSJS |
|
|
228
|
+
| `sfmc.configs['unicorn-ssjs-embedded']` | `**/*.html/*.js` | Same 60-rule override for SSJS embedded in HTML |
|
|
227
229
|
|
|
228
230
|
Scope the complete Unicorn preset to JavaScript/SSJS, not custom AMPscript, Handlebars or MSO ASTs. Clearing its builtin map prevents modern globals leaking into SSJS; other matching configs can still supply globals. The SFMC presets do not enable general `no-undef` checking, and extracted HTML server blocks are linted independently.
|
|
229
231
|
|
|
230
|
-
Only **
|
|
232
|
+
Only **60** of unicorn's 315 enabled recommended rules are overridden — the other **255** 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 v76.0.0), see [docs/unicorn-compatibility.md](docs/unicorn-compatibility.md).
|
|
231
233
|
|
|
232
234
|
## Processors
|
|
233
235
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
Some AMPscript function parameters only accept a fixed set of keyword values. For example, the second argument of `DatePart` must be one of `year`, `Y`, `month`, `M`, `monthName`, `day`, `D`, `hour`, `H`, `minute`, or `MI`. Passing any other value is a bug that surfaces only at send/render time.
|
|
14
14
|
|
|
15
|
-
The Salesforce catalog records these allowed values as an `enum` on the parameter. This rule checks every static literal argument — strings, numbers, and booleans — against the parameter's `enum`
|
|
15
|
+
The Salesforce catalog records these allowed values as an `enum` on the parameter. This rule checks every static literal argument — strings, numbers, and booleans — against the parameter's `enum` and reports a mismatch. Literal primitive types remain distinct: `1` does not match `"1"`, and `true` does not match `"true"` unless both forms are explicitly present in the enum. String-to-string comparisons are case-insensitive. Variables and expressions are skipped because their value cannot be determined statically.
|
|
16
16
|
|
|
17
17
|
This rule is the AMPscript counterpart of [`sfmc/ssjs-arg-types`](../ssjs/arg-types.md) and may be expanded later to cover additional argument-type checks.
|
|
18
18
|
|
|
@@ -35,6 +35,10 @@ This rule has no configuration options.
|
|
|
35
35
|
|
|
36
36
|
/* a number is not a valid datePart either */
|
|
37
37
|
set @y = DatePart('2026-01-15', 5)
|
|
38
|
+
|
|
39
|
+
/* unsupported boolean-like values are rejected */
|
|
40
|
+
RaiseError('stop', false, '', 0, 2)
|
|
41
|
+
RaiseError('stop', false, '', 0, 'yes')
|
|
38
42
|
]%%
|
|
39
43
|
```
|
|
40
44
|
|
|
@@ -45,9 +49,16 @@ This rule has no configuration options.
|
|
|
45
49
|
/* exact-case enum value */
|
|
46
50
|
set @x = DatePart('2026-01-15', 'Y')
|
|
47
51
|
|
|
48
|
-
/* case-insensitive match */
|
|
52
|
+
/* case-insensitive string match */
|
|
49
53
|
set @y = DatePart('2026-01-15', 'year')
|
|
50
54
|
|
|
55
|
+
/* mixed enums can explicitly allow several primitive forms */
|
|
56
|
+
RaiseError('stop', false, '', 0, true)
|
|
57
|
+
RaiseError('stop', false, '', 0, 1)
|
|
58
|
+
RaiseError('stop', false, '', 0, 'TRUE')
|
|
59
|
+
RaiseError('stop', false, '', 0, '1')
|
|
60
|
+
RaiseError('stop', false, '', 0, '0')
|
|
61
|
+
|
|
51
62
|
/* variable argument — not statically checkable, skipped */
|
|
52
63
|
set @z = DatePart(@d, @part)
|
|
53
64
|
]%%
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# `sfmc/amp-prefer-boolean-literal`
|
|
2
|
+
|
|
3
|
+
> Recommend bare boolean literals for AMPscript parameters that also accept numeric or quoted alternatives.
|
|
4
|
+
|
|
5
|
+
| | |
|
|
6
|
+
|---|---|
|
|
7
|
+
| **Type** | `suggestion` |
|
|
8
|
+
| **Default severity** | `warn` in `recommended` and `strict` |
|
|
9
|
+
| **Fixable** | Yes — `eslint --fix` or editor quick fix |
|
|
10
|
+
|
|
11
|
+
## Why This Rule Exists
|
|
12
|
+
|
|
13
|
+
All catalogued boolean-like AMPscript parameters accept the same eight values: bare `true` and `false`; numeric `1` and `0`; and quoted `'true'`, `'false'`, `'1'`, and `'0'` (with either quote style and case-insensitive word matching). All eight are valid, so `sfmc/amp-arg-types` accepts them. This separate style rule recommends the clearer bare `true` or `false` form without describing the alternatives as invalid syntax.
|
|
14
|
+
|
|
15
|
+
The rule derives its scope from `ampscript-data` metadata and checks every catalogued boolean-like parameter. Each discouraged static alternative is safely auto-fixed by replacing only that argument with bare `true` or `false`; surrounding code and formatting remain unchanged. Apply fixes with `eslint --fix` or an editor's ESLint quick fix.
|
|
16
|
+
|
|
17
|
+
## Settings
|
|
18
|
+
|
|
19
|
+
| Setting | Values | Default |
|
|
20
|
+
|---------|--------|---------|
|
|
21
|
+
| severity | `"error"` \| `"warn"` \| `"off"` | `"warn"` |
|
|
22
|
+
|
|
23
|
+
This rule has no configuration options.
|
|
24
|
+
|
|
25
|
+
### Recommended
|
|
26
|
+
|
|
27
|
+
```ampscript
|
|
28
|
+
%%[
|
|
29
|
+
RaiseError('stop', false, '', 0, true)
|
|
30
|
+
RaiseError('stop', false, '', 0, false)
|
|
31
|
+
]%%
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Produces a recommendation warning
|
|
35
|
+
|
|
36
|
+
```ampscript
|
|
37
|
+
%%[
|
|
38
|
+
RaiseError('stop', false, '', 0, 1)
|
|
39
|
+
RaiseError('stop', false, '', 0, 'FALSE')
|
|
40
|
+
]%%
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Invalid values such as `2` or `'yes'` are not reported by this rule. They remain errors from `sfmc/amp-arg-types`.
|
|
44
|
+
|
|
45
|
+
## When to Disable
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
// eslint.config.js
|
|
49
|
+
rules: { 'sfmc/amp-prefer-boolean-literal': 'off' }
|
|
50
|
+
```
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
# `eslint-plugin-unicorn` compatibility with SFMC SSJS
|
|
2
2
|
|
|
3
|
-
> **Compatibility analysis for [`eslint-plugin-unicorn@
|
|
3
|
+
> **Compatibility analysis for [`eslint-plugin-unicorn@76.0.0`](https://github.com/sindresorhus/eslint-plugin-unicorn).**
|
|
4
4
|
>
|
|
5
|
-
> ⚠️ **Version warning:** This classification was done against `eslint-plugin-unicorn` **
|
|
5
|
+
> ⚠️ **Version warning:** This classification was done against `eslint-plugin-unicorn` **v76.0.0** (315 enabled 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`, `Math.trunc`, spread `...`, ES modules, `async`/`await`, …). CloudPage probes also found native `Object.fromEntries`, `matchAll` and `structuredClone` unavailable, both without Core and with Core 1.1.1 or 1.1.5. 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 **
|
|
12
|
+
Of unicorn's **315** enabled recommended rules (v76.0.0), **255** remain active (including conditional and inert cases; not a blanket runtime-safety guarantee) and **60** should be turned off. `eslint-plugin-sfmc` ships a scope-specific override config (`unicorn-ssjs` / `unicorn-ssjs-embedded`) that turns off exactly those 60 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
|
|
|
16
16
|
## Section 1 — How to apply
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
The base `eslint-plugin-sfmc` package requires ESLint **10.0.0+** and Node.js **22+**. Optional composition with `eslint-plugin-unicorn@76` is upstream-supported only on ESLint **10.4.0+**, because Unicorn 76 declares that ESLint peer range. This integration floor does not raise the package-wide SFMC peer minimum: consumers that do not compose Unicorn remain supported from ESLint 10.0.0.
|
|
19
19
|
|
|
20
20
|
Unicorn itself is **optional**. When you enable it for standalone SSJS, `unicorn-ssjs` is **required**; when you enable it for embedded SSJS, `unicorn-ssjs-embedded` is **required**. The example below covers both scopes, so it requires both overrides. `eslint-plugin-sfmc` never loads unicorn; the override is a plain rules object that only resolves when you have loaded your own unicorn config **earlier** in the flat-config array (that config registers the `unicorn` plugin). Insert each sfmc override **object** directly **after** it; only the `recommended` and `embedded` arrays are spread:
|
|
21
21
|
|
|
@@ -31,7 +31,7 @@ export default [
|
|
|
31
31
|
},
|
|
32
32
|
...sfmc.configs.recommended,
|
|
33
33
|
...sfmc.configs.embedded, // AMPscript + SSJS embedded in HTML (<script runat="server">)
|
|
34
|
-
sfmc.configs['unicorn-ssjs'], // REQUIRED: protect standalone SSJS from the
|
|
34
|
+
sfmc.configs['unicorn-ssjs'], // REQUIRED: protect standalone SSJS from the 60 incompatible rules
|
|
35
35
|
sfmc.configs['unicorn-ssjs-embedded'], // REQUIRED: protect SSJS embedded in HTML
|
|
36
36
|
];
|
|
37
37
|
```
|
|
@@ -47,7 +47,7 @@ If you don't use unicorn, omit these configs entirely — nothing else in `eslin
|
|
|
47
47
|
|
|
48
48
|
All 12 public shapes remain unchanged: six objects (`ampscript`, `ssjs`, `ampscript-next`, `ssjs-next`, `unicorn-ssjs`, `unicorn-ssjs-embedded`) and six arrays (`recommended`, `embedded`, `strict`, `recommended-next`, `embedded-next`, `strict-next`). Raw arrays require spreading the multi-config presets as above, not the single override objects.
|
|
49
49
|
|
|
50
|
-
Alternatively, ESLint's `defineConfig` flattens nested configuration arrays.
|
|
50
|
+
Alternatively, ESLint's `defineConfig` flattens nested configuration arrays. The base SFMC presets are verified at exactly ESLint **10.0.0** and at **10.11.0**. The Unicorn composition shown here is tested only on an engine satisfying Unicorn 76's upstream floor (**10.4.0+**); it is not presented as supported on ESLint 10.0–10.3:
|
|
51
51
|
|
|
52
52
|
```js
|
|
53
53
|
import { defineConfig } from 'eslint/config';
|
|
@@ -69,11 +69,11 @@ export default defineConfig(
|
|
|
69
69
|
|
|
70
70
|
---
|
|
71
71
|
|
|
72
|
-
## Section 2 — Rules to override for SSJS (
|
|
72
|
+
## Section 2 — Rules to override for SSJS (60)
|
|
73
73
|
|
|
74
|
-
These
|
|
74
|
+
These 60 recommended rules introduce unavailable or unresolved APIs, conflict with recorded runtime semantics, pressure users toward unsafe changes through diagnostics, or introduce unsupported syntax. Some paths are conditionally inert under strict ES5 parsing. The override config sets each to `'off'` for SSJS. All 60 are confirmed enabled in unicorn v76.0.0's recommended configuration.
|
|
75
75
|
|
|
76
|
-
### Group A — API, runtime-semantic and diagnostic protections (
|
|
76
|
+
### Group A — API, runtime-semantic and diagnostic protections (52)
|
|
77
77
|
|
|
78
78
|
| Rule | Why it breaks SSJS | SFMC evidence |
|
|
79
79
|
|---|---|---|
|
|
@@ -117,10 +117,12 @@ These 58 recommended rules introduce unavailable or unresolved APIs, conflict wi
|
|
|
117
117
|
| [`prefer-map-from-entries`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-map-from-entries.md) | Pushes unsupported `Map`; native `Object.fromEntries` is also unavailable in CloudPage probes | [Engine limitations](https://ssjs.guide/engine-limitations/) |
|
|
118
118
|
| [`prefer-group-by`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-group-by.md) | Pushes `Object.groupBy` without established target-runtime support; conservative output protection, with `Map.groupBy` independently requiring unsupported `Map` | [ECMAScript built-ins](https://ssjs.guide/ecmascript-builtins/) |
|
|
119
119
|
| [`prefer-iterator-helpers`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-iterator-helpers.md) | Pushes the iterator-helper protocol — unsupported | [Engine limitations](https://ssjs.guide/engine-limitations/) |
|
|
120
|
+
| [`prefer-iterator-zip`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-iterator-zip.md) | Suggests `Iterator.zip()` and `for...of` for parallel-array loops; both the Iterator helper and ES6 loop syntax are unavailable | [Engine limitations](https://ssjs.guide/engine-limitations/) |
|
|
121
|
+
| [`prefer-temporal-conversion`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-temporal-conversion.md) | Rewrites `Temporal` conversions to direct methods, but the Temporal API is unavailable in the SSJS runtime | [Engine limitations](https://ssjs.guide/engine-limitations/) |
|
|
120
122
|
| [`prefer-structured-clone`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-structured-clone.md) | Pushes native `structuredClone`, unavailable in CloudPage probes: `typeof` was `undefined` and direct calls threw without Core and with Core 1.1.1 or 1.1.5 | [ECMAScript built-ins](https://ssjs.guide/ecmascript-builtins/) |
|
|
121
123
|
| [`prefer-includes-over-repeated-comparisons`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-includes-over-repeated-comparisons.md) | Diagnostic-only pressure toward unavailable `.includes()`; no fix or editor suggestion | [ECMAScript built-ins](https://ssjs.guide/ecmascript-builtins/) |
|
|
122
124
|
| [`prefer-object-define-properties`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-object-define-properties.md) | Autofix combines singular calls into unavailable plural `Object.defineProperties`; singular support does not establish plural support or descriptor equivalence | [ECMAScript built-ins](https://ssjs.guide/ecmascript-builtins/) |
|
|
123
|
-
| [`no-new-array`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-new-array.md) | Autofix emits `Array.from`;
|
|
125
|
+
| [`no-new-array`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-new-array.md) | Autofix emits `Array.from`; v76 string-method inference newly reaches `new Array("abc".indexOf(value))` with an unknown parameter | [ECMAScript built-ins](https://ssjs.guide/ecmascript-builtins/) |
|
|
124
126
|
| [`no-unnecessary-array-splice-count`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unnecessary-array-splice-count.md) | Autofix omits `deleteCount`; recorded native one-argument SSJS `splice` throws | [ECMAScript built-ins](https://ssjs.guide/ecmascript-builtins/) |
|
|
125
127
|
| [`prefer-regexp-test`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-regexp-test.md) | Recorded no-match `match()` returns truthy `[]`, and missed `search()` returns `0`; conversion to `.test()` changes truthiness and affected inequality predicates | [ECMAScript built-ins](https://ssjs.guide/ecmascript-builtins/) |
|
|
126
128
|
| [`no-unnecessary-splice`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unnecessary-splice.md) | One-argument splice throws, unlike `.length = 0`; replacement branches also change recorded insertion/overwrite semantics. The used-return `shift()` branch is diagnostic-only, not an autofix | [ECMAScript built-ins](https://ssjs.guide/ecmascript-builtins/) |
|
|
@@ -132,7 +134,7 @@ These 58 recommended rules introduce unavailable or unresolved APIs, conflict wi
|
|
|
132
134
|
|
|
133
135
|
| Rule | Why it breaks SSJS | SFMC evidence |
|
|
134
136
|
|---|---|---|
|
|
135
|
-
| [`no-for-loop`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-for-loop.md) | Autofix introduces `for...of` and `const`. The
|
|
137
|
+
| [`no-for-loop`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-for-loop.md) | Autofix introduces `for...of` and `const`. The v76 visitor is inert under strict ES5 parsing because it needs block scopes; the same ES5 source becomes reachable with ES2015 parsing | [Engine limitations](https://ssjs.guide/engine-limitations/) |
|
|
136
138
|
| [`prefer-default-parameters`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-default-parameters.md) | Editor suggestion replaces parameter reassignment with ES6 default-parameter syntax; reachable under ES5 input parsing | [Engine limitations](https://ssjs.guide/engine-limitations/) |
|
|
137
139
|
| [`require-array-sort-compare`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/require-array-sort-compare.md) | Both numeric and string comparator suggestions introduce arrow functions even under ES5 parsing | [Engine limitations](https://ssjs.guide/engine-limitations/) |
|
|
138
140
|
| [`prefer-optional-catch-binding`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-optional-catch-binding.md) | Pushes `catch {}` (ES2019) — may not parse on ES3 | [Engine limitations](https://ssjs.guide/engine-limitations/) |
|
|
@@ -145,11 +147,11 @@ These 58 recommended rules introduce unavailable or unresolved APIs, conflict wi
|
|
|
145
147
|
|
|
146
148
|
---
|
|
147
149
|
|
|
148
|
-
## Section 3 — Active rules, including conditional cases (
|
|
150
|
+
## Section 3 — Active rules, including conditional cases (255)
|
|
149
151
|
|
|
150
152
|
These recommended rules are **not** disabled by the override config. Active is a policy classification, not proof that every transformation is safe in SFMC. Modern-syntax-gated paths may be inert under strict ES5 parsing; DOM, Node.js, TypeScript and custom/polyfilled-object paths require their own environment contracts. Each links to its official Unicorn documentation. See the evidence qualifications below before accepting generated changes.
|
|
151
153
|
|
|
152
|
-
<!-- BEGIN
|
|
154
|
+
<!-- BEGIN 255-OK-LIST -->
|
|
153
155
|
- [better-dom-traversing](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/better-dom-traversing.md)
|
|
154
156
|
- [catch-error-name](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/catch-error-name.md)
|
|
155
157
|
- [class-reference-in-static-methods](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/class-reference-in-static-methods.md)
|
|
@@ -193,6 +195,7 @@ These recommended rules are **not** disabled by the override config. Active is a
|
|
|
193
195
|
- [no-array-method-this-argument](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-method-this-argument.md)
|
|
194
196
|
- [no-array-reduce](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-reduce.md)
|
|
195
197
|
- [no-array-sort-for-min-max](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-sort-for-min-max.md)
|
|
198
|
+
- [no-async-iterator-callback](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-async-iterator-callback.md)
|
|
196
199
|
- [no-async-promise-finally](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-async-promise-finally.md)
|
|
197
200
|
- [no-await-expression-member](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-await-expression-member.md)
|
|
198
201
|
- [no-await-in-promise-methods](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-await-in-promise-methods.md)
|
|
@@ -277,12 +280,14 @@ These recommended rules are **not** disabled by the override config. Active is a
|
|
|
277
280
|
- [no-unreadable-for-of-expression](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unreadable-for-of-expression.md)
|
|
278
281
|
- [no-unreadable-iife](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unreadable-iife.md)
|
|
279
282
|
- [no-unreadable-object-destructuring](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unreadable-object-destructuring.md)
|
|
283
|
+
- [no-using-resource-escape](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-using-resource-escape.md)
|
|
280
284
|
- [no-unsafe-buffer-conversion](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unsafe-buffer-conversion.md)
|
|
281
285
|
- [no-unsafe-promise-all-settled-values](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unsafe-promise-all-settled-values.md)
|
|
282
286
|
- [no-unsafe-property-key](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unsafe-property-key.md)
|
|
283
287
|
- [no-unsafe-sqlite-interpolation](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unsafe-sqlite-interpolation.md)
|
|
284
288
|
- [no-unsafe-string-replacement](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unsafe-string-replacement.md)
|
|
285
|
-
- [no-unused-
|
|
289
|
+
- [no-unused-builtin-method-return](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unused-builtin-method-return.md)
|
|
290
|
+
- [no-unused-iterator-helper](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unused-iterator-helper.md)
|
|
286
291
|
- [no-useless-boolean-cast](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-boolean-cast.md)
|
|
287
292
|
- [no-useless-collection-argument](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-collection-argument.md)
|
|
288
293
|
- [no-useless-compound-assignment](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-compound-assignment.md)
|
|
@@ -300,6 +305,7 @@ These recommended rules are **not** disabled by the override config. Active is a
|
|
|
300
305
|
- [no-useless-re-export](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-re-export.md)
|
|
301
306
|
- [no-useless-recursion](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-recursion.md)
|
|
302
307
|
- [no-useless-spread](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-spread.md)
|
|
308
|
+
- [no-useless-set-construction](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-set-construction.md)
|
|
303
309
|
- [no-useless-switch-case](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-switch-case.md)
|
|
304
310
|
- [no-useless-template-literals](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-template-literals.md)
|
|
305
311
|
- [no-useless-undefined](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-undefined.md)
|
|
@@ -324,6 +330,7 @@ These recommended rules are **not** disabled by the override config. Active is a
|
|
|
324
330
|
- [prefer-boolean-return](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-boolean-return.md)
|
|
325
331
|
- [prefer-class-fields](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-class-fields.md)
|
|
326
332
|
- [prefer-classlist-toggle](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-classlist-toggle.md)
|
|
333
|
+
- [prefer-combined-guards](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-combined-guards.md)
|
|
327
334
|
- [prefer-continue](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-continue.md)
|
|
328
335
|
- [prefer-direct-iteration](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-direct-iteration.md)
|
|
329
336
|
- [prefer-dom-node-append](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-dom-node-append.md)
|
|
@@ -400,7 +407,7 @@ These recommended rules are **not** disabled by the override config. Active is a
|
|
|
400
407
|
- [text-encoding-identifier-case](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/text-encoding-identifier-case.md)
|
|
401
408
|
- [throw-new-error](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/throw-new-error.md)
|
|
402
409
|
- [require-array-join-separator](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/require-array-join-separator.md)
|
|
403
|
-
<!-- END
|
|
410
|
+
<!-- END 255-OK-LIST -->
|
|
404
411
|
|
|
405
412
|
**Reactivated, with bounded evidence:** `require-array-join-separator` adds an explicit comma separator, which recorded SSJS supports. `prefer-global-number-constants` replaces Number properties with globals: positive-infinity and NaN fixes have focused coverage, including shadowing guards. Its negative-infinity property branch is diagnostic-only; recorded sign differences mean accepting that diagnostic remains conditional, not a blanket constant-equivalence clearance.
|
|
406
413
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-sfmc",
|
|
3
|
-
"version": "5.1
|
|
3
|
+
"version": "5.2.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",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
"mcn"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"ampscript-data": "^4.
|
|
39
|
+
"ampscript-data": "^4.1.0",
|
|
40
40
|
"ampscript-parser": "^0.3.1",
|
|
41
41
|
"eslint-plugin-mso-email": "^2.0.0",
|
|
42
42
|
"handlebars-data": "^0.4.0",
|
|
43
43
|
"mso-conditional-parser": "^2.0.1",
|
|
44
44
|
"sfmc-handlebars-parser": "^0.1.1",
|
|
45
|
-
"ssjs-data": "^2.1.
|
|
45
|
+
"ssjs-data": "^2.1.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"eslint": ">=10.
|
|
48
|
+
"eslint": ">=10.0.0"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"test": "node --test tests/release-safeguards.test.js tests/metadata.test.js && 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 && node --test tests/unicorn-protection.test.js tests/unicorn-hazards.test.js tests/unicorn-configs.test.js && node --test tests/unicorn-minimum.test.js",
|
|
@@ -66,16 +66,16 @@
|
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@eslint/js": "^10.0.1",
|
|
69
|
-
"eslint": "^10.
|
|
69
|
+
"eslint": "^10.11.0",
|
|
70
70
|
"eslint-config-prettier": "^10.1.8",
|
|
71
|
-
"eslint-minimum": "npm:eslint@10.
|
|
72
|
-
"eslint-plugin-jsdoc": "^
|
|
71
|
+
"eslint-minimum": "npm:eslint@10.0.0",
|
|
72
|
+
"eslint-plugin-jsdoc": "^64.5.4",
|
|
73
73
|
"eslint-plugin-prettier": "^5.5.6",
|
|
74
|
-
"eslint-plugin-unicorn": "^
|
|
75
|
-
"globals": "^17.
|
|
74
|
+
"eslint-plugin-unicorn": "^76.0.0",
|
|
75
|
+
"globals": "^17.12.0",
|
|
76
76
|
"husky": "^9.1.7",
|
|
77
|
-
"lint-staged": "^17.
|
|
78
|
-
"prettier": "^3.9.
|
|
77
|
+
"lint-staged": "^17.5.1",
|
|
78
|
+
"prettier": "^3.9.9"
|
|
79
79
|
},
|
|
80
80
|
"lint-staged": {
|
|
81
81
|
"*.{js,mjs,cjs}": [
|
|
@@ -130,11 +130,7 @@ export function preprocess(text, filename) {
|
|
|
130
130
|
index++;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
return [text];
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return blocks;
|
|
133
|
+
return blocks.length === 0 ? [text] : blocks;
|
|
138
134
|
}
|
|
139
135
|
|
|
140
136
|
export function postprocess(messages) {
|
package/src/index.js
CHANGED
|
@@ -27,6 +27,7 @@ import ampNoInlineStatement from './rules/amp/no-inline-statement.js';
|
|
|
27
27
|
import ampRequireVariableDeclaration from './rules/amp/require-variable-declaration.js';
|
|
28
28
|
import ampFunctionArity from './rules/amp/function-arity.js';
|
|
29
29
|
import ampArgumentTypes from './rules/amp/argument-types.js';
|
|
30
|
+
import ampPreferBooleanLiteral from './rules/amp/prefer-boolean-literal.js';
|
|
30
31
|
import ampNoEmailExcludedFunction from './rules/amp/no-email-excluded-function.js';
|
|
31
32
|
import ampNoDeprecatedFunction from './rules/amp/no-deprecated-function.js';
|
|
32
33
|
import ampNoNonfunctionalFunction from './rules/amp/no-nonfunctional-function.js';
|
|
@@ -117,6 +118,7 @@ const plugin = {
|
|
|
117
118
|
'amp-require-variable-declaration': ampRequireVariableDeclaration,
|
|
118
119
|
'amp-function-arity': ampFunctionArity,
|
|
119
120
|
'amp-arg-types': ampArgumentTypes,
|
|
121
|
+
'amp-prefer-boolean-literal': ampPreferBooleanLiteral,
|
|
120
122
|
'amp-no-email-excluded-function': ampNoEmailExcludedFunction,
|
|
121
123
|
'amp-no-deprecated-function': ampNoDeprecatedFunction,
|
|
122
124
|
'amp-no-nonfunctional-function': ampNoNonfunctionalFunction,
|
|
@@ -234,6 +236,7 @@ const ampRecommendedRules = {
|
|
|
234
236
|
'sfmc/amp-no-inline-statement': 'warn',
|
|
235
237
|
'sfmc/amp-function-arity': 'error',
|
|
236
238
|
'sfmc/amp-arg-types': 'error',
|
|
239
|
+
'sfmc/amp-prefer-boolean-literal': 'warn',
|
|
237
240
|
'sfmc/amp-no-deprecated-function': 'warn',
|
|
238
241
|
'sfmc/amp-no-nonfunctional-function': 'error',
|
|
239
242
|
'sfmc/amp-naming-convention': 'warn',
|
|
@@ -257,6 +260,7 @@ const ampStrictRules = {
|
|
|
257
260
|
'sfmc/amp-require-variable-declaration': 'warn',
|
|
258
261
|
'sfmc/amp-function-arity': 'error',
|
|
259
262
|
'sfmc/amp-arg-types': 'error',
|
|
263
|
+
'sfmc/amp-prefer-boolean-literal': 'warn',
|
|
260
264
|
'sfmc/amp-no-email-excluded-function': 'off',
|
|
261
265
|
'sfmc/amp-no-deprecated-function': 'warn',
|
|
262
266
|
'sfmc/amp-no-nonfunctional-function': 'error',
|
|
@@ -386,8 +390,8 @@ function standaloneHandlebarsConfigs(configName) {
|
|
|
386
390
|
// ── Optional eslint-plugin-unicorn override for SSJS ──────────────────────────
|
|
387
391
|
|
|
388
392
|
/**
|
|
389
|
-
* The
|
|
390
|
-
* unicorn
|
|
393
|
+
* The 60 `eslint-plugin-unicorn` recommended rules (analysed against
|
|
394
|
+
* unicorn v76.0.0) that are incompatible with the SFMC SSJS (JINT / ES3-ES5)
|
|
391
395
|
* engine — they either fix/suggest code using a missing built-in or forbid a required
|
|
392
396
|
* SFMC workaround, or enforce ES-module / async / ES6-only syntax that the
|
|
393
397
|
* engine cannot run. Each is mapped to `'off'`.
|
|
@@ -450,6 +454,10 @@ const unicornSsjsOffRules = {
|
|
|
450
454
|
'unicorn/prefer-map-from-entries': 'off',
|
|
451
455
|
'unicorn/prefer-group-by': 'off',
|
|
452
456
|
'unicorn/prefer-iterator-helpers': 'off',
|
|
457
|
+
// Unicorn 76 suggestions introduce Iterator.zip(), unavailable in SFMC SSJS.
|
|
458
|
+
'unicorn/prefer-iterator-zip': 'off',
|
|
459
|
+
// Temporal is unavailable, so direct Temporal conversion methods are unsafe.
|
|
460
|
+
'unicorn/prefer-temporal-conversion': 'off',
|
|
453
461
|
'unicorn/prefer-structured-clone': 'off',
|
|
454
462
|
// Native match/search miss results and splice behavior are not standard JS.
|
|
455
463
|
'unicorn/prefer-regexp-test': 'off',
|
|
@@ -865,7 +873,7 @@ plugin.configs = {
|
|
|
865
873
|
// ── Required overrides when eslint-plugin-unicorn covers SSJS ────────────
|
|
866
874
|
|
|
867
875
|
/**
|
|
868
|
-
* REQUIRED when unicorn covers standalone `.ssjs` files: turns off the
|
|
876
|
+
* REQUIRED when unicorn covers standalone `.ssjs` files: turns off the 60
|
|
869
877
|
* unicorn recommended rules incompatible with SFMC SSJS. Plain rules object with NO
|
|
870
878
|
* `plugins` key — eslint-plugin-sfmc does not load unicorn. Insert this object
|
|
871
879
|
* AFTER your own unicorn config (which registers the `unicorn` plugin);
|
|
@@ -879,7 +887,7 @@ plugin.configs = {
|
|
|
879
887
|
},
|
|
880
888
|
|
|
881
889
|
/**
|
|
882
|
-
* REQUIRED when unicorn covers SSJS embedded in HTML: same
|
|
890
|
+
* REQUIRED when unicorn covers SSJS embedded in HTML: same 60-rule override
|
|
883
891
|
* for virtual `**\/*.html/*.js` files. Insert AFTER your unicorn config.
|
|
884
892
|
* Omit this config if unicorn is not enabled for embedded SSJS.
|
|
885
893
|
*/
|
package/src/processor.js
CHANGED
|
@@ -223,11 +223,7 @@ export function preprocess(text, filename) {
|
|
|
223
223
|
blocks.push(...msoPreprocess(text, filename));
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
|
|
227
|
-
return [text];
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return blocks;
|
|
226
|
+
return blocks.length === 0 ? [text] : blocks;
|
|
231
227
|
}
|
|
232
228
|
|
|
233
229
|
export function postprocess(messages) {
|