@tofrankie/commitlint
v0.0.6
Published
Shared Commitlint configuration
Maintainers
Readme
@tofrankie/commitlint
Shared commitlint configuration.
[!IMPORTANT] Before 1.0.0, releases may include breaking changes. Read the CHANGELOG before upgrading.
Quick Start
Install dependencies:
$ pnpm add @commitlint/cli @tofrankie/commitlint -DCreate a commitlint.config.js in your project root:
export default {
extends: ['@tofrankie/commitlint'],
}See the Commitlint rules reference for all rule options.
Example: custom scope-enum:
export default {
extends: ['@tofrankie/commitlint'],
rules: {
'scope-enum': [2, 'always', ['foo', 'bar']],
},
}Using with simple-git-hooks and lint-staged
Install dependencies:
$ pnpm add simple-git-hooks lint-staged -DAdd simple-git-hooks to package.json:
{
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged",
"commit-msg": "pnpm commitlint --edit $1"
}
}After you change this configuration, run:
$ npx simple-git-hooksAdd lint-staged.config.js to the project root:
export default {
'*.{js,ts,jsx,tsx,vue}': ['eslint --fix', 'prettier --write'],
'*.{json,md,yaml,html}': ['prettier --write'],
'*.wxml': ['prettier --write', 'stylelint --fix'],
'*.{css,scss,less,wxss}': ['prettier --write', 'stylelint --fix'],
}Adjust the globs to match the file types you lint. See lint-staged configuration for more.
Using with Husky and lint-staged
Install dependencies:
$ pnpm add husky lint-staged -DAdd Husky to package.json:
{
"scripts": {
"prepare": "husky"
}
}Add lint-staged.config.js to the project root (same as above).
Add a pre-commit hook:
$ echo 'pnpm lint-staged' > .husky/pre-commitFor a full-project lint, use
pnpm lintor whatever script you define inpackage.json.
Add a commit-msg hook:
$ echo 'pnpm commitlint --edit "$1"' > .husky/commit-msgOther
Skipping hooks
Use -n / --no-verify to skip Git hooks:
$ git commit -m "commit message" --no-verifyUse HUSKY=0 to skip Husky:
$ HUSKY=0 git commit -m "commit message"Use SKIP_SIMPLE_GIT_HOOKS=1 to skip simple-git-hooks:
$ SKIP_SIMPLE_GIT_HOOKS=1 git commit -m "commit message"To skip hooks for multiple commits in a row, export an environment variable:
$ export HUSKY=0 # Disables all Git hooks
$ git commit -m "first commit"
$ git commit -m "second commit"
$ unset HUSKY # Re-enables hooks
$ git commit -m "third commit"The same applies to simple-git-hooks.
