Skip to content

Latest commit

 

History

History
53 lines (42 loc) · 983 Bytes

best-practices.md

File metadata and controls

53 lines (42 loc) · 983 Bytes

Javascript / Best practices

Comment dependencies in the package.json

As described here and here. E.g.

{
  "//dependencies": {
    "crypto-exchange": "Unified exchange API"
  },
  "dependencies": {
    "crypto-exchange": "^2.3.3"
  },
  "//devDependencies": {
    "chai": "Assertions",
    "mocha": "Unit testing framwork",
    "sinon": "Spies, Stubs, Mocks",
    "supertest": "Test requests"
  },
  "devDependencies": {
    "chai": "^4.1.2",
    "mocha": "^4.0.1",
    "sinon": "^4.1.3",
    "supertest": "^3.0.0"
  }
}

Serialize objects when concatenating to strings

GOOD

const obj = {
  // ...
};

console.log("Uh! " + JSON.stringify(obj);

// => Uh! { ... }

BAD

const obj = {
  // ...
};

console.log("Uh! " + obj);

// => Uh! [object Object]