Types of commit:
- feat: Add a new feature (equivalent to a MINOR in Semantic Versioning).
- fix: Fix a bug (equivalent to a PATCH in Semantic Versioning).
- docs: Documentation changes.
- style: Code style change (semicolon, indentation...).
- refactor: Refactor code without changing public API.
- perf: Update code performances.
- test: Add test to an existing feature.
- chore: Update something without impacting the user (ex: bump a dependency in package.json).
Examples
fix(docs): remove stub URL and tweak language feat(ratings): add the ability to add star ratings to posts. fix(docs): add labels to first relevant example refactor(gatsby): restrict actions available in Node APIs feat(gatsby-cli): Add a plugin authoring help in gatsby-cli
Simpler Examples
chore: add Oyster build script docs: explain hat wobble feat: add beta sequence fix: remove broken confirmation message refactor: share logic between 4d3d3d3 and flarhgunnstow style: convert tabs to spaces test: ensure Tayne retains clothing
More complete example
git commit -m "feat(ratings): add ability to add star ratings to posts. This has been a feature requested by different users. Changes in the database structure where necessary to make this happen. closes #105"
Pseudo
/^(revert: )?(feat|fix|docs|style|refactor|perf|test|chore)((.+))?: .{1,50}/
Hook Script Validation
npm install --save-dev @commitlint/cli @commitlint/config-conventional npx husky add .husky/commit-msg 'npx --no-install commitlint --edit $1'
commitlint.config.js module.exports = { parserPreset: 'conventional-changelog-conventionalcommits', rules: { 'body-leading-blank': [1, 'always'], 'body-max-line-length': [2, 'always', 100], 'footer-leading-blank': [1, 'always'], 'footer-max-line-length': [2, 'always', 100], 'header-max-length': [2, 'always', 100], 'scope-case': [2, 'always', 'lower-case'], 'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']], 'subject-empty': [2, 'never'], 'subject-full-stop': [2, 'never', '.'], 'type-case': [2, 'always', 'lower-case'], 'type-empty': [2, 'never'], 'type-enum': [2, 'always', ['build', 'chore', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'style', 'test']] } };
Created on 5/22/2019