We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Formatting

Automated code formatting keeps your code consistent and readable. It's also a great way to avoid arguments about code style (bikeshedding).

I almost never start a new project without enforcing automated code formatting.

For example, this is technically valid:

function welcome() {
	console.log("hello world!") }

But it's not formatted according to standard conventions. You would normally write it like this:

function welcome() {
  console.log("hello world!");
}

Prettier

We're going to use Prettier to format our code. It's a popular package that will format our code automatically.

Assignment

npm install -D --save-exact prettier
    "format:write": "prettier --write \"src/**/*.{js,ts,json,css,md}\"",
    "format:check": "prettier --check \"src/**/*.{js,ts,json,css,md}\""

If you're using VS Code, you can use the Prettier extension to auto-format your code on save. But you don't need that unless you like it (I can't live without format-on-save). The default "Notely" project should already be formatted properly, but the tests we added previously will likely need to be formatted.

Run and submit the CLI tests from the root of your repo.