Skip to main content

Premail code style and syntax

Premail uses Husky, internally to format and lint code using Prettier on every git commit. (Prettier is also used on the end-user side, without Husky.)

The following config options are set:

  • JavaScript uses Standard Style. We are in the process of upgrading to ES Module syntax.
  • For Gulp tasks, we use version 4 syntax with pipeline(), not .pipe. Instead of using one-off gulp wrappers, we use gulp-tap to pass streams as files.
  • Handlebars processing happens first in the build process, thus all templates are named as Handlebars files. Within these templates, you will also see MJML, which will be processed second.
  • MJML should always be valid under version 4. Use the MJML Try It Live website to test if necessary.
  • Sass files use the SCSS syntax to make it easiest on end-users. It is compiled with Dart Sass and uses node-sass-json-importer (which does, in fact, work with Dart Sass) to import variables from configuration files into the Sass files. Because of how Sass maps work, YAML objects need to defined and passed separately. See src/config/sassImport.js and the sass() function in src/tasks/build.js for the implementation.
  • YAML and Markdown files are wrapped when possible at 80 characters. This is enforced with Prettier.
  • Indents are 2 spaces, enforced with .editorconfig.