eslint-plugin-sfmc 0.1.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.
Files changed (86) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +100 -0
  3. package/docs/rules/amp/function-arity.md +53 -0
  4. package/docs/rules/amp/naming-convention.md +76 -0
  5. package/docs/rules/amp/no-deprecated-function.md +78 -0
  6. package/docs/rules/amp/no-email-excluded-function.md +69 -0
  7. package/docs/rules/amp/no-empty-block.md +59 -0
  8. package/docs/rules/amp/no-empty-then.md +62 -0
  9. package/docs/rules/amp/no-html-comment.md +67 -0
  10. package/docs/rules/amp/no-inline-statement.md +51 -0
  11. package/docs/rules/amp/no-js-line-comment.md +54 -0
  12. package/docs/rules/amp/no-loop-counter-assign.md +52 -0
  13. package/docs/rules/amp/no-nested-ampscript-delimiter.md +69 -0
  14. package/docs/rules/amp/no-nested-script-tag.md +58 -0
  15. package/docs/rules/amp/no-smart-quotes.md +60 -0
  16. package/docs/rules/amp/no-unknown-function.md +50 -0
  17. package/docs/rules/amp/no-var-redeclaration.md +52 -0
  18. package/docs/rules/amp/prefer-attribute-value.md +64 -0
  19. package/docs/rules/amp/require-rowcount-check.md +62 -0
  20. package/docs/rules/amp/require-variable-declaration.md +51 -0
  21. package/docs/rules/amp/set-requires-target.md +47 -0
  22. package/docs/rules/ssjs/cache-loop-length.md +59 -0
  23. package/docs/rules/ssjs/no-hardcoded-credentials.md +52 -0
  24. package/docs/rules/ssjs/no-switch-default.md +37 -0
  25. package/docs/rules/ssjs/no-treatascontent-injection.md +38 -0
  26. package/docs/rules/ssjs/no-unavailable-method.md +134 -0
  27. package/docs/rules/ssjs/no-unknown-core-method.md +46 -0
  28. package/docs/rules/ssjs/no-unknown-http-method.md +44 -0
  29. package/docs/rules/ssjs/no-unknown-platform-client-browser.md +44 -0
  30. package/docs/rules/ssjs/no-unknown-platform-function.md +44 -0
  31. package/docs/rules/ssjs/no-unknown-platform-request.md +43 -0
  32. package/docs/rules/ssjs/no-unknown-platform-response.md +43 -0
  33. package/docs/rules/ssjs/no-unknown-platform-variable.md +43 -0
  34. package/docs/rules/ssjs/no-unknown-wsproxy-method.md +46 -0
  35. package/docs/rules/ssjs/no-unsupported-syntax.md +83 -0
  36. package/docs/rules/ssjs/platform-function-arity.md +45 -0
  37. package/docs/rules/ssjs/prefer-parsejson-safe-arg.md +42 -0
  38. package/docs/rules/ssjs/prefer-platform-load-version.md +68 -0
  39. package/docs/rules/ssjs/require-hasownproperty.md +57 -0
  40. package/docs/rules/ssjs/require-platform-load-order.md +46 -0
  41. package/docs/rules/ssjs/require-platform-load.md +57 -0
  42. package/package.json +52 -0
  43. package/src/ampscript-parser.js +159 -0
  44. package/src/ampscript-processor.js +132 -0
  45. package/src/index.js +355 -0
  46. package/src/processor.js +147 -0
  47. package/src/rules/amp/function-arity.js +51 -0
  48. package/src/rules/amp/naming-convention.js +58 -0
  49. package/src/rules/amp/no-deprecated-function.js +75 -0
  50. package/src/rules/amp/no-email-excluded-function.js +72 -0
  51. package/src/rules/amp/no-empty-block.js +37 -0
  52. package/src/rules/amp/no-empty-then.js +34 -0
  53. package/src/rules/amp/no-html-comment.js +57 -0
  54. package/src/rules/amp/no-inline-statement.js +45 -0
  55. package/src/rules/amp/no-js-line-comment.js +54 -0
  56. package/src/rules/amp/no-loop-counter-assign.js +71 -0
  57. package/src/rules/amp/no-nested-ampscript-delimiter.js +102 -0
  58. package/src/rules/amp/no-nested-script-tag.js +65 -0
  59. package/src/rules/amp/no-smart-quotes.js +78 -0
  60. package/src/rules/amp/no-unknown-function.js +31 -0
  61. package/src/rules/amp/no-var-redeclaration.js +36 -0
  62. package/src/rules/amp/prefer-attribute-value.js +94 -0
  63. package/src/rules/amp/require-rowcount-check.js +116 -0
  64. package/src/rules/amp/require-variable-declaration.js +49 -0
  65. package/src/rules/amp/set-requires-target.js +27 -0
  66. package/src/rules/ssjs/cache-loop-length.js +92 -0
  67. package/src/rules/ssjs/no-hardcoded-credentials.js +66 -0
  68. package/src/rules/ssjs/no-switch-default.js +32 -0
  69. package/src/rules/ssjs/no-treatascontent-injection.js +76 -0
  70. package/src/rules/ssjs/no-unavailable-method.js +190 -0
  71. package/src/rules/ssjs/no-unknown-core-method.js +103 -0
  72. package/src/rules/ssjs/no-unknown-http-method.js +41 -0
  73. package/src/rules/ssjs/no-unknown-platform-client-browser.js +50 -0
  74. package/src/rules/ssjs/no-unknown-platform-function.js +49 -0
  75. package/src/rules/ssjs/no-unknown-platform-request.js +50 -0
  76. package/src/rules/ssjs/no-unknown-platform-response.js +50 -0
  77. package/src/rules/ssjs/no-unknown-platform-variable.js +50 -0
  78. package/src/rules/ssjs/no-unknown-wsproxy-method.js +71 -0
  79. package/src/rules/ssjs/no-unsupported-syntax.js +122 -0
  80. package/src/rules/ssjs/platform-function-arity.js +70 -0
  81. package/src/rules/ssjs/prefer-parsejson-safe-arg.js +94 -0
  82. package/src/rules/ssjs/prefer-platform-load-version.js +96 -0
  83. package/src/rules/ssjs/require-hasownproperty.js +142 -0
  84. package/src/rules/ssjs/require-platform-load-order.js +112 -0
  85. package/src/rules/ssjs/require-platform-load.js +124 -0
  86. package/src/ssjs-processor.js +48 -0
@@ -0,0 +1,52 @@
1
+ # `sfmc/ssjs-no-hardcoded-credentials`
2
+
3
+ > Disallow hardcoded keys, IVs, or salts in encryption/decryption calls.
4
+
5
+ | | |
6
+ |---|---|
7
+ | **Type** | `problem` |
8
+ | **Default severity** | `error` in `recommended` and `strict` |
9
+ | **Fixable** | — |
10
+
11
+ ## Why This Rule Exists
12
+
13
+ Hardcoding cryptographic keys, initialisation vectors, or salts as string literals in `Platform.Function.EncryptSymmetric` or `Platform.Function.DecryptSymmetric` calls is a security risk. The values are visible in plain text inside your content template, accessible to anyone with access to the Marketing Cloud account or its version history. Credentials should be stored in a Data Extension and retrieved at runtime so they are never committed to templates directly.
14
+
15
+ ## Settings
16
+
17
+ | Setting | Values | Default |
18
+ |---------|--------|---------|
19
+ | severity | `"error"` \| `"warn"` \| `"off"` | `"error"` |
20
+
21
+ This rule has no configuration options.
22
+
23
+ The rule flags string literals at argument positions 1, 3, 5, and 7 (the key, IV, salt, and additional-key positions) of `EncryptSymmetric` and `DecryptSymmetric` calls.
24
+
25
+ ### Examples
26
+
27
+ **Not allowed:**
28
+
29
+ ```js
30
+ Platform.Load("core", "1.1.5");
31
+ var encrypted = Platform.Function.EncryptSymmetric(plaintext, "AES", "my-secret-key", null, null, null);
32
+ var decrypted = Platform.Function.DecryptSymmetric(ciphertext, "AES", "my-secret-key", null, null, null);
33
+ ```
34
+
35
+ **Allowed:**
36
+
37
+ ```js
38
+ Platform.Load("core", "1.1.5");
39
+ var de = DataExtension.Init("EncryptionKeys");
40
+ var filter = { Property: "Name", SimpleOperator: "equals", Value: "AES_KEY" };
41
+ var rows = de.Rows.Lookup([filter]);
42
+ var key = Platform.Function.Field(Platform.Function.Row(rows, 1), "KeyValue");
43
+
44
+ var encrypted = Platform.Function.EncryptSymmetric(plaintext, "AES", key, null, null, null);
45
+ ```
46
+
47
+ ## When to Disable
48
+
49
+ ```js
50
+ // eslint.config.js
51
+ rules: { 'sfmc/ssjs-no-hardcoded-credentials': 'off' }
52
+ ```
@@ -0,0 +1,37 @@
1
+ # ssjs-no-switch-default
2
+
3
+ Disallow `default` case in `switch` statements.
4
+
5
+ ## Why
6
+
7
+ SFMC's SSJS engine may silently skip the `default` case in `switch` statements. This is a known engine bug that causes code in the `default` block to never execute, leading to hard-to-debug logic errors.
8
+
9
+ ## Recommended approach
10
+
11
+ Enumerate all expected values as explicit `case` labels:
12
+
13
+ ```js
14
+ // Bad -- 'default' may not execute
15
+ switch (status) {
16
+ case 'active':
17
+ doActive();
18
+ break;
19
+ default:
20
+ doFallback();
21
+ break;
22
+ }
23
+
24
+ // Good -- explicit cases
25
+ switch (status) {
26
+ case 'active':
27
+ doActive();
28
+ break;
29
+ case 'inactive':
30
+ doFallback();
31
+ break;
32
+ }
33
+ ```
34
+
35
+ ## Settings
36
+
37
+ This rule has no options.
@@ -0,0 +1,38 @@
1
+ # ssjs-no-treatascontent-injection
2
+
3
+ Disallow string concatenation inside `TreatAsContent()` calls.
4
+
5
+ ## Why
6
+
7
+ `Platform.Function.TreatAsContent()` evaluates its string argument as AMPscript. When dynamic values are concatenated into that string, an attacker (or unexpected data containing AMPscript syntax) can inject and execute arbitrary AMPscript code.
8
+
9
+ ## Unsafe pattern
10
+
11
+ ```js
12
+ // UNSAFE -- 'string' could contain AMPscript code
13
+ Platform.Function.TreatAsContent('%%[ Set @x = Trim("' + string + '")]%%');
14
+ ```
15
+
16
+ ## Safe pattern
17
+
18
+ Pass dynamic values through `Variable.SetValue()` first, then reference the AMPscript variable inside `TreatAsContent()`:
19
+
20
+ ```js
21
+ // SAFE -- no user data in the AMPscript string
22
+ Variable.SetValue('@input', string);
23
+ Platform.Function.TreatAsContent('%%[ Set @x = Trim(@input) ]%%');
24
+ var result = Variable.GetValue('@x');
25
+ ```
26
+
27
+ This approach ensures that dynamic values are never interpreted as AMPscript instructions.
28
+
29
+ ## Rule details
30
+
31
+ This rule flags `TreatAsContent()` and `Platform.Function.TreatAsContent()` calls where the first argument contains:
32
+
33
+ - String concatenation (`+` operator)
34
+ - Template literals with expressions (`` `...${expr}...` ``)
35
+
36
+ ## Settings
37
+
38
+ This rule has no options.
@@ -0,0 +1,134 @@
1
+ # `sfmc/ssjs-no-unavailable-method`
2
+
3
+ > Flag Array methods that are unavailable or broken in SFMC SSJS and suggest inserting a polyfill.
4
+
5
+ | | |
6
+ |---|---|
7
+ | **Type** | `problem` |
8
+ | **Default severity** | `warn` in `recommended` and `strict` |
9
+ | **Fixable** | **Suggestion** only (lightbulb / `Ctrl+.` in VS Code) |
10
+
11
+ ## Why This Rule Exists
12
+
13
+ SFMC Server-Side JavaScript runs on an old ECMAScript 3/5 engine (Jint). Many modern
14
+ `Array` methods that developers expect to work either throw a runtime error or silently
15
+ return wrong results:
16
+
17
+ - **Unavailable** — the method does not exist on the object at all. Calling it throws
18
+ `expecting object: <methodName>` at runtime.
19
+ - **Broken** — the method exists natively but its implementation is incorrect:
20
+ - `splice` ignores its first two parameters and replaces elements from the left.
21
+ - `lastIndexOf` always returns `-1`.
22
+
23
+ This rule detects both categories and offers a lightbulb suggestion to insert a polyfill
24
+ at the end of the file.
25
+
26
+ ## Covered methods
27
+
28
+ | Method | Category | Notes |
29
+ |--------|----------|-------|
30
+ | `Array.prototype.copyWithin` | unavailable | |
31
+ | `Array.prototype.entries` | unavailable | Returns a minimal iterator; `for...of` is also unsupported |
32
+ | `Array.prototype.fill` | unavailable | |
33
+ | `Array.prototype.filter` | unavailable | |
34
+ | `Array.prototype.find` | unavailable | |
35
+ | `Array.prototype.findIndex` | unavailable | |
36
+ | `Array.prototype.forEach` | unavailable | |
37
+ | `Array.prototype.includes` | unavailable | |
38
+ | `Array.prototype.indexOf` | unavailable | Only flagged on array literals; string `.indexOf()` still works |
39
+ | `Array.prototype.lastIndexOf` | broken | Natively always returns `-1` |
40
+ | `Array.prototype.map` | unavailable | |
41
+ | `Array.prototype.reduce` | unavailable | |
42
+ | `Array.prototype.reduceRight` | unavailable | |
43
+ | `Array.prototype.some` | unavailable | |
44
+ | `Array.prototype.splice` | broken | Natively ignores `startIndex` and `deleteCount` |
45
+ | `Array.isArray` | unavailable | |
46
+ | `Array.of` | unavailable | |
47
+
48
+ ## Settings
49
+
50
+ | Setting | Values | Default |
51
+ |---------|--------|---------|
52
+ | severity | `"error"` \| `"warn"` \| `"off"` | `"warn"` |
53
+ | `ignore` | Array of method names to suppress | `[]` |
54
+
55
+ Use `ignore` when polyfills are loaded externally via a Content Block or Code Resource
56
+ that runs before your script.
57
+
58
+ ```js
59
+ // eslint.config.js
60
+ rules: {
61
+ 'sfmc/ssjs-no-unavailable-method': ['warn', { ignore: ['map', 'filter', 'forEach'] }]
62
+ }
63
+ ```
64
+
65
+ ## Examples
66
+
67
+ ### Not allowed (without polyfill)
68
+
69
+ ```js
70
+ var nums = [1, 2, 3];
71
+ var doubled = nums.map(function (n) { return n * 2; }); // unavailable
72
+
73
+ var pos = nums.lastIndexOf(2); // broken — always returns -1 natively
74
+
75
+ var found = Array.isArray(nums); // unavailable
76
+ ```
77
+
78
+ ### Allowed
79
+
80
+ ```js
81
+ // Polyfill defined in the same file — rule is suppressed
82
+ Array.prototype.map = function (callback) { /* ... */ };
83
+
84
+ var doubled = nums.map(function (n) { return n * 2; }); // ok
85
+
86
+ // Native methods that work correctly are never flagged
87
+ nums.push(4);
88
+ nums.reverse();
89
+ nums.join(', ');
90
+ nums.slice(0, 2);
91
+ ```
92
+
93
+ ### With `ignore`
94
+
95
+ ```js
96
+ // eslint.config.js
97
+ rules: {
98
+ 'sfmc/ssjs-no-unavailable-method': ['warn', { ignore: ['map', 'filter'] }]
99
+ }
100
+ ```
101
+
102
+ ```js
103
+ // No warning — 'map' and 'filter' are in the ignore list
104
+ var doubled = nums.map(function (n) { return n * 2; });
105
+ var evens = nums.filter(function (n) { return n % 2 === 0; });
106
+ ```
107
+
108
+ ## Suggestion (lightbulb)
109
+
110
+ When a violation is reported, a suggestion is available to insert the individual
111
+ polyfill at the **end of the file**. Apply it via:
112
+
113
+ - Click the **lightbulb** or press `Ctrl+.` in VS Code (requires the ESLint extension)
114
+ - `eslint --fix` does **not** apply suggestions
115
+
116
+ > **Important:** `Array.prototype.X = function () {}` is an assignment expression —
117
+ > it is **not** hoisted like a function declaration. You must ensure the polyfill
118
+ > executes before the first call to the method. If you apply the suggestion and the
119
+ > method is called earlier in the file, move the polyfill above the first usage, or
120
+ > load it from an external Content Block / Code Resource that runs first.
121
+
122
+ ## When to Disable
123
+
124
+ ```js
125
+ // eslint.config.js
126
+ rules: { 'sfmc/ssjs-no-unavailable-method': 'off' }
127
+ ```
128
+
129
+ Or suppress per-line for a single call you know is safe:
130
+
131
+ ```js
132
+ // eslint-disable-next-line sfmc/ssjs-no-unavailable-method
133
+ var result = myArr.map(transform);
134
+ ```
@@ -0,0 +1,46 @@
1
+ # `sfmc/ssjs-no-unknown-core-method`
2
+
3
+ > Disallow calls to methods that don't exist on a Core library object.
4
+
5
+ | | |
6
+ |---|---|
7
+ | **Type** | `problem` |
8
+ | **Default severity** | `warn` in `recommended`; `error` in `strict` |
9
+ | **Fixable** | — |
10
+
11
+ ## Why This Rule Exists
12
+
13
+ When a variable is initialised with a known Core library constructor (e.g. `var de = DataExtension.Init("MyDE")`), only the methods documented for that Core object type should be called on it. Calling an undocumented or misspelled method causes a runtime error. This rule infers the object type from the `.Init()` call and validates subsequent method calls.
14
+
15
+ ## Settings
16
+
17
+ | Setting | Values | Default |
18
+ |---------|--------|---------|
19
+ | severity | `"error"` \| `"warn"` \| `"off"` | `"warn"` |
20
+
21
+ This rule has no configuration options.
22
+
23
+ ### Examples
24
+
25
+ **Not allowed:**
26
+
27
+ ```js
28
+ Platform.Load("core", "1.1.5");
29
+ var de = DataExtension.Init("MyDE");
30
+ de.Execute(); /* 'Execute' is not a method of DataExtension */
31
+ ```
32
+
33
+ **Allowed:**
34
+
35
+ ```js
36
+ Platform.Load("core", "1.1.5");
37
+ var de = DataExtension.Init("MyDE");
38
+ var rows = de.Rows.Retrieve();
39
+ ```
40
+
41
+ ## When to Disable
42
+
43
+ ```js
44
+ // eslint.config.js
45
+ rules: { 'sfmc/ssjs-no-unknown-core-method': 'off' }
46
+ ```
@@ -0,0 +1,44 @@
1
+ # `sfmc/ssjs-no-unknown-http-method`
2
+
3
+ > Disallow unknown `HTTP.*` method calls.
4
+
5
+ | | |
6
+ |---|---|
7
+ | **Type** | `problem` |
8
+ | **Default severity** | `error` in `recommended` and `strict` |
9
+ | **Fixable** | — |
10
+
11
+ ## Why This Rule Exists
12
+
13
+ SFMC's SSJS runtime exposes only four `HTTP` methods: `HTTP.Get`, `HTTP.Post`, `HTTP.GetRequest`, and `HTTP.PostRequest`. Calling any other `HTTP.*` method causes a runtime error. This rule validates every `HTTP.*` call against that fixed list.
14
+
15
+ ## Settings
16
+
17
+ | Setting | Values | Default |
18
+ |---------|--------|---------|
19
+ | severity | `"error"` \| `"warn"` \| `"off"` | `"error"` |
20
+
21
+ This rule has no configuration options.
22
+
23
+ ### Examples
24
+
25
+ **Not allowed:**
26
+
27
+ ```js
28
+ var response = HTTP.Delete("https://api.example.com/resource/1");
29
+ var response = HTTP.Patch("https://api.example.com/resource/1", payload);
30
+ ```
31
+
32
+ **Allowed:**
33
+
34
+ ```js
35
+ var getResponse = HTTP.Get("https://api.example.com/resource/1");
36
+ var postResponse = HTTP.Post("https://api.example.com/resource", payload, contentType);
37
+ ```
38
+
39
+ ## When to Disable
40
+
41
+ ```js
42
+ // eslint.config.js
43
+ rules: { 'sfmc/ssjs-no-unknown-http-method': 'off' }
44
+ ```
@@ -0,0 +1,44 @@
1
+ # `sfmc/ssjs-no-unknown-platform-client-browser`
2
+
3
+ > Disallow unknown `Platform.ClientBrowser.*` method calls.
4
+
5
+ | | |
6
+ |---|---|
7
+ | **Type** | `problem` |
8
+ | **Default severity** | `error` in `recommended` and `strict` |
9
+ | **Fixable** | — |
10
+
11
+ ## Why This Rule Exists
12
+
13
+ `Platform.ClientBrowser` exposes a small, fixed set of methods for writing to and redirecting the HTTP response on CloudPages and landing pages. Calling a method that does not exist in this catalog causes a runtime error. This rule validates every `Platform.ClientBrowser.*` call against the known list.
14
+
15
+ ## Settings
16
+
17
+ | Setting | Values | Default |
18
+ |---------|--------|---------|
19
+ | severity | `"error"` \| `"warn"` \| `"off"` | `"error"` |
20
+
21
+ This rule has no configuration options.
22
+
23
+ ### Examples
24
+
25
+ **Not allowed:**
26
+
27
+ ```js
28
+ Platform.ClientBrowser.Send("data");
29
+ ```
30
+
31
+ **Allowed:**
32
+
33
+ ```js
34
+ Platform.ClientBrowser.Redirect("https://example.com");
35
+ Platform.ClientBrowser.Write("<p>Hello</p>");
36
+ Platform.ClientBrowser.SetCookie("session", "abc123");
37
+ ```
38
+
39
+ ## When to Disable
40
+
41
+ ```js
42
+ // eslint.config.js
43
+ rules: { 'sfmc/ssjs-no-unknown-platform-client-browser': 'off' }
44
+ ```
@@ -0,0 +1,44 @@
1
+ # `sfmc/ssjs-no-unknown-platform-function`
2
+
3
+ > Disallow calls to unknown `Platform.Function.*` methods.
4
+
5
+ | | |
6
+ |---|---|
7
+ | **Type** | `problem` |
8
+ | **Default severity** | `error` in `recommended` and `strict` |
9
+ | **Fixable** | — |
10
+
11
+ ## Why This Rule Exists
12
+
13
+ `Platform.Function` exposes a fixed set of SFMC server-side utility functions (e.g. `Platform.Function.Lookup`, `Platform.Function.InsertData`). Calling a method that does not exist in the catalog causes a runtime error. This rule validates every `Platform.Function.*` call against the known list.
14
+
15
+ ## Settings
16
+
17
+ | Setting | Values | Default |
18
+ |---------|--------|---------|
19
+ | severity | `"error"` \| `"warn"` \| `"off"` | `"error"` |
20
+
21
+ This rule has no configuration options.
22
+
23
+ ### Examples
24
+
25
+ **Not allowed:**
26
+
27
+ ```js
28
+ Platform.Load("core", "1.1.5");
29
+ var result = Platform.Function.CustomQuery("MyDE");
30
+ ```
31
+
32
+ **Allowed:**
33
+
34
+ ```js
35
+ Platform.Load("core", "1.1.5");
36
+ var result = Platform.Function.Lookup("MyDE", "Value", "Key", keyValue);
37
+ ```
38
+
39
+ ## When to Disable
40
+
41
+ ```js
42
+ // eslint.config.js
43
+ rules: { 'sfmc/ssjs-no-unknown-platform-function': 'off' }
44
+ ```
@@ -0,0 +1,43 @@
1
+ # `sfmc/ssjs-no-unknown-platform-request`
2
+
3
+ > Disallow unknown `Platform.Request.*` method calls.
4
+
5
+ | | |
6
+ |---|---|
7
+ | **Type** | `problem` |
8
+ | **Default severity** | `error` in `recommended` and `strict` |
9
+ | **Fixable** | — |
10
+
11
+ ## Why This Rule Exists
12
+
13
+ `Platform.Request` exposes a fixed set of methods for reading incoming HTTP request data on CloudPages and landing pages (e.g. `Platform.Request.GetQueryStringParameter`, `Platform.Request.GetFormField`). Calling an unknown method causes a runtime error. This rule validates every `Platform.Request.*` call against the known list.
14
+
15
+ ## Settings
16
+
17
+ | Setting | Values | Default |
18
+ |---------|--------|---------|
19
+ | severity | `"error"` \| `"warn"` \| `"off"` | `"error"` |
20
+
21
+ This rule has no configuration options.
22
+
23
+ ### Examples
24
+
25
+ **Not allowed:**
26
+
27
+ ```js
28
+ var val = Platform.Request.ReadParam("myParam");
29
+ ```
30
+
31
+ **Allowed:**
32
+
33
+ ```js
34
+ var val = Platform.Request.GetQueryStringParameter("myParam");
35
+ var field = Platform.Request.GetFormField("email");
36
+ ```
37
+
38
+ ## When to Disable
39
+
40
+ ```js
41
+ // eslint.config.js
42
+ rules: { 'sfmc/ssjs-no-unknown-platform-request': 'off' }
43
+ ```
@@ -0,0 +1,43 @@
1
+ # `sfmc/ssjs-no-unknown-platform-response`
2
+
3
+ > Disallow unknown `Platform.Response.*` method calls.
4
+
5
+ | | |
6
+ |---|---|
7
+ | **Type** | `problem` |
8
+ | **Default severity** | `error` in `recommended` and `strict` |
9
+ | **Fixable** | — |
10
+
11
+ ## Why This Rule Exists
12
+
13
+ `Platform.Response` exposes a fixed set of methods for controlling HTTP responses from CloudPages and landing pages (e.g. `Platform.Response.Write`, `Platform.Response.Redirect`). Calling an unknown method causes a runtime error. This rule validates every `Platform.Response.*` call against the known list.
14
+
15
+ ## Settings
16
+
17
+ | Setting | Values | Default |
18
+ |---------|--------|---------|
19
+ | severity | `"error"` \| `"warn"` \| `"off"` | `"error"` |
20
+
21
+ This rule has no configuration options.
22
+
23
+ ### Examples
24
+
25
+ **Not allowed:**
26
+
27
+ ```js
28
+ Platform.Response.Send("text/html", "<p>Hello</p>");
29
+ ```
30
+
31
+ **Allowed:**
32
+
33
+ ```js
34
+ Platform.Response.Write("<p>Hello</p>");
35
+ Platform.Response.Redirect("https://example.com");
36
+ ```
37
+
38
+ ## When to Disable
39
+
40
+ ```js
41
+ // eslint.config.js
42
+ rules: { 'sfmc/ssjs-no-unknown-platform-response': 'off' }
43
+ ```
@@ -0,0 +1,43 @@
1
+ # `sfmc/ssjs-no-unknown-platform-variable`
2
+
3
+ > Disallow unknown `Platform.Variable.*` method calls.
4
+
5
+ | | |
6
+ |---|---|
7
+ | **Type** | `problem` |
8
+ | **Default severity** | `error` in `recommended` and `strict` |
9
+ | **Fixable** | — |
10
+
11
+ ## Why This Rule Exists
12
+
13
+ `Platform.Variable` exposes a fixed set of methods for interacting with AMPscript variables from SSJS (e.g. `Platform.Variable.GetValue`, `Platform.Variable.SetValue`). Calling an unknown method causes a runtime error. This rule validates every `Platform.Variable.*` call against the known list.
14
+
15
+ ## Settings
16
+
17
+ | Setting | Values | Default |
18
+ |---------|--------|---------|
19
+ | severity | `"error"` \| `"warn"` \| `"off"` | `"error"` |
20
+
21
+ This rule has no configuration options.
22
+
23
+ ### Examples
24
+
25
+ **Not allowed:**
26
+
27
+ ```js
28
+ var val = Platform.Variable.ReadValue("@myVar");
29
+ ```
30
+
31
+ **Allowed:**
32
+
33
+ ```js
34
+ var val = Platform.Variable.GetValue("@myVar");
35
+ Platform.Variable.SetValue("@myVar", "Hello");
36
+ ```
37
+
38
+ ## When to Disable
39
+
40
+ ```js
41
+ // eslint.config.js
42
+ rules: { 'sfmc/ssjs-no-unknown-platform-variable': 'off' }
43
+ ```
@@ -0,0 +1,46 @@
1
+ # `sfmc/ssjs-no-unknown-wsproxy-method`
2
+
3
+ > Disallow unknown method calls on a `WSProxy` instance.
4
+
5
+ | | |
6
+ |---|---|
7
+ | **Type** | `problem` |
8
+ | **Default severity** | `warn` in `recommended`; `error` in `strict` |
9
+ | **Fixable** | — |
10
+
11
+ ## Why This Rule Exists
12
+
13
+ `WSProxy` is SFMC's SSJS wrapper around the SOAP API. It exposes a specific set of methods (`retrieve`, `retrieveAll`, `create`, `update`, `delete`, `execute`, `perform`). Calling an unknown method on a `WSProxy` instance causes a runtime error. This rule infers `WSProxy` variable usage and validates method calls against the known list.
14
+
15
+ ## Settings
16
+
17
+ | Setting | Values | Default |
18
+ |---------|--------|---------|
19
+ | severity | `"error"` \| `"warn"` \| `"off"` | `"warn"` |
20
+
21
+ This rule has no configuration options.
22
+
23
+ ### Examples
24
+
25
+ **Not allowed:**
26
+
27
+ ```js
28
+ Platform.Load("core", "1.1.5");
29
+ var proxy = new Script.Util.WSProxy();
30
+ var result = proxy.query({ ObjectType: "Subscriber" });
31
+ ```
32
+
33
+ **Allowed:**
34
+
35
+ ```js
36
+ Platform.Load("core", "1.1.5");
37
+ var proxy = new Script.Util.WSProxy();
38
+ var result = proxy.retrieve({ ObjectType: "Subscriber", Properties: ["SubscriberKey"] }, []);
39
+ ```
40
+
41
+ ## When to Disable
42
+
43
+ ```js
44
+ // eslint.config.js
45
+ rules: { 'sfmc/ssjs-no-unknown-wsproxy-method': 'off' }
46
+ ```