prettier-plugin-sfmc 0.4.0 → 0.4.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/printer.js +10 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prettier-plugin-sfmc",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Prettier plugin for Salesforce Marketing Cloud — AMPscript, SSJS, and SQL formatting",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/printer.js CHANGED
@@ -370,7 +370,11 @@ function printAmpscriptNode(path, options, print) {
370
370
  for (const altDocument of altDocs) {
371
371
  parts.push(altDocument);
372
372
  }
373
- parts.push([hardline, kw('endif', okw.endif)]);
373
+ // Only emit endif when the parser saw it in this block (cross-block
374
+ // IF/ENDIF spans multiple %%[ ]%% segments; missing endif is intentional).
375
+ if ('endif' in okw) {
376
+ parts.push([hardline, kw('endif', okw.endif)]);
377
+ }
374
378
  return parts;
375
379
  }
376
380
 
@@ -426,7 +430,11 @@ function printAmpscriptNode(path, options, print) {
426
430
  if (node.body.length > 0) {
427
431
  parts.push(indent([hardline, join(hardline, path.map(print, 'body'))]));
428
432
  }
429
- parts.push([hardline, kw('next', okw.next), ' ', counterDocument]);
433
+ // Only emit next when the parser saw it in this block (cross-block
434
+ // FOR/NEXT spans multiple %%[ ]%% segments; missing next is intentional).
435
+ if ('next' in okw) {
436
+ parts.push([hardline, kw('next', okw.next), ' ', counterDocument]);
437
+ }
430
438
  return parts;
431
439
  }
432
440