Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
136 lines (102 sloc) 2.92 KB

Best Practices

When starting a new project

  • Use Lerna
  • Use typescript
  • Use eslint
  • Use prettier
  • Use jest
  • Use husky
    • Used to lint files



npx lerna init
leran bootstrap --npm-client=yarn --use-workspaces

Update lerna.json

{% code-tabs %} {% code-tabs-item title="lerna.json" %}

  "npmClient": "yarn",
  "useWorkspaces": "true"

{% endcode-tabs-item %} {% endcode-tabs %}


yarn install

Update package.json

{% code-tabs %} {% code-tabs-item title="package.json" %}

  "scripts": {
    "lint": "yarn run lerna run lint"
  "workspaces": ["packages/*"]

{% endcode-tabs-item %} {% endcode-tabs %}

package.json when creating a new package:

{% code-tabs %} {% code-tabs-item title="packages/new-package/package.json" %}

  "name": "new-package",
  "private": true,
  "version": "0.0.0"

{% endcode-tabs-item %} {% endcode-tabs %}

Package Management

Each package manages it's own typescript and eslint.

For example, at the root directory.

yarn lerna run lint

Use JSON5 over JSON

The JSON5 Data Interchange Format (JSON5) is a superset of JSON that aims to alleviate some of the limitations of JSON by expanding its syntax to include some productions from ECMAScript 5.1.

yarn add json5

JSON5 Short Example:

  // comments
  unquoted: 'and you can quote me on that',
  singleQuotes: 'I can use "double quotes" here',
  lineBreaks: "Look, Mom! \
No \\n's!",
  newLine: "1\n\
  hexadecimal: 0xdecaf,
  leadingDecimalPoint: .8675309, andTrailing: 8675309.,
  positiveSign: +1,
  trailingComma: 'in objects', andIn: ['arrays',],
  "backwardsCompatible": "with JSON",

Package Recommendations

commander: command-line arguments

yarn add commander


fs-extra adds file system methods that aren't included in the native fs module and adds promise support to the fs methods. It also uses graceful-fs to prevent EMFILEerrors. It should be a drop in replacement for fs.

yarn add fs-extra
You can’t perform that action at this time.