From a2d264a04bd965b09ec37880418bc506f4834750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Berkefeld?= Date: Tue, 19 May 2020 15:28:47 +0200 Subject: [PATCH] added advise on how to use prettier --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index a772266..37b0a21 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,30 @@ To use SSJS in conjunction with ESLint's recommended rule set, extend with both, } ``` +## Using Prettier with SSJS + +Starting with version 2.x of prettier, the plugin automatically has "trailingComma" set to "es5". That's a problem because SSJS actually does not support this. + +Also, SFMC tends to remove all tabs when you save queries, scripts, code snippets, emails and cloud pages. We hence strongly recommend to set `useTabs` to `false` and define `tabWidth` according to your liking (2 or 4 are typical values). + +Add the following to your `.prettierrc` file to ensure the above concerns are adressed: + +```json +{ + "useTabs": false, + "tabWidth": 4, + "singleQuote": true, + "overrides": [ + { + "files": "*.ssjs", + "options": { + "trailingComma": "none" + } + } + ] +} +``` + ## Using the .ssjs extension in VSCode Make sure you associate `*.ssjs` with JavaScript in your IDE. That should automatically enable linting via ESLint.