70 %
Chris Biscardi

Starting a new Node project

How I start new projects.

shell
yarn init -y
// set up workspaces in the root to point at packages/*
mkdir packages
yarn add lint-staged prettier husky jest

Initializing a new project

I use yarn for all my projects these days, and I have my yarnrc shortcuts set up so I use

shell
yarn init -y

Yarn workspaces

I've learned that many projects benefit from a multi-package repo setup from the beginning, and it's very little overhead to do it, so I add the following to package.json, and make a packages directory.

JS
{
private: true,
"workspaces": [ "packages/*" ]
}

Code formatting

JS doesn't come with a formatting tool like go fmt or rust, so I install and configure prettier to run on everything I care about. This usually involves lint-staged as well.

shell
yarn add prettier lint-staged husky

Testing

Jest is the best-in-class test runner with support for multiple "projects" which interacts quite well with multi-package repos.

shell
yarn add jest

Releasing

Because we're in a multi-package yarn workspaces repo, we can use changesets to handle releases, including their github action.