1
- const pkg = require ( './package.json' ) ;
1
+ import {
2
+ RuleConfigCondition ,
3
+ RuleConfigSeverity ,
4
+ TargetCaseType ,
5
+ } from '@commitlint/types' ;
2
6
3
- // Check if the user has configured the package to use conventional commits.
4
- const isConventional = pkg . config
5
- ? pkg . config [ 'cz-emoji' ] ?. conventional
6
- : false ;
7
-
8
- // Regex for default and conventional commits.
9
- const RE_DEFAULT_COMMIT =
10
- / ^ (?: : .* : | (?: \u00a9 | \u00ae | [ \u2000 - \u3300 ] | \ud83c [ \ud000 - \udfff ] | \ud83d [ \ud000 - \udfff ] | \ud83e [ \ud000 - \udfff ] ) ) \s (?< emoji > \( (?< scope > .* ) \) \s ) ? .* $ / gm;
11
- const RE_CONVENTIONAL_COMMIT =
12
- / ^ ^ (?< type > \w + ) (?: \( (?< scope > \w + ) \) ) ? \s (?< emoji > : .* : | (?: \u00a9 | \u00ae | [ \u2000 - \u3300 ] | \ud83c [ \ud000 - \udfff ] | \ud83d [ \ud000 - \udfff ] | \ud83e [ \ud000 - \udfff ] ) ) \s .* $ / gm;
13
-
14
- module . exports = {
15
- rules : {
16
- 'cz-emoji' : [ 2 , 'always' ] ,
17
- } ,
18
- plugins : [
19
- {
20
- rules : {
21
- 'cz-emoji' : ( { raw } ) => {
22
- const isValid = isConventional
23
- ? RE_CONVENTIONAL_COMMIT . test ( raw )
24
- : RE_DEFAULT_COMMIT . test ( raw ) ;
25
-
26
- const message = isConventional
27
- ? `Your commit message should follow conventional commit format.`
28
- : `Your commit message should be: <emoji> (<scope>)?: <subject>` ;
29
-
30
- return [ isValid , message ] ;
31
- } ,
32
- } ,
33
- } ,
34
- ] ,
35
- } ;
7
+ export default {
8
+ extends : [ 'gitmoji' ] ,
9
+ parserPreset : '@gitmoji/parser-opts' ,
10
+ rules : {
11
+ 'body-leading-blank' : [ RuleConfigSeverity . Warning , 'always' ] as const ,
12
+ //not setting any max-line-length since we are writing release-notes
13
+ //in our chore(release) commit messages. @see release.config.ts '@semantic-release/git' configurations.
14
+ //'body-max-line-length': [RuleConfigSeverity.Error, 'always', 100] as const,
15
+ 'footer-leading-blank' : [ RuleConfigSeverity . Warning , 'always' ] as const ,
16
+ // 'footer-max-line-length': [
17
+ // RuleConfigSeverity.Error,
18
+ // 'always',
19
+ // 100,
20
+ // ] as const,
21
+ 'header-max-length' : [ RuleConfigSeverity . Error , 'always' , 100 ] as const ,
22
+ 'header-trim' : [ RuleConfigSeverity . Error , 'always' ] as const ,
23
+ 'subject-case' : [
24
+ RuleConfigSeverity . Error ,
25
+ 'never' ,
26
+ [ 'sentence-case' , 'start-case' , 'pascal-case' , 'upper-case' ] ,
27
+ ] as [ RuleConfigSeverity , RuleConfigCondition , TargetCaseType [ ] ] ,
28
+ 'subject-empty' : [ RuleConfigSeverity . Error , 'never' ] as const ,
29
+ 'subject-full-stop' : [ RuleConfigSeverity . Error , 'never' , '.' ] as const ,
30
+ 'type-case' : [ RuleConfigSeverity . Error , 'always' , 'lower-case' ] as const ,
31
+ 'type-empty' : [ RuleConfigSeverity . Error , 'never' ] as const ,
32
+ 'type-enum' : [
33
+ RuleConfigSeverity . Error ,
34
+ 'always' ,
35
+ [
36
+ 'style' ,
37
+ 'perf' ,
38
+ 'prune' ,
39
+ 'fix' ,
40
+ 'quickfix' ,
41
+ 'feature' ,
42
+ 'docs' ,
43
+ 'deploy' ,
44
+ 'ui' ,
45
+ 'init' ,
46
+ 'test' ,
47
+ 'security' ,
48
+ 'release' ,
49
+ 'lint' ,
50
+ 'wip' ,
51
+ 'fix-ci' ,
52
+ 'downgrade' ,
53
+ 'upgrade' ,
54
+ 'pushpin' ,
55
+ 'ci' ,
56
+ 'analytics' ,
57
+ 'refactoring' ,
58
+ 'dep-add' ,
59
+ 'dep-rm' ,
60
+ 'config' ,
61
+ 'i18n' ,
62
+ 'typo' ,
63
+ 'poo' ,
64
+ 'revert' ,
65
+ 'merge' ,
66
+ 'dep-up' ,
67
+ 'compat' ,
68
+ 'mv' ,
69
+ 'license' ,
70
+ 'breaking' ,
71
+ 'assets' ,
72
+ 'access' ,
73
+ 'docs-code' ,
74
+ 'beer' ,
75
+ 'texts' ,
76
+ 'db' ,
77
+ 'log-add' ,
78
+ 'log-rm' ,
79
+ 'contrib-add' ,
80
+ 'ux' ,
81
+ 'arch' ,
82
+ 'iphone' ,
83
+ 'clown-face' ,
84
+ 'egg' ,
85
+ 'see-no-evil' ,
86
+ 'camera-flash' ,
87
+ 'experiment' ,
88
+ 'seo' ,
89
+ 'types' ,
90
+ 'seed' ,
91
+ 'flags' ,
92
+ 'animation' ,
93
+ 'wastebasket' ,
94
+ 'passport-control' ,
95
+ 'adhesive-bandage' ,
96
+ 'monocle-face' ,
97
+ 'coffin' ,
98
+ 'test-tube' ,
99
+ 'necktie' ,
100
+ 'stethoscope' ,
101
+ 'bricks' ,
102
+ 'technologist' ,
103
+ 'chore' ,
104
+ ] ,
105
+ ] as [ RuleConfigSeverity , RuleConfigCondition , string [ ] ] ,
106
+ }
107
+ } ;
0 commit comments