|
| 1 | +const Configuration = { |
| 2 | + /* |
| 3 | + * Resolve and load @commitlint/config-conventional from node_modules. |
| 4 | + * Referenced packages must be installed |
| 5 | + */ |
| 6 | + extends: ['@commitlint/config-conventional'], |
| 7 | + /* |
| 8 | + * Any rules defined here will override rules from @commitlint/config-conventional |
| 9 | + * See https://commitlint.js.org/#/reference-rules?id=available-rules |
| 10 | + * Rules are defined as lists: |
| 11 | + * - level(int:required): 0 disabled, 1 warning, 2 error |
| 12 | + * - behaviour(string:required): 'always', 'never' |
| 13 | + * - value(mixed:optional): value to match |
| 14 | + */ |
| 15 | + rules: { |
| 16 | + 'type-enum': [ |
| 17 | + 2, |
| 18 | + 'always', |
| 19 | + [ |
| 20 | + 'build', |
| 21 | + 'chore', |
| 22 | + 'ci', |
| 23 | + 'docs', |
| 24 | + 'feat', |
| 25 | + 'fix', |
| 26 | + 'perf', |
| 27 | + 'refactor', |
| 28 | + 'revert', |
| 29 | + 'style', |
| 30 | + 'test', |
| 31 | + 'misc', |
| 32 | + 'merge', |
| 33 | + 'cherry-pick', |
| 34 | + ] |
| 35 | + ], |
| 36 | + 'scope-empty': [ |
| 37 | + 2, |
| 38 | + 'never', |
| 39 | + ], |
| 40 | + 'scope-enum': [ |
| 41 | + 2, |
| 42 | + 'always', |
| 43 | + [ |
| 44 | + 'templates', |
| 45 | + 'cron', |
| 46 | + 'webform', |
| 47 | + 'user', |
| 48 | + 'blocks', |
| 49 | + 'fields', |
| 50 | + 'views', |
| 51 | + 'obd', |
| 52 | + 'dev', |
| 53 | + 'tests', |
| 54 | + ] |
| 55 | + ], |
| 56 | + 'subject-full-stop': [ |
| 57 | + 0, |
| 58 | + ], |
| 59 | + 'header-full-stop': [ |
| 60 | + 2, |
| 61 | + 'always', |
| 62 | + ';', |
| 63 | + ], |
| 64 | + 'body-empty': [ |
| 65 | + 0, |
| 66 | + 'never', |
| 67 | + ], |
| 68 | + 'body-leading-blank': [ |
| 69 | + 2, |
| 70 | + 'always', |
| 71 | + ], |
| 72 | + 'body-full-stop': [ |
| 73 | + 2, |
| 74 | + 'always', |
| 75 | + '.', |
| 76 | + ], |
| 77 | + 'body-starts-with': [ |
| 78 | + 2, |
| 79 | + 'always', |
| 80 | + '- ' |
| 81 | + ], |
| 82 | + }, |
| 83 | + /* |
| 84 | + * Custom plugins |
| 85 | + */ |
| 86 | + plugins: [ |
| 87 | + { |
| 88 | + rules: { |
| 89 | + 'header-full-stop': (parsed, behaviour, value) => { |
| 90 | + if ( ! parsed.header ){ return [true, ''] } |
| 91 | + return [parsed.header.endsWith(value), 'header must end with `' + value + '`'] |
| 92 | + }, |
| 93 | + 'body-full-stop': (parsed, behaviour, value) => { |
| 94 | + if ( ! parsed.body ){ return [true, ''] } |
| 95 | + return [parsed.body.endsWith(value), 'body must end with `' + value + '`'] |
| 96 | + }, |
| 97 | + 'body-starts-with': (parsed, behaviour, value) => { |
| 98 | + if ( ! parsed.body ){ return [true, ''] } |
| 99 | + return [parsed.body.startsWith(value), 'body must start with `' + value + '`'] |
| 100 | + }, |
| 101 | + 'scope-enum': (parsed, behaviour, value) => { |
| 102 | + if ( ! parsed.scope ){ return [true, ''] } |
| 103 | + scopes = parsed.scope.split(',') |
| 104 | + for( let i = 0; i < scopes.length; i++ ){ |
| 105 | + if ( ! value.includes(scopes[i]) ){ |
| 106 | + return [false, 'scope must be one of `' + value.join(', ') + '`'] |
| 107 | + } |
| 108 | + } |
| 109 | + return [true, ''] |
| 110 | + }, |
| 111 | + }, |
| 112 | + }, |
| 113 | + ], |
| 114 | +} |
| 115 | + |
| 116 | +module.exports = Configuration; |
0 commit comments