|
1 | 1 | # Upgrade Guides
|
2 | 2 |
|
| 3 | +## validate-commit-msg |
| 4 | + |
| 5 | +The maintainers of [validate-commit-msg](https://github.com/conventional-changelog-archived-repos/validate-commit-msg) have deprecated their package in favor of `commitlint`. |
| 6 | + |
| 7 | +### Migrating with default settings |
| 8 | + |
| 9 | +The most common `validate-commit-msg` use cases can be recreated with minor changes to your setup. |
| 10 | + |
| 11 | +**Replace validate-commit-msg with commitlint** |
| 12 | + |
| 13 | +```sh |
| 14 | +npm remove validate-commit-msg --save-dev |
| 15 | +npm install --save-dev @commitlint/cli @commitint/config-angular |
| 16 | +``` |
| 17 | + |
| 18 | +**Add a commitmsg run-script to package.json** |
| 19 | + |
| 20 | +``` |
| 21 | +{ |
| 22 | + "scripts": { |
| 23 | + "commitmsg": "commitlint -x @commitlint/config-angular -e $GIT_PARAMS" |
| 24 | + } |
| 25 | +} |
| 26 | +``` |
| 27 | + |
| 28 | +**Install husky** |
| 29 | + |
| 30 | +```sh |
| 31 | +npm install --save-dev husky |
| 32 | +``` |
| 33 | + |
| 34 | +### Migrating with custom settings |
| 35 | + |
| 36 | +If you used `validate-commit-msg` with custom configuration you might want to customize `commitlint` configuration, too. |
| 37 | + |
| 38 | +**Replace validate-commit-msg with commitlint** |
| 39 | + |
| 40 | +```sh |
| 41 | +npm remove validate-commit-msg --save-dev |
| 42 | +npm install --save-dev @commitlint/cli @commitint/config-angular |
| 43 | +``` |
| 44 | + |
| 45 | +**Add a commitmsg run-script to package.json** |
| 46 | + |
| 47 | +``` |
| 48 | +{ |
| 49 | + "scripts": { |
| 50 | + "commitmsg": "commitlint -e $GIT_PARAMS" |
| 51 | + } |
| 52 | +} |
| 53 | +``` |
| 54 | + |
| 55 | +**Install husky** |
| 56 | + |
| 57 | +```sh |
| 58 | +npm install --save-dev husky |
| 59 | +``` |
| 60 | + |
| 61 | +**Configure commitlint** |
| 62 | + |
| 63 | +```js |
| 64 | +module.exports = { |
| 65 | + extends: ['@commitlint/config-angular'], |
| 66 | + rules: { |
| 67 | + // Place your rules here |
| 68 | + 'scope-enum': [2, 'always', ['a', 'b']] // error if scope is given but not in provided list |
| 69 | + } |
| 70 | +} |
| 71 | +``` |
| 72 | + |
| 73 | +### validate-commit-msg option equivalents |
| 74 | + |
| 75 | +```js |
| 76 | +{ |
| 77 | + "types": ["a", "b"], // 'type-enum': [2, 'always', ['a', 'b']] |
| 78 | + "scope": { |
| 79 | + "required": true, // 'scope-empty': [2, 'never'] |
| 80 | + "allowed": ["a", "b"], // 'scope-enum': [2, 'always', ['a', 'b']]; specify [0] for allowed: ["*"] |
| 81 | + "validate": false, // 'scope-enum': [0], 'scope-empty': [0] |
| 82 | + "multiple": false // multiple scopes are not supported in commitlint |
| 83 | + }, |
| 84 | + "warnOnFail": false, // no equivalent setting in commitlint |
| 85 | + "maxSubjectLength": 100, // 'header-max-length': [2, 'always', 100] |
| 86 | + "subjectPattern": ".+", // may be configured via `parser-preset`, contact us |
| 87 | + "subjectPatternErrorMsg": "msg", // no equivalent setting in commitlint |
| 88 | + "helpMessage": "", // no equivalent setting in commitlint |
| 89 | + "autoFix": false // no equivalent setting in commitlint |
| 90 | +} |
| 91 | +``` |
| 92 | + |
| 93 | +Refer to the [Rules Referece](reference-rules.md) for a list of all avaiable configuration options. |
| 94 | + |
| 95 | +There is also the [#commitlint](https://yargs.slack.com/messages/C7M8XJ4RL/) channel on the DevTools Slack workspace. Join us there and we'll do our best to help you with your migration. |
| 96 | + |
| 97 | + |
3 | 98 | ## Version 1 to 2
|
4 | 99 |
|
5 | 100 | ```bash
|
|
0 commit comments