There are many small ways to ensure a front-end project is kept consistent amongst developers. Prettier is one way of ensuring code is formatted correctly.
Files such as .nvmrc and .npmrc help lock the node version and ensure there are no conflicts with the version of the Node used with NPM packages.
There files are known as configuration files and can be named as prettier.config.js
for example.
The prettier file can allow you to write a set of rules, such as only single quotes, tab space of two, to standardise the formatting of code across a project.
The nvmrc specifies the node version the project uses and does not allow users to upgrade the node version.
When working on a project with multiple users there can be many merge conflicts with package-lock
. An .npmrc file can help maintain Node modules with the verison of Node the application is using.
yarn add prettier --save-dev
touch .prettierrc
(in the root of your project)
Navigate to your .prettierrc file and add any rules
For example:
semi: false
tabWidth: 4
Nvm must first be set up on the machine being used. To find out more about how to set up nvm on a machine check out this link.
nvm use
nvm install
nvm exec
nvm run
nvm which
Create a .npmrc
file in the root of the project.
Here is a small example of what could be included in this file:
engine-strict=true