-
Notifications
You must be signed in to change notification settings - Fork 1
Suggestions: JavaScript
-
Write code in strict mode by having
'use strict'
at the top of your script file- Note that code
import
ed in ES2015 is always interpreted as strict-mode
- Note that code
-
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
Here are our favourite ways of making HTTP requests with JavaScript:
-
browser:
fetch()
(built-in) -
Node.js: node-fetch (like browsers'
fetch()
)
- use hash-based routing in Cordova / webview apps, and consider using hash-based routing for web apps, too