umma.dev

Config in Front End

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.

Whare is a .prettierrc/.nvmrc/.npmrc File?

There files are known as configuration files and can be named as prettier.config.js for example.

What Do These Files Do?

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.

.prettierrc

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

.nvmrc

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.

Set Up

Once nvm has been set up, add a file called .nvrmc in the root of the project. Specify the number of the version of Node to be used in the project.
nvm use
nvm install
nvm exec
nvm run
nvm which

.npmrc

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