Installation and setup
- Run the command:
yarn add -D @lightech-llc/eslint-config-angular
yarn add -D @commitlint/config-conventional
yarn add -D husky
husky install
husky instal
command will add directory .husky
, create there 2 files:
cd .husky/
husky add pre-commit
husky add commit-msg
- pre-commit:
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged
- commit-msg:
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx commitlint --edit $1
- Add
tsconfig.eslint.json
file:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": ".",
"baseUrl": ".",
"strict": false,
"incremental": true
},
"include": ["src", "projects"],
"exclude": ["**/node_modules", "**/schematics/**", "**/.*/", "*.js"]
}
- Add
.eslintrc.js
file:
/**
* @type {import('eslint').Linter.Config}
*/
module.exports = {
root: true,
extends: ['@lightech-llc/eslint-config-angular'],
ignorePatterns: [
'e2e',
'src/**/test.ts',
'src/**/main.ts',
'src/**/polyfills.ts',
'*.js',
'*.json',
'*.scss',
'*.md',
],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
project: [require.resolve('./tsconfig.eslint.json')],
},
parser: '@typescript-eslint/parser',
};
- Add
commitlint.config.js
file:
module.exports = { extends: ['@commitlint/config-conventional'] };
- Add
.lintstagedrc.js
file:
module.exports = {
'*.{js,ts,html,md,scss,json}': ['npm run lint -- --fix', 'prettier --write', 'git add'],
'*.scss': ['stylelint --fix', 'git add'],
};
- Add next scripts to
package.json
:
"scripts": {
"lint": "eslint ."
}