Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Suggestions: JavaScript

Ron Waldon edited this page Feb 3, 2017 · 7 revisions

Suggestions: JavaScript

Maintainability, Sustainability

  • Write code in strict mode by having 'use strict' at the top of your script file

    • Note that code imported in ES2015 is always interpreted as strict-mode
  • Extract shared logic out into separate files, and use a module system so that you can require() as needed

  • Keep credentials and other environment variables out of your code. See dotenv or similar approaches

  • Consider keeping integration functions (e.g. network requests, libraries) separate from processing functions (e.g. transformations, data traversal) in order to make them easier to test

  • Consider writing automated tests with one of the following test frameworks or similar: ava, jest, mocha, tape

  • Lint your code for common mistakes and anti-patterns by using ESLint with its recommended rules at a minimum

Convenient HTTP Requests

Here are our favourite ways of making HTTP requests with JavaScript:

Front-End

See Also