eslint-plugin-sfmc 5.4.4 → 5.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-sfmc",
3
- "version": "5.4.4",
3
+ "version": "5.6.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",
@@ -42,13 +42,19 @@
42
42
  "handlebars-data": "^0.8.2",
43
43
  "mso-conditional-parser": "^2.0.1",
44
44
  "sfmc-handlebars-parser": "^0.2.1",
45
- "ssjs-data": "^2.1.3"
45
+ "ssjs-data": "^2.2.1"
46
46
  },
47
47
  "peerDependencies": {
48
- "eslint": ">=10.0.0"
48
+ "eslint": ">=10.0.0",
49
+ "eslint-plugin-unicorn": ">=57.0.0 <=80.0.0"
50
+ },
51
+ "peerDependenciesMeta": {
52
+ "eslint-plugin-unicorn": {
53
+ "optional": true
54
+ }
49
55
  },
50
56
  "scripts": {
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",
57
+ "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 tests/unicorn-audit-database.test.js tests/unicorn-function.test.js && node --test tests/unicorn-minimum.test.js",
52
58
  "verify:own-dependencies-latest": "node scripts/verify-own-dependencies-latest.mjs",
53
59
  "preversion": "npm run verify:own-dependencies-latest",
54
60
  "test:release": "node --test tests/release-safeguards.test.js",
@@ -73,7 +79,7 @@
73
79
  "eslint-minimum": "npm:eslint@10.0.0",
74
80
  "eslint-plugin-jsdoc": "^64.5.4",
75
81
  "eslint-plugin-prettier": "^5.5.6",
76
- "eslint-plugin-unicorn": "^76.0.0",
82
+ "eslint-plugin-unicorn": "^80.0.0",
77
83
  "globals": "^17.12.0",
78
84
  "husky": "^9.1.7",
79
85
  "lint-staged": "^17.5.1",
package/src/index.js CHANGED
@@ -394,11 +394,13 @@ function standaloneHandlebarsConfigs(configName) {
394
394
  // ── Optional eslint-plugin-unicorn override for SSJS ──────────────────────────
395
395
 
396
396
  /**
397
- * The 60 `eslint-plugin-unicorn` recommended rules (analysed against
398
- * unicorn v76.0.0) that are incompatible with the SFMC SSJS (JINT / ES3-ES5)
399
- * engine — they either fix/suggest code using a missing built-in or forbid a required
400
- * SFMC workaround, or enforce ES-module / async / ES6-only syntax that the
401
- * engine cannot run. Each is mapped to `'off'`.
397
+ * The 88 `eslint-plugin-unicorn` recommended rules (audited against unicorn
398
+ * v76.0.0 and v80.0.0; the list is the union of both audits) that are
399
+ * incompatible with the SFMC SSJS (JINT / ES3-ES5) engine — they either
400
+ * fix/suggest code using a missing built-in, change recorded runtime semantics,
401
+ * forbid a required SFMC workaround, or emit ES2015+ syntax that the engine
402
+ * cannot run. Each is mapped to `'off'`. Per-rule verdicts: audit/unicorn/ in
403
+ * the repository (not published).
402
404
  *
403
405
  * This is exposed via the optional `unicorn-ssjs` / `unicorn-ssjs-embedded`
404
406
  * configs. eslint-plugin-sfmc does NOT depend on or load unicorn; these configs
@@ -470,6 +472,27 @@ const unicornSsjsOffRules = {
470
472
  'unicorn/prefer-object-define-properties': 'off',
471
473
  'unicorn/no-new-array': 'off',
472
474
  'unicorn/no-unnecessary-array-splice-count': 'off',
475
+ // Unicorn 80 audit — unavailable built-ins or changed SSJS semantics.
476
+ // New in 80: match() → exec() differs in SSJS (no-match [] vs null, broken groups).
477
+ 'unicorn/prefer-regexp-exec': 'off',
478
+ // New in 80: unescapes \x3C/script> and %%= inside server-side script blocks.
479
+ 'unicorn/prefer-literal-ascii': 'off',
480
+ // Everything below in this group already behaved this way in 76 (missed by the
481
+ // 76 audit); prefer-single-replace and prefer-url-search-parameters reach more
482
+ // code in 80. replaceAll, Object.values/entries, URLSearchParams, Object.hasOwn
483
+ // and Function#bind are unavailable in SSJS.
484
+ 'unicorn/prefer-single-replace': 'off',
485
+ 'unicorn/prefer-object-iterable-methods': 'off',
486
+ 'unicorn/prefer-url-search-parameters': 'off',
487
+ 'unicorn/no-computed-property-existence-check': 'off',
488
+ 'unicorn/dom-node-dataset': 'off',
489
+ 'unicorn/no-array-method-this-argument': 'off',
490
+ // Rewrites the SOAP namespace URI (exacttarget.com/wsdl/partnerAPI) to https.
491
+ 'unicorn/prefer-https': 'off',
492
+ // Drops trailing undefined arguments of arity-bound Platform functions.
493
+ 'unicorn/no-useless-undefined': 'off',
494
+ // new Date(d) drops the milliseconds in SSJS (verified live); new Date(d.getTime()) keeps them.
495
+ 'unicorn/consistent-date-clone': 'off',
473
496
  // Group B — forbid ES6+ syntax / ES-module / async constructs
474
497
  // Inert with strict ES5 parsing, but introduces for-of when block scopes are enabled.
475
498
  'unicorn/no-for-loop': 'off',
@@ -481,8 +504,321 @@ const unicornSsjsOffRules = {
481
504
  'unicorn/prefer-node-protocol': 'off',
482
505
  'unicorn/prefer-top-level-await': 'off',
483
506
  'unicorn/prefer-export-from': 'off',
507
+ // Unicorn 80 audit — fixes/suggestions that emit ES2015+ syntax from ES5 input.
508
+ // New in 80: always writes \u{A0}-style code-point escapes.
509
+ 'unicorn/prefer-escaped-irregular-whitespace': 'off',
510
+ // Everything below already behaved this way in 76 (missed by the 76 audit);
511
+ // no-array-sort-for-min-max and no-immediate-mutation reach more code in 80:
512
+ // ||= / &&=, 1_000 separators, \u{…} escapes, **, ??, spread, computed keys
513
+ // and arrow functions.
514
+ 'unicorn/logical-assignment-operators': 'off',
515
+ 'unicorn/numeric-separators-style': 'off',
516
+ 'unicorn/prefer-unicode-code-point-escapes': 'off',
517
+ 'unicorn/no-xor-as-exponentiation': 'off',
518
+ 'unicorn/prefer-logical-operator-over-ternary': 'off',
519
+ 'unicorn/no-accidental-bitwise-operator': 'off',
520
+ 'unicorn/no-array-sort-for-min-max': 'off',
521
+ 'unicorn/no-immediate-mutation': 'off',
522
+ 'unicorn/no-array-callback-reference': 'off',
523
+ 'unicorn/no-boolean-sort-comparator': 'off',
524
+ 'unicorn/prefer-simple-sort-comparator': 'off',
525
+ // Later finding (2026-12-02): these write control characters, DEL and U+2028/U+2029
526
+ // in string literals as ES2015 \u{…} escapes. prefer-keyboard-event-key only in 76.
527
+ 'unicorn/no-useless-concat': 'off',
528
+ 'unicorn/better-dom-traversing': 'off',
529
+ 'unicorn/no-invalid-dom-token': 'off',
530
+ 'unicorn/no-invalid-style-set-property': 'off',
531
+ 'unicorn/prefer-keyboard-event-key': 'off',
484
532
  };
485
533
 
534
+ /**
535
+ * Every `eslint-plugin-unicorn` rule, recommended or not, that the newest audit
536
+ * marked safe for SSJS (verdict `active` there and not `off` in any supported
537
+ * audit). A rule that only an older audit marked safe stays off.
538
+ * `unicornSsjs()` leaves these to the user's own
539
+ * unicorn config and turns every other unicorn rule off for SSJS, so renamed,
540
+ * new or unaudited rules stay off until an audit adds them here.
541
+ * tests/unicorn-function.test.js keeps this list equal to audit/unicorn/.
542
+ */
543
+ const unicornSsjsActiveRules = new Set([
544
+ 'catch-error-name',
545
+ 'class-reference-in-static-methods',
546
+ 'comment-content',
547
+ 'consistent-arrow-return-style',
548
+ 'consistent-assert',
549
+ 'consistent-boolean-name',
550
+ 'consistent-class-member-order',
551
+ 'consistent-compound-words',
552
+ 'consistent-conditional-object-spread',
553
+ 'consistent-destructuring',
554
+ 'consistent-empty-array-spread',
555
+ 'consistent-existence-index-check',
556
+ 'consistent-export-decorator-position',
557
+ 'consistent-function-scoping',
558
+ 'consistent-json-file-read',
559
+ 'consistent-optional-chaining',
560
+ 'consistent-template-literal-escape',
561
+ 'consistent-tuple-labels',
562
+ 'custom-error-definition',
563
+ 'default-export-style',
564
+ 'empty-brace-spaces',
565
+ 'error-message',
566
+ 'escape-case',
567
+ 'expiring-todo-comments',
568
+ 'explicit-length-check',
569
+ 'explicit-timer-delay',
570
+ 'filename-case',
571
+ 'id-match',
572
+ 'import-style',
573
+ 'isolated-functions',
574
+ 'iteration-fallback-style',
575
+ 'max-nested-calls',
576
+ 'name-replacements',
577
+ 'new-for-builtins',
578
+ 'no-abusive-eslint-disable',
579
+ 'no-accessor-recursion',
580
+ 'no-anonymous-default-export',
581
+ 'no-array-concat-in-loop',
582
+ 'no-array-fill-with-reference-type',
583
+ 'no-array-from-fill',
584
+ 'no-array-front-mutation',
585
+ 'no-array-reduce',
586
+ 'no-asterisk-prefix-in-documentation-comments',
587
+ 'no-async-iterator-callback',
588
+ 'no-async-promise-finally',
589
+ 'no-await-expression-member',
590
+ 'no-await-in-promise-methods',
591
+ 'no-barrel-files',
592
+ 'no-blob-to-file',
593
+ 'no-break-in-nested-loop',
594
+ 'no-canvas-to-image',
595
+ 'no-chained-comparison',
596
+ 'no-collection-bracket-access',
597
+ 'no-conflicting-constraints',
598
+ 'no-confusing-array-splice',
599
+ 'no-confusing-array-with',
600
+ 'no-console-spaces',
601
+ 'no-constant-zero-expression',
602
+ 'no-declarations-before-early-exit',
603
+ 'no-document-cookie',
604
+ 'no-double-comparison',
605
+ 'no-duplicate-if-branches',
606
+ 'no-duplicate-logical-operands',
607
+ 'no-duplicate-loops',
608
+ 'no-duplicate-set-values',
609
+ 'no-empty-file',
610
+ 'no-error-property-assignment',
611
+ 'no-exports-in-scripts',
612
+ 'no-global-object-property-assignment',
613
+ 'no-incomplete-accessor-override',
614
+ 'no-incorrect-query-selector',
615
+ 'no-incorrect-template-string-interpolation',
616
+ 'no-ineffective-csp-directives',
617
+ 'no-invalid-argument-count',
618
+ 'no-invalid-boolean-attribute-value',
619
+ 'no-invalid-character-comparison',
620
+ 'no-invalid-fetch-options',
621
+ 'no-invalid-file-input-accept',
622
+ 'no-invalid-integrity',
623
+ 'no-invalid-intl-options',
624
+ 'no-invalid-property-descriptor',
625
+ 'no-invalid-remove-event-listener',
626
+ 'no-invalid-response-options',
627
+ 'no-invalid-temporal-arithmetic',
628
+ 'no-invalid-url-protocol-comparison',
629
+ 'no-invalid-well-known-symbol-methods',
630
+ 'no-keyword-prefix',
631
+ 'no-late-current-target-access',
632
+ 'no-late-event-control',
633
+ 'no-leading-empty-lines',
634
+ 'no-lonely-if',
635
+ 'no-loop-iterable-mutation',
636
+ 'no-magic-array-flat-depth',
637
+ 'no-manually-wrapped-comments',
638
+ 'no-mismatched-map-key',
639
+ 'no-misrefactored-assignment',
640
+ 'no-missing-local-resource',
641
+ 'no-multiple-promise-resolver-calls',
642
+ 'no-named-default',
643
+ 'no-negated-array-predicate',
644
+ 'no-negated-comparison',
645
+ 'no-negated-condition',
646
+ 'no-negation-in-equality-check',
647
+ 'no-nested-ternary',
648
+ 'no-new-buffer',
649
+ 'no-non-function-verb-prefix',
650
+ 'no-nonstandard-builtin-properties',
651
+ 'no-null',
652
+ 'no-object-as-default-parameter',
653
+ 'no-object-methods-with-collections',
654
+ 'no-optional-chaining-on-undeclared-variable',
655
+ 'no-prevent-default-in-passive-listener',
656
+ 'no-process-exit',
657
+ 'no-repeated-call-wrappers',
658
+ 'no-return-array-push',
659
+ 'no-selector-as-dom-name',
660
+ 'no-shorthand-property-overrides',
661
+ 'no-single-promise-in-promise-methods',
662
+ 'no-static-only-class',
663
+ 'no-subtraction-comparison',
664
+ 'no-thenable',
665
+ 'no-this-assignment',
666
+ 'no-this-outside-of-class',
667
+ 'no-top-level-assignment-in-function',
668
+ 'no-top-level-side-effects',
669
+ 'no-transition-all',
670
+ 'no-typeof-undefined',
671
+ 'no-uncalled-method',
672
+ 'no-undeclared-class-members',
673
+ 'no-unnecessary-array-flat-depth',
674
+ 'no-unnecessary-array-flat-map',
675
+ 'no-unnecessary-await',
676
+ 'no-unnecessary-boolean-comparison',
677
+ 'no-unnecessary-default-arguments',
678
+ 'no-unnecessary-fetch-options',
679
+ 'no-unnecessary-global-this',
680
+ 'no-unnecessary-nested-ternary',
681
+ 'no-unnecessary-parameters',
682
+ 'no-unnecessary-polyfills',
683
+ 'no-unnecessary-slice-end',
684
+ 'no-unnecessary-string-trim',
685
+ 'no-unreadable-array-destructuring',
686
+ 'no-unreadable-for-of-expression',
687
+ 'no-unreadable-iife',
688
+ 'no-unreadable-new-expression',
689
+ 'no-unreadable-object-destructuring',
690
+ 'no-unsafe-buffer-conversion',
691
+ 'no-unsafe-dom-html',
692
+ 'no-unsafe-json-serialization',
693
+ 'no-unsafe-promise-all-settled-values',
694
+ 'no-unsafe-property-key',
695
+ 'no-unsafe-sqlite-interpolation',
696
+ 'no-unsafe-string-replacement',
697
+ 'no-unused-builtin-method-return',
698
+ 'no-unused-iterator-helper',
699
+ 'no-unused-properties',
700
+ 'no-url-in-search-params',
701
+ 'no-useless-boolean-cast',
702
+ 'no-useless-collection-argument',
703
+ 'no-useless-compound-assignment',
704
+ 'no-useless-continue',
705
+ 'no-useless-delete-check',
706
+ 'no-useless-else',
707
+ 'no-useless-error-capture-stack-trace',
708
+ 'no-useless-fallback-in-spread',
709
+ 'no-useless-iterator-to-array',
710
+ 'no-useless-length-check',
711
+ 'no-useless-logical-operand',
712
+ 'no-useless-override',
713
+ 'no-useless-promise-resolve-reject',
714
+ 'no-useless-re-export',
715
+ 'no-useless-recursion',
716
+ 'no-useless-set-construction',
717
+ 'no-useless-spread',
718
+ 'no-useless-switch-case',
719
+ 'no-useless-template-literals',
720
+ 'no-using-resource-escape',
721
+ 'no-zero-fractions',
722
+ 'number-literal-case',
723
+ 'operator-assignment',
724
+ 'prefer-abort-signal-any',
725
+ 'prefer-abort-signal-timeout',
726
+ 'prefer-add-event-listener',
727
+ 'prefer-add-event-listener-options',
728
+ 'prefer-aggregate-error',
729
+ 'prefer-array-from-map',
730
+ 'prefer-array-from-range',
731
+ 'prefer-array-iterable-methods',
732
+ 'prefer-array-slice',
733
+ 'prefer-await',
734
+ 'prefer-bigint-literals',
735
+ 'prefer-blob-reading-methods',
736
+ 'prefer-block-statement-over-iife',
737
+ 'prefer-boolean-return',
738
+ 'prefer-class-fields',
739
+ 'prefer-classlist-toggle',
740
+ 'prefer-combined-guards',
741
+ 'prefer-continue',
742
+ 'prefer-direct-iteration',
743
+ 'prefer-dispose',
744
+ 'prefer-dom-node-append',
745
+ 'prefer-dom-node-html-methods',
746
+ 'prefer-dom-node-remove',
747
+ 'prefer-dom-node-replace-children',
748
+ 'prefer-dom-node-text-content',
749
+ 'prefer-early-return',
750
+ 'prefer-else-if',
751
+ 'prefer-event-target',
752
+ 'prefer-flat-math-min-max',
753
+ 'prefer-get-or-insert-computed',
754
+ 'prefer-global-number-constants',
755
+ 'prefer-global-this',
756
+ 'prefer-has-check',
757
+ 'prefer-hoisting-branch-code',
758
+ 'prefer-identifier-import-export-specifiers',
759
+ 'prefer-import-meta-properties',
760
+ 'prefer-iterable-in-constructor',
761
+ 'prefer-iterator-concat',
762
+ 'prefer-iterator-to-array',
763
+ 'prefer-iterator-to-array-at-end',
764
+ 'prefer-json-import',
765
+ 'prefer-location-assign',
766
+ 'prefer-math-abs',
767
+ 'prefer-math-constants',
768
+ 'prefer-math-min-max',
769
+ 'prefer-minimal-ternary',
770
+ 'prefer-modern-dom-apis',
771
+ 'prefer-object-destructuring-defaults',
772
+ 'prefer-observer-apis',
773
+ 'prefer-options-parameter',
774
+ 'prefer-path2d',
775
+ 'prefer-private-class-fields',
776
+ 'prefer-promise-static-methods',
777
+ 'prefer-promise-try',
778
+ 'prefer-promise-with-resolvers',
779
+ 'prefer-prototype-methods',
780
+ 'prefer-query-selector',
781
+ 'prefer-queue-microtask',
782
+ 'prefer-response-static-json',
783
+ 'prefer-scoped-selector',
784
+ 'prefer-short-arrow-method',
785
+ 'prefer-short-escape-sequences',
786
+ 'prefer-simple-condition-first',
787
+ 'prefer-simplified-conditions',
788
+ 'prefer-single-array-predicate',
789
+ 'prefer-single-call',
790
+ 'prefer-single-object-destructuring',
791
+ 'prefer-smaller-scope',
792
+ 'prefer-split-limit',
793
+ 'prefer-switch',
794
+ 'prefer-ternary',
795
+ 'prefer-then-catch',
796
+ 'prefer-toggle-attribute',
797
+ 'prefer-type-error',
798
+ 'prefer-type-literal-last',
799
+ 'prefer-unary-minus',
800
+ 'prefer-url-can-parse',
801
+ 'prefer-url-href',
802
+ 'prefer-while-loop-condition',
803
+ 'relative-url-style',
804
+ 'require-array-join-separator',
805
+ 'require-css-escape',
806
+ 'require-module-attributes',
807
+ 'require-module-specifiers',
808
+ 'require-number-to-fixed-digits-argument',
809
+ 'require-passive-events',
810
+ 'require-proxy-trap-boolean-return',
811
+ 'require-spread-parentheses',
812
+ 'require-text-decoder-streaming',
813
+ 'single-line-block-comment-style',
814
+ 'switch-case-braces',
815
+ 'switch-case-break-position',
816
+ 'template-indent',
817
+ 'text-encoding-identifier-case',
818
+ 'throw-new-error',
819
+ 'try-complexity',
820
+ ]);
821
+
486
822
  // ── MSO / Outlook email rule configs (auto-included, no separate plugin load) ──
487
823
 
488
824
  /**
@@ -877,7 +1213,7 @@ plugin.configs = {
877
1213
  // ── Required overrides when eslint-plugin-unicorn covers SSJS ────────────
878
1214
 
879
1215
  /**
880
- * REQUIRED when unicorn covers standalone `.ssjs` files: turns off the 60
1216
+ * REQUIRED when unicorn covers standalone `.ssjs` files: turns off the 88
881
1217
  * unicorn recommended rules incompatible with SFMC SSJS. Plain rules object with NO
882
1218
  * `plugins` key — eslint-plugin-sfmc does not load unicorn. Insert this object
883
1219
  * AFTER your own unicorn config (which registers the `unicorn` plugin);
@@ -891,7 +1227,7 @@ plugin.configs = {
891
1227
  },
892
1228
 
893
1229
  /**
894
- * REQUIRED when unicorn covers SSJS embedded in HTML: same 60-rule override
1230
+ * REQUIRED when unicorn covers SSJS embedded in HTML: same 88-rule override
895
1231
  * for virtual `**\/*.html/*.js` files. Insert AFTER your unicorn config.
896
1232
  * Omit this config if unicorn is not enabled for embedded SSJS.
897
1233
  */
@@ -902,4 +1238,42 @@ plugin.configs = {
902
1238
  },
903
1239
  };
904
1240
 
1241
+ /**
1242
+ * One-line unicorn setup for SSJS (standalone `.ssjs` and SSJS embedded in
1243
+ * HTML). Pass the `eslint-plugin-unicorn` object you import and spread the
1244
+ * result after your own unicorn config:
1245
+ *
1246
+ * ...sfmc.unicornSsjs(eslintPluginUnicorn)
1247
+ *
1248
+ * Every rule of the given unicorn version is turned off unless the newest
1249
+ * audit marked it safe for SSJS and no supported audit marked it off; the
1250
+ * rules audited as safe keep whatever your unicorn config sets.
1251
+ * Only `'off'` is written, so a rule missing from an older or newer unicorn
1252
+ * never causes a "Could not find rule" error.
1253
+ *
1254
+ * @param {{ rules: object }} unicorn - The imported eslint-plugin-unicorn plugin.
1255
+ * @returns {object[]} Flat config objects to spread into the config array.
1256
+ */
1257
+ plugin.unicornSsjs = function unicornSsjs(unicorn) {
1258
+ if (!unicorn || typeof unicorn.rules !== 'object' || unicorn.rules === null) {
1259
+ throw new TypeError(
1260
+ 'sfmc.unicornSsjs(unicorn) expects the imported eslint-plugin-unicorn plugin',
1261
+ );
1262
+ }
1263
+ const rules = {};
1264
+ for (const name of Object.keys(unicorn.rules)) {
1265
+ if (!unicornSsjsActiveRules.has(name)) {
1266
+ rules[`unicorn/${name}`] = 'off';
1267
+ }
1268
+ }
1269
+ return [
1270
+ {
1271
+ name: 'sfmc/unicorn-ssjs-allowlist',
1272
+ files: ['**/*.ssjs', '**/*.html/*.js'],
1273
+ plugins: { unicorn },
1274
+ rules,
1275
+ },
1276
+ ];
1277
+ };
1278
+
905
1279
  export default plugin;
@@ -49,7 +49,7 @@ function staticLiteralValue(argument) {
49
49
  * @param {string | number | boolean} actual - Static AMPscript literal value.
50
50
  * @returns {boolean} Whether the values match with type-sensitive semantics.
51
51
  */
52
- function enumValueMatches(allowed, actual) {
52
+ function isEnumValueMatch(allowed, actual) {
53
53
  if (typeof allowed !== typeof actual) {
54
54
  return false;
55
55
  }
@@ -108,7 +108,7 @@ export default {
108
108
  continue;
109
109
  }
110
110
  const isAllowed = parameter.enum.some((value) =>
111
- enumValueMatches(value, actual),
111
+ isEnumValueMatch(value, actual),
112
112
  );
113
113
  if (!isAllowed) {
114
114
  context.report({
@@ -58,11 +58,12 @@ export default {
58
58
  };
59
59
 
60
60
  function hasMemberLength(node) {
61
- return node
62
- ? node.type === 'MemberExpression' &&
63
- node.property.type === 'Identifier' &&
64
- node.property.name === 'length'
65
- : false;
61
+ return (
62
+ Boolean(node) &&
63
+ node.type === 'MemberExpression' &&
64
+ node.property.type === 'Identifier' &&
65
+ node.property.name === 'length'
66
+ );
66
67
  }
67
68
 
68
69
  function buildCacheFix(forNode, lengthExpression, context) {
@@ -65,10 +65,11 @@ function isHttpConstructorMember(node) {
65
65
  * @returns {boolean} Whether the expression yields an HTTP request instance
66
66
  */
67
67
  function isHttpRequestInit(node) {
68
- return node
69
- ? (node.type === 'NewExpression' || node.type === 'CallExpression') &&
70
- isHttpConstructorMember(node.callee)
71
- : false;
68
+ return (
69
+ Boolean(node) &&
70
+ (node.type === 'NewExpression' || node.type === 'CallExpression') &&
71
+ isHttpConstructorMember(node.callee)
72
+ );
72
73
  }
73
74
 
74
75
  /**
@@ -73,10 +73,11 @@ function isHttpConstructorMember(node) {
73
73
  * @returns {boolean} Whether the expression yields an HTTP request instance
74
74
  */
75
75
  function isHttpRequestInit(node) {
76
- return node
77
- ? (node.type === 'NewExpression' || node.type === 'CallExpression') &&
78
- isHttpConstructorMember(node.callee)
79
- : false;
76
+ return (
77
+ Boolean(node) &&
78
+ (node.type === 'NewExpression' || node.type === 'CallExpression') &&
79
+ isHttpConstructorMember(node.callee)
80
+ );
80
81
  }
81
82
 
82
83
  export default {
@@ -58,10 +58,11 @@ function isHttpConstructorMember(node) {
58
58
  * @returns {boolean} Whether the expression yields an HTTP request instance
59
59
  */
60
60
  function isHttpRequestInit(node) {
61
- return node
62
- ? (node.type === 'NewExpression' || node.type === 'CallExpression') &&
63
- isHttpConstructorMember(node.callee)
64
- : false;
61
+ return (
62
+ Boolean(node) &&
63
+ (node.type === 'NewExpression' || node.type === 'CallExpression') &&
64
+ isHttpConstructorMember(node.callee)
65
+ );
65
66
  }
66
67
 
67
68
  /**
@@ -27,7 +27,7 @@ import { notDefinedAtRuntimeGlobalLookup } from 'ssjs-data';
27
27
  */
28
28
  function replacementFor(entry) {
29
29
  const source = `${entry.officialDocsNote ?? ''} ${entry.description ?? ''}`;
30
- const match = source.match(/Platform\.[A-Za-z.]+\([^)]*\)/);
30
+ const match = /Platform\.[A-Za-z.]+\([^)]*\)/.exec(source);
31
31
  return match ? match[0] : 'a supported alternative';
32
32
  }
33
33
 
@@ -44,21 +44,18 @@ export default {
44
44
  function isTreatAsContentCall(node) {
45
45
  const callee = node.callee;
46
46
 
47
- // TreatAsContent(...)
48
- if (callee.type === 'Identifier' && callee.name === 'TreatAsContent') {
49
- return true;
50
- }
51
-
52
- // Platform.Function.TreatAsContent(...)
53
47
  return (
54
- callee.type === 'MemberExpression' &&
55
- callee.property.type === 'Identifier' &&
56
- callee.property.name === 'TreatAsContent' &&
57
- callee.object.type === 'MemberExpression' &&
58
- callee.object.property.type === 'Identifier' &&
59
- callee.object.property.name === 'Function' &&
60
- callee.object.object.type === 'Identifier' &&
61
- callee.object.object.name === 'Platform'
48
+ // TreatAsContent(...)
49
+ (callee.type === 'Identifier' && callee.name === 'TreatAsContent') ||
50
+ // Platform.Function.TreatAsContent(...)
51
+ (callee.type === 'MemberExpression' &&
52
+ callee.property.type === 'Identifier' &&
53
+ callee.property.name === 'TreatAsContent' &&
54
+ callee.object.type === 'MemberExpression' &&
55
+ callee.object.property.type === 'Identifier' &&
56
+ callee.object.property.name === 'Function' &&
57
+ callee.object.object.type === 'Identifier' &&
58
+ callee.object.object.name === 'Platform')
62
59
  );
63
60
  }
64
61
 
@@ -229,10 +229,7 @@ export default {
229
229
  }
230
230
 
231
231
  // ── Prototype methods with NO polyfill: .trimStart(), .flat(), … ─
232
- if (!knownUnsupportedByPrototypeName.has(lowerMethod)) {
233
- return;
234
- }
235
- if (ignored.has(methodName)) {
232
+ if (!knownUnsupportedByPrototypeName.has(lowerMethod) || ignored.has(methodName)) {
236
233
  return;
237
234
  }
238
235
  // Skip known SFMC top-level objects to avoid false positives.
@@ -240,6 +237,11 @@ export default {
240
237
  return;
241
238
  }
242
239
  const entry = knownUnsupportedByPrototypeName.get(lowerMethod);
240
+ // Missing globals (Set, URL, Promise, …) are not methods: obj.set() or
241
+ // obj.url() is a call on the user's own object, not on the global.
242
+ if (entry.owner === 'Global' || entry.owner === 'GlobalValues') {
243
+ return;
244
+ }
243
245
  pendingReports.push({ node: property, entry, noPolyfill: true });
244
246
  },
245
247