|
| 1 | +# commitlint-config-git-commit-emoji |
| 2 | + |
| 3 | +[![npm latest][version-img]][pkg-url] |
| 4 | +[![download][download-img]][pkg-url] |
| 5 | +[![MIT][license-img]](LICENSE) |
| 6 | + |
| 7 | +Shareable `commitlint` config for the VS Code extension [git-commit-plugin](https://github.com/RedJue/git-commit-plugin) with emoji enabled. |
| 8 | +Use with [commitlint](https://github.com/conventional-changelog/commitlint). |
| 9 | + |
| 10 | +## Getting started |
| 11 | + |
| 12 | +```sh |
| 13 | +npm install --save-dev @commitlint/cli commitlint-config-git-commit-emoji |
| 14 | + |
| 15 | +echo "module.exports = {extends: ['git-commit-emoji']};" > .commitlintrc.js |
| 16 | +``` |
| 17 | + |
| 18 | +## Format |
| 19 | + |
| 20 | +```text |
| 21 | +<emoji> <type>(<scope>): <subject> |
| 22 | +<BLANK LINE> |
| 23 | +<body> |
| 24 | +<BLANK LINE> |
| 25 | +<footer> |
| 26 | +``` |
| 27 | + |
| 28 | +### Example |
| 29 | + |
| 30 | +```text |
| 31 | +✨ feat(blog): add comment section |
| 32 | +``` |
| 33 | + |
| 34 | +## Rules |
| 35 | + |
| 36 | +### Problems |
| 37 | + |
| 38 | +The following rules are considered problems for `commitlint-config-git-commit-emoji` and will yield a non-zero exit code when not met. |
| 39 | +Consult [docs/rules](https://conventional-changelog.github.io/commitlint/#/reference-rules) for a list of available rules. |
| 40 | + |
| 41 | +#### type-enum |
| 42 | + |
| 43 | +- **condition**: `type` is found in value |
| 44 | +- **rule**: `always` |
| 45 | +- **value** |
| 46 | + |
| 47 | +```text |
| 48 | +[ |
| 49 | + '🎉 init', |
| 50 | + '✨ feat', |
| 51 | + '🐞 fix', |
| 52 | + '📃 docs', |
| 53 | + '🌈 style', |
| 54 | + '🦄 refactor', |
| 55 | + '🎈 perf', |
| 56 | + '🧪 test', |
| 57 | + '🔧 build', |
| 58 | + '🐎 ci', |
| 59 | + '🐳 chore', |
| 60 | + '↩ revert', |
| 61 | +] |
| 62 | +``` |
| 63 | + |
| 64 | +```sh |
| 65 | +echo "foo: some message" # fails |
| 66 | +echo "🐞 fix: some message" # passes |
| 67 | +``` |
| 68 | + |
| 69 | +#### type-case |
| 70 | + |
| 71 | +- **description**: `type` is in case `value` |
| 72 | +- **rule**: `always` |
| 73 | +- **value** |
| 74 | + |
| 75 | +```text |
| 76 | +'lowerCase' |
| 77 | +``` |
| 78 | + |
| 79 | +```sh |
| 80 | +echo "FIX: some message" # fails |
| 81 | +echo "🐞 fix: some message" # passes |
| 82 | +``` |
| 83 | + |
| 84 | +#### type-empty |
| 85 | + |
| 86 | +- **condition**: `type` is empty |
| 87 | +- **rule**: `never` |
| 88 | + |
| 89 | +```sh |
| 90 | +echo ": some message" # fails |
| 91 | +echo "🐞 fix: some message" # passes |
| 92 | +``` |
| 93 | + |
| 94 | +#### scope-case |
| 95 | + |
| 96 | +- **condition**: `scope` is in case `value` |
| 97 | +- **rule**: `always` |
| 98 | + |
| 99 | +```text |
| 100 | +'lowerCase' |
| 101 | +``` |
| 102 | + |
| 103 | +```sh |
| 104 | +echo "🐞 fix(SCOPE): some message" # fails |
| 105 | +echo "🐞 fix(scope): some message" # passes |
| 106 | +``` |
| 107 | + |
| 108 | +#### subject-case |
| 109 | + |
| 110 | +- **condition**: `subject` is in one of the cases `['sentence-case', 'start-case', 'pascal-case', 'upper-case']` |
| 111 | +- **rule**: `never` |
| 112 | + |
| 113 | +```sh |
| 114 | +echo "🐞 fix(SCOPE): Some message" # fails |
| 115 | +echo "🐞 fix(SCOPE): Some Message" # fails |
| 116 | +echo "🐞 fix(SCOPE): SomeMessage" # fails |
| 117 | +echo "🐞 fix(SCOPE): SOMEMESSAGE" # fails |
| 118 | +echo "🐞 fix(scope): some message" # passes |
| 119 | +echo "🐞 fix(scope): some Message" # passes |
| 120 | +``` |
| 121 | + |
| 122 | +#### subject-empty |
| 123 | + |
| 124 | +- **condition**: `subject` is empty |
| 125 | +- **rule**: `never` |
| 126 | + |
| 127 | +```sh |
| 128 | +echo "🐞 fix:" # fails |
| 129 | +echo "🐞 fix: some message" # passes |
| 130 | +``` |
| 131 | + |
| 132 | +#### subject-full-stop |
| 133 | + |
| 134 | +- **condition**: `subject` ends with `value` |
| 135 | +- **rule**: `never` |
| 136 | +- **value** |
| 137 | + |
| 138 | +```text |
| 139 | +'.' |
| 140 | +``` |
| 141 | + |
| 142 | +```sh |
| 143 | +echo "🐞 fix: some message." # fails |
| 144 | +echo "🐞 fix: some message" # passes |
| 145 | +``` |
| 146 | + |
| 147 | +#### subject-exclamation-mark |
| 148 | + |
| 149 | +- **condition**: `subject` must not have a `!` before the `:` marker |
| 150 | +- **rule**: `never` |
| 151 | + |
| 152 | +The [angular commit |
| 153 | +convention](hhttps://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit) |
| 154 | +dose not use a `!` to define a breaking change in the commit subject. If you |
| 155 | +want to use this feature please consider using the [conventional commit |
| 156 | +config](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional#commitlintconfig-conventional). |
| 157 | + |
| 158 | +#### header-max-length |
| 159 | + |
| 160 | +- **condition**: `header` has `value` or less characters |
| 161 | +- **rule**: `always` |
| 162 | +- **value** |
| 163 | + |
| 164 | +```text |
| 165 | +72 |
| 166 | +``` |
| 167 | + |
| 168 | +```sh |
| 169 | +echo "🐞 fix: some message that is way too long and breaks the line max-length by several characters" # fails |
| 170 | +echo "🐞 fix: some message" # passes |
| 171 | +``` |
| 172 | + |
| 173 | +#### body-leading-blank |
| 174 | + |
| 175 | +- **condition**: Body should have a leading blank line |
| 176 | +- **rule**: `always` |
| 177 | + |
| 178 | +```sh |
| 179 | +echo "🐞 fix: some message |
| 180 | +body" # fails |
| 181 | + |
| 182 | +echo "🐞 fix: some message |
| 183 | +
|
| 184 | +body" # passes |
| 185 | +``` |
| 186 | + |
| 187 | +#### footer-leading-blank |
| 188 | + |
| 189 | +- **condition**: Footer should have a leading blank line |
| 190 | +- **rule**: `always` |
| 191 | + |
| 192 | +```sh |
| 193 | +echo "🐞 fix: some message |
| 194 | +BREAKING CHANGE: It will be significant" # fails |
| 195 | + |
| 196 | +echo "🐞 fix: some message |
| 197 | +
|
| 198 | +BREAKING CHANGE: It will be significant" # passes |
| 199 | +``` |
| 200 | + |
| 201 | +## Thanks |
| 202 | + |
| 203 | +- Header regex pattern modified from [@gitmoji/parser-opts](https://github.com/arvinxx/gitmoji-commit-workflow/blob/master/packages/parser-opts/README.md) |
| 204 | +- Most of the rules come from [@commitlint/config-angular](https://github.com/conventional-changelog/commitlint/blob/master/%40commitlint/config-angular/README.md) |
| 205 | + |
| 206 | +## License |
| 207 | + |
| 208 | +[MIT](LICENSE) © Nor Cod |
| 209 | + |
| 210 | +<!-- badge url --> |
| 211 | + |
| 212 | +[pkg-url]: https://www.npmjs.com/package/commitlint-config-git-commit-emoji |
| 213 | +[version-img]: https://img.shields.io/npm/v/commitlint-config-git-commit-emoji?color=deepgreen&style=flat-square |
| 214 | +[download-img]: https://img.shields.io/npm/dm/commitlint-config-git-commit-emoji?style=flat-square |
| 215 | +[license-img]: https://img.shields.io/badge/license-MIT-blue?style=flat-square |
0 commit comments