eslint-plugin-sfmc 4.13.0 → 4.15.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
|
@@ -109,6 +109,7 @@ export default [...sfmc.configs['recommended-next'], ...sfmc.configs['embedded-n
|
|
|
109
109
|
| [`sfmc/amp-no-loop-counter-assign`](docs/rules/amp/no-loop-counter-assign.md) | `warn` | Disallow assigning to the `for` loop counter |
|
|
110
110
|
| [`sfmc/amp-no-inline-statement`](docs/rules/amp/no-inline-statement.md) | `warn` | Disallow statements inside inline expressions |
|
|
111
111
|
| [`sfmc/amp-no-deprecated-function`](docs/rules/amp/no-deprecated-function.md) | `warn` | Flag deprecated functions and suggest replacements |
|
|
112
|
+
| [`sfmc/amp-no-nonfunctional-function`](docs/rules/amp/no-nonfunctional-function.md) | `error` | Flag functions that resolve but have no working runtime invocation |
|
|
112
113
|
| [`sfmc/amp-naming-convention`](docs/rules/amp/naming-convention.md) | `warn` | Enforce variable naming convention |
|
|
113
114
|
| [`sfmc/amp-no-empty-then`](docs/rules/amp/no-empty-then.md) | `warn` | Disallow IF with empty THEN branch |
|
|
114
115
|
| [`sfmc/amp-require-rowcount-check`](docs/rules/amp/require-rowcount-check.md) | `warn` | Require RowCount check before FOR on LookupRows |
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# `sfmc/amp-no-nonfunctional-function`
|
|
2
|
+
|
|
3
|
+
> Flag AMPscript functions that resolve at runtime but have no known working invocation.
|
|
4
|
+
|
|
5
|
+
| | |
|
|
6
|
+
|---|---|
|
|
7
|
+
| **Type** | `problem` |
|
|
8
|
+
| **Default severity** | `error` in `recommended` and `strict` |
|
|
9
|
+
| **Fixable** | No — there is no replacement to auto-apply |
|
|
10
|
+
|
|
11
|
+
## Why This Rule Exists
|
|
12
|
+
|
|
13
|
+
A handful of catalogued AMPscript functions still parse and resolve, yet every reached call aborts the page at runtime. This happens when the platform capability the function depends on has been retired (for example Classic Portfolio behind `GetPortfolioItem`, or Classic Content behind `GetPublishedSocialContent`), or when the integration it targets has no working call shape (the MSCRM family).
|
|
14
|
+
|
|
15
|
+
These functions are deliberately kept in completions and hover — they exist in the language — but calling one is always a bug, so the call site is flagged. This is distinct from deprecation: Salesforce never issued a formal sunset notice or a drop-in replacement, so `amp-no-deprecated-function` does not cover them.
|
|
16
|
+
|
|
17
|
+
In Marketing Cloud Next targets these same functions are already reported by `amp-no-mcn-unsupported`, so this rule is disabled in the `-next` configs to avoid a duplicate diagnostic.
|
|
18
|
+
|
|
19
|
+
## Settings
|
|
20
|
+
|
|
21
|
+
| Setting | Values | Default |
|
|
22
|
+
|---------|--------|---------|
|
|
23
|
+
| severity | `"error"` \| `"warn"` \| `"off"` | `"error"` |
|
|
24
|
+
|
|
25
|
+
This rule has no configuration options.
|
|
26
|
+
|
|
27
|
+
### Examples
|
|
28
|
+
|
|
29
|
+
**Not allowed:**
|
|
30
|
+
|
|
31
|
+
```ampscript
|
|
32
|
+
%%[
|
|
33
|
+
var @item
|
|
34
|
+
set @item = GetPortfolioItem("my-portfolio-key")
|
|
35
|
+
|
|
36
|
+
var @social
|
|
37
|
+
set @social = GetPublishedSocialContent("socialContentId")
|
|
38
|
+
]%%
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Allowed:**
|
|
42
|
+
|
|
43
|
+
```ampscript
|
|
44
|
+
%%[
|
|
45
|
+
var @block
|
|
46
|
+
set @block = ContentBlockByKey("my-block-key")
|
|
47
|
+
]%%
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## When to Disable
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
// eslint.config.js
|
|
54
|
+
rules: { 'sfmc/amp-no-nonfunctional-function': 'off' }
|
|
55
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-sfmc",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.15.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,7 +37,7 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@handlebars/parser": "^2.2.2",
|
|
40
|
-
"ampscript-data": "^3.
|
|
40
|
+
"ampscript-data": "^3.5.0",
|
|
41
41
|
"ampscript-parser": "^0.3.1",
|
|
42
42
|
"eslint-plugin-mso-email": "^2.0.0",
|
|
43
43
|
"handlebars-data": "^0.3.1",
|
package/src/index.js
CHANGED
|
@@ -28,6 +28,7 @@ import ampFunctionArity from './rules/amp/function-arity.js';
|
|
|
28
28
|
import ampArgumentTypes from './rules/amp/argument-types.js';
|
|
29
29
|
import ampNoEmailExcludedFunction from './rules/amp/no-email-excluded-function.js';
|
|
30
30
|
import ampNoDeprecatedFunction from './rules/amp/no-deprecated-function.js';
|
|
31
|
+
import ampNoNonfunctionalFunction from './rules/amp/no-nonfunctional-function.js';
|
|
31
32
|
import ampNamingConvention from './rules/amp/naming-convention.js';
|
|
32
33
|
import ampNoEmptyThen from './rules/amp/no-empty-then.js';
|
|
33
34
|
import ampRequireRowcountCheck from './rules/amp/require-rowcount-check.js';
|
|
@@ -114,6 +115,7 @@ const plugin = {
|
|
|
114
115
|
'amp-arg-types': ampArgumentTypes,
|
|
115
116
|
'amp-no-email-excluded-function': ampNoEmailExcludedFunction,
|
|
116
117
|
'amp-no-deprecated-function': ampNoDeprecatedFunction,
|
|
118
|
+
'amp-no-nonfunctional-function': ampNoNonfunctionalFunction,
|
|
117
119
|
'amp-naming-convention': ampNamingConvention,
|
|
118
120
|
'amp-no-empty-then': ampNoEmptyThen,
|
|
119
121
|
'amp-require-rowcount-check': ampRequireRowcountCheck,
|
|
@@ -212,6 +214,7 @@ const ampRecommendedRules = {
|
|
|
212
214
|
'sfmc/amp-function-arity': 'error',
|
|
213
215
|
'sfmc/amp-arg-types': 'error',
|
|
214
216
|
'sfmc/amp-no-deprecated-function': 'warn',
|
|
217
|
+
'sfmc/amp-no-nonfunctional-function': 'error',
|
|
215
218
|
'sfmc/amp-naming-convention': 'warn',
|
|
216
219
|
'sfmc/amp-no-empty-then': 'warn',
|
|
217
220
|
'sfmc/amp-require-rowcount-check': 'warn',
|
|
@@ -235,6 +238,7 @@ const ampStrictRules = {
|
|
|
235
238
|
'sfmc/amp-arg-types': 'error',
|
|
236
239
|
'sfmc/amp-no-email-excluded-function': 'off',
|
|
237
240
|
'sfmc/amp-no-deprecated-function': 'warn',
|
|
241
|
+
'sfmc/amp-no-nonfunctional-function': 'error',
|
|
238
242
|
'sfmc/amp-naming-convention': ['error', { format: 'camelCase' }],
|
|
239
243
|
'sfmc/amp-no-empty-then': 'error',
|
|
240
244
|
'sfmc/amp-require-rowcount-check': 'error',
|
|
@@ -639,6 +643,9 @@ plugin.configs = {
|
|
|
639
643
|
rules: {
|
|
640
644
|
...ampRecommendedRules,
|
|
641
645
|
'sfmc/amp-no-mcn-unsupported': 'error',
|
|
646
|
+
// Already covered by amp-no-mcn-unsupported in MCN (these functions
|
|
647
|
+
// are mcnSince:null); disabled here to avoid double-reporting.
|
|
648
|
+
'sfmc/amp-no-nonfunctional-function': 'off',
|
|
642
649
|
},
|
|
643
650
|
},
|
|
644
651
|
|
|
@@ -670,6 +677,9 @@ plugin.configs = {
|
|
|
670
677
|
rules: {
|
|
671
678
|
...ampRecommendedRules,
|
|
672
679
|
'sfmc/amp-no-mcn-unsupported': 'error',
|
|
680
|
+
// Already covered by amp-no-mcn-unsupported in MCN (these
|
|
681
|
+
// functions are mcnSince:null); disabled to avoid double-reporting.
|
|
682
|
+
'sfmc/amp-no-nonfunctional-function': 'off',
|
|
673
683
|
},
|
|
674
684
|
},
|
|
675
685
|
{
|
|
@@ -705,6 +715,9 @@ plugin.configs = {
|
|
|
705
715
|
rules: {
|
|
706
716
|
...ampRecommendedRules,
|
|
707
717
|
'sfmc/amp-no-mcn-unsupported': 'error',
|
|
718
|
+
// Already covered by amp-no-mcn-unsupported in MCN (these
|
|
719
|
+
// functions are mcnSince:null); disabled to avoid double-reporting.
|
|
720
|
+
'sfmc/amp-no-nonfunctional-function': 'off',
|
|
708
721
|
},
|
|
709
722
|
},
|
|
710
723
|
{
|
|
@@ -744,6 +757,9 @@ plugin.configs = {
|
|
|
744
757
|
rules: {
|
|
745
758
|
...ampStrictRules,
|
|
746
759
|
'sfmc/amp-no-mcn-unsupported': 'error',
|
|
760
|
+
// Already covered by amp-no-mcn-unsupported in MCN (these
|
|
761
|
+
// functions are mcnSince:null); disabled to avoid double-reporting.
|
|
762
|
+
'sfmc/amp-no-nonfunctional-function': 'off',
|
|
747
763
|
},
|
|
748
764
|
},
|
|
749
765
|
{
|
|
@@ -771,6 +787,9 @@ plugin.configs = {
|
|
|
771
787
|
rules: {
|
|
772
788
|
...ampStrictRules,
|
|
773
789
|
'sfmc/amp-no-mcn-unsupported': 'error',
|
|
790
|
+
// Already covered by amp-no-mcn-unsupported in MCN (these
|
|
791
|
+
// functions are mcnSince:null); disabled to avoid double-reporting.
|
|
792
|
+
'sfmc/amp-no-nonfunctional-function': 'off',
|
|
774
793
|
},
|
|
775
794
|
},
|
|
776
795
|
{
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule: no-nonfunctional-function
|
|
3
|
+
*
|
|
4
|
+
* Flags calls to AMPscript functions that resolve at runtime but have no known
|
|
5
|
+
* working invocation (ampscript-data `nonFunctionalAtRuntime`). Unlike an unknown
|
|
6
|
+
* function, these DO exist in the catalog (so they remain in completions and
|
|
7
|
+
* hover), but every reached call aborts the page — e.g. `GetPortfolioItem` and
|
|
8
|
+
* the MSCRM family, whose underlying Classic feature is retired.
|
|
9
|
+
*
|
|
10
|
+
* Kept separate from `no-deprecated-function` because these functions were never
|
|
11
|
+
* formally deprecated by Salesforce; the failure is a retired platform feature,
|
|
12
|
+
* not a sunset notice. Reported as a problem with no auto-fix (no replacement
|
|
13
|
+
* exists). Mirrors the SSJS `ssjs-no-nonfunctional-method` rule.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { nonFunctionalFunctionLookup } from 'ampscript-data';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Extract a short factual pointer from an entry's officialDocsNote (first
|
|
20
|
+
* sentence) for the warning message. Returns an empty string when absent.
|
|
21
|
+
*
|
|
22
|
+
* @param {object} entry - ampscript-data function entry
|
|
23
|
+
* @returns {string} A short note, or empty string
|
|
24
|
+
*/
|
|
25
|
+
function shortNote(entry) {
|
|
26
|
+
if (!entry || typeof entry.officialDocsNote !== 'string') {
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
29
|
+
const trimmed = entry.officialDocsNote.trim();
|
|
30
|
+
if (trimmed === '') {
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
const sentenceEnd = trimmed.indexOf('. ');
|
|
34
|
+
return sentenceEnd === -1 ? trimmed : trimmed.slice(0, sentenceEnd + 1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default {
|
|
38
|
+
meta: {
|
|
39
|
+
type: 'problem',
|
|
40
|
+
docs: {
|
|
41
|
+
description:
|
|
42
|
+
'Disallow AMPscript functions that resolve at runtime but have no known working invocation',
|
|
43
|
+
},
|
|
44
|
+
hasSuggestions: false,
|
|
45
|
+
messages: {
|
|
46
|
+
nonFunctional:
|
|
47
|
+
"'{{name}}' exists in SFMC but has no known working invocation at runtime (every tested call aborts the page). {{note}}",
|
|
48
|
+
},
|
|
49
|
+
schema: [],
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
create(context) {
|
|
53
|
+
return {
|
|
54
|
+
FunctionCall(node) {
|
|
55
|
+
const functionName = node.name || (node.callee && node.callee.name) || '';
|
|
56
|
+
if (!functionName) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const entry = nonFunctionalFunctionLookup.get(functionName.toLowerCase());
|
|
61
|
+
if (!entry) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
context.report({
|
|
66
|
+
node,
|
|
67
|
+
messageId: 'nonFunctional',
|
|
68
|
+
data: { name: functionName, note: shortNote(entry) },
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
};
|