|
1 | 1 | module.exports = { |
2 | | - extends : ["@commitlint/config-conventional"], |
3 | | - rules : { |
4 | | - "header-max-length" : [1, "always", 50], |
5 | | - "body-max-line-length" : [1, "always", 72] |
6 | | - } |
7 | | -} |
| 2 | + extends: ["@commitlint/config-conventional"], |
| 3 | + plugins: [ |
| 4 | + { |
| 5 | + rules: { |
| 6 | + // custom rule: enforce scope formats |
| 7 | + // - for `retry`: require a result code scope: WA,TLE,OLE,MLE,RE,PE,CE,CREDIT (e.g. retry(WA)) |
| 8 | + // - for `solve` and `skip`: no special validation |
| 9 | + "scope-format": (parsed) => { |
| 10 | + const t = parsed.type; |
| 11 | + const s = parsed.scope || ""; |
| 12 | + if (t === "retry") { |
| 13 | + const ok = /^(WA|TLE|OLE|MLE|RE|PE|CE|CREDIT)$/.test(s); |
| 14 | + return [ |
| 15 | + ok, |
| 16 | + "For type 'retry' the scope must be one of WA,TLE,OLE,MLE,RE,PE,CE,CREDIT (e.g. retry(WA))", |
| 17 | + ]; |
| 18 | + } |
| 19 | + return [true]; |
| 20 | + }, |
| 21 | + }, |
| 22 | + }, |
| 23 | + ], |
| 24 | + rules: { |
| 25 | + "header-max-length": [1, "always", 50], |
| 26 | + "body-max-line-length": [1, "always", 72], |
| 27 | + // allowed commit types (prefixes) |
| 28 | + "type-enum": [ |
| 29 | + 2, |
| 30 | + "always", |
| 31 | + [ |
| 32 | + "refactor", |
| 33 | + "docs", |
| 34 | + "test", |
| 35 | + "revert", |
| 36 | + "perf", |
| 37 | + "build", |
| 38 | + "solve", |
| 39 | + "chore", |
| 40 | + "fix", |
| 41 | + "ci", |
| 42 | + "skip", |
| 43 | + "retry", |
| 44 | + "style", |
| 45 | + ], |
| 46 | + ], |
| 47 | + // activate custom scope-format plugin rule |
| 48 | + "scope-format": [2, "always"], |
| 49 | + // disable subject-case enforcement so both "Do it" and "do it" are accepted |
| 50 | + "subject-case": [0, "always"], |
| 51 | + }, |
| 52 | +}; |
0 commit comments