Heyitsbash config for EZ linting
Local Install
- In your project folder type
npm init
, and npx install-peerdeps --dev eslint-config-heyitsbash
- Create
.eslintrc.js
file in the root of your projects folder - Copy this in
.eslintrc.js
module.exports = {
'extends': [
'heyitsbash',
]
};
Add these scripts in package.json
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix"
},
Lint/pretty your code by running npm run lint
and npm run lint:fix
in the console
Now linting for commit also available
- Run
npm install husky --save-dev
to make sure husky is installed properly - Create
commitlint.config.js
file in the root of your projects folder - Paste that in
commitlint.config.js
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'subject-min-length': [2, 'always', 10],
}
};
Add these lines in package.json
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-commit": "npm run lint:fix && git add ."
}
}
Now all your commits will first be checked by linter rules and then with conventional commit rules, if any of these fail - changes will not get commited.
Be aware that this line in husky hook git add .
will always stage all files, if you not commiting all your files at once, you should remove it.
Commit example:
-
git commit -m "random commit bla bla bla"
- this line will fail by conventional commit rules. -
git commit -m "chore: test commit with new modules"
- this line will pass by conventional commit rules.