UNPKG

eslint-config-heyitsbash

Version:

"ESlint & Prettier Config by heyitsbash"

65 lines (48 loc) 1.62 kB
# Heyitsbash config for EZ linting ## Local Install 1. In your project folder type `npm init` , and 2. `npx install-peerdeps --dev eslint-config-heyitsbash` 3. Create `.eslintrc.js` file in the root of your projects folder 4. Copy this in `.eslintrc.js` ```js module.exports = { 'extends': [ 'heyitsbash', ] }; ``` Add these scripts in `package.json` ```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 1. Run `npm install husky --save-dev` to make sure husky is installed properly 2. Create `commitlint.config.js` file in the root of your projects folder 3. Paste that in `commitlint.config.js` ```js module.exports = { extends: ['@commitlint/config-conventional'], rules: { 'subject-min-length': [2, 'always', 10], } }; ``` Add these lines in `package.json` ```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: 1. `git commit -m "random commit bla bla bla"` - this line will fail by conventional commit rules. 2. `git commit -m "chore: test commit with new modules"` - this line will pass by conventional commit rules.