⚙ The Angular project's config files

⚙ The Angular project's config files

Config files

The angular project comes with some config files ending with "rc" for "runcom/run commands". Those files are required to setup environment variables when running commands with those specific tools such as:

  • Husky

  • npm

  • node version manager (nvm)

  • eslint

  • prettier

  • lint-staged

  • conventional commit

Husky

Modern native git hooks made it easy to improve your commits and more.

  • lint commit messages

  • run tests

  • prettier and lint code when committing or pushing

Links

Settings

It requires the .git file position to install

/* package.json */
// for mono-repo 
"prepare": "cd .. && husky install swipe-cs/.husky" 
// for separate front/back repo 
"prepare": "husky install" 
// install in custom directory 
"prepare": "husky install .config/husky"

Bypass hooks with tag --no-verify

git commit -m "yolo!" --no-verify

OR HUSKY=0 git push # yolo! inside the husky.sh script

if [ "$HUSKY" = "0" ]; then debug "HUSKY env variable is set to 0, skipping hook"

hooks filename important

  • commit-msg

  • pre-commit

  • pre-push

inside hooks files you can:

  • run locally installed binary

  • npx --no-install lint-staged

  • npx --no-install commitlint --edit $1 ($1 = commit message)

npm: Node Package Manager

npm is the world's largest software registry. Open source developers from every continent use npm to share and borrow packages, and many organizations use npm to manage private development as well.

The .npmrc file defines the settings on how NPM should behave when running commands

Links

Settings

3 levels of settings

  1. The command line by passing a setting with the NPM command you want to run.

  2. Through ENV variables

  3. .npmrc or npm config command

Files: The four relevant files are:

  1. per-project config file (/path/to/my/project/.npmrc)

  2. per-user config file (~/.npmrc)

  3. global config file ($PREFIX/etc/npmrc)

  4. npm builtin config file (/path/to/npm/npmrc)

nvmrc: Node Version Manager

Nvm allows you to quickly install and use different versions of node via the command line.

The file .nvmrc is a compliant bash script to manage multiple active node.js versions

Links

Example

$ nvm use 16 
Now using node v16.9.1 (npm v7.21.1) 
$ node -v 
v16.9.1 
$ nvm use 14 
Now using node v14.18.0 (npm v6.14.15) 
$ node -v 
v14.18.0 
$ nvm install 12 
Now using node v12.22.6 (npm v6.14.5) 
$ node -v 
v12.22.6

Eslint

The config files are .eslintrc and .eslintignore

Links

Settings

/* package.json */
"lint": "ng lint",
"lint": "eslint . --ext .ts",
"lint-and-fix": "eslint . --ext .ts --fix"

Prettier

The config files are .prettierrc .prettierignore

Links

Settings

/* package.json */
"format": "prettier --write "src/**/*"", 
"formatconf": "prettier --write *",

/* prettierrc */
"endOfLine": "auto" // to avoid "crlf" issues when using lint-staged

Lint Staged

🚫💩 — Run linters on git staged files. The config file is .lintstagedrc

link

Conventional commit

The config file is .czrc

Links

settings

{ "path": "cz-conventional-changelog" }

This just tells Commitizen which adapter we want our contributors to use when they try to commit to this repo.