Skip to content

Formatting for JS/SSJS files

Would be nice to be able to use a built-in or external formatting tool for the .js and .ssjs files.

I would propose that we use prettier with the following settings for this.

tabWidth: 4
useTabs: true
singleQuote: true
trailingComma: "es5"

The main issue is the use of "for each" is not understood, as it's deprecated and didn't make it into the language spec.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/For-each-in_loops_are_deprecated

As an intermediate step, with polyfills updated, could use. Object.keys, Object.entries, Object.values with Array.prototype.forEach iteration. Which isn't as efficient as a regular for-loop, but would allow for consistent linting and formatting to be added (as well as autoformatting in supportive editors).