Nest 14 App
nest new project-name

npm install --save-dev husky lint-staged @commitlint/{cli,config-conventional} eslint-plugin-import-helpers
Development Dependencies for Nest
--save-dev: Saves dependencies only for the development environment.
husky: Tool to create Git hooks, helping automate tasks before committing.
lint-staged: Runs linters on staged files in Git.
@commitlint/cli: Command-line tool to ensure commit messages follow a conventional standard.
@commitlint/config-conventional: Configuration for commitlint to follow the conventional commit message format.
eslint-plugin-import-helpers: ESLint plugin to automatically order imports.
Eslint Config
Yo can use the configuration that was generated by the CLI.
Or generate a
.eslintrc.js
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin','prettier' ,'eslint-plugin-import-helpers'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'prettier'
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'prettier/prettier': ['error'],
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
"import-helpers/order-imports": [
"warn",
{
newlinesBetween: "always",
groups: [
["/^next/", "module"],
"/@styles/",
"/@components/",
"/@lib/",
["parent", "sibling", "index"],
],
alphabetize: { order: "asc", ignoreCase: true },
},
],
},
};
Prettier Config
Yo can use the configuration that was generated by the CLI.
Or generate a
prettier.config.js
{
"singleQuote": true,
"trailingComma": "all"
}
Commitlint Config
Generate a file with the following content:
commitlint.config.js
module.exports = { extends: ["@commitlint/config-conventional"] };
Husky
Execute a
npx husky install
Generate a husky folder
pre-commit
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged
Generate a husky folder
commit-msg
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx --no -- commitlint --edit
Package.json
Add in file with the following content:
package.json
"prepare": "husky install"
Lint Staged Config
Add in file with the following content:
.lintstagedrc
{
"**/*.{js,jsx,ts,tsx}": ["npm run format", "npm run lint"]
}
Ignore Eslint
Add in file with the following content:
.eslintignore
dist
package-lock.json
husky
configs
env
public
server.js
jsconfig.json
package.json
public
README.md
.eslintrc
.eslintrc.json
.eslintrc.js
.prettierrc.json
.eslint*
commitlint.config.js
next-env.d.ts
postcss.config.js
prettier.config.js
Ignore Prettier
Add in file with the following content:
.prettierignore
dist
package-lock.json
configs
env
husky
public
server.js
jsconfig.json
package.json
public
README.md
.eslintrc
.eslintrc.json
.eslintrc.js
.prettierrc.json
commitlint.config.js
next-env.d.ts
postcss.config.js
commitlint.config.js
prettier.config.js