@@ -59,20 +59,28 @@ module.exports = {
59
59
{
60
60
rules : {
61
61
"body-prose" : ( { raw } : { raw : any } ) => {
62
- let rawStr = Helpers . convertAnyToString ( raw , "raw" ) . trim ( ) ;
62
+ let rawUncastedStr = Helpers . convertAnyToString ( raw , "raw" ) ;
63
+ Helpers . assertRaw ( rawUncastedStr ) ;
64
+ let rawStr = ( rawUncastedStr as string ) . trim ( ) ;
65
+
63
66
return Plugins . bodyProse ( rawStr ) ;
64
67
} ,
65
68
66
69
"commit-hash-alone" : ( { raw } : { raw : any } ) => {
67
- let rawStr = Helpers . convertAnyToString ( raw , "raw" ) ;
70
+ let rawUncastedStr = Helpers . convertAnyToString ( raw , "raw" ) ;
71
+ Helpers . assertRaw ( rawUncastedStr ) ;
72
+ let rawStr = ( rawUncastedStr as string ) . trim ( ) ;
73
+
68
74
return Plugins . commitHashAlone ( rawStr ) ;
69
75
} ,
70
76
71
77
"empty-wip" : ( { header } : { header : any } ) => {
72
- let headerStr = Helpers . convertAnyToString (
78
+ let headerUncastedStr = Helpers . convertAnyToString (
73
79
header ,
74
80
"header"
75
81
) ;
82
+ Helpers . assertHeader ( headerUncastedStr ) ;
83
+ let headerStr = headerUncastedStr as string ;
76
84
return Plugins . emptyWip ( headerStr ) ;
77
85
} ,
78
86
@@ -81,108 +89,138 @@ module.exports = {
81
89
_ : any ,
82
90
maxLineLength : number
83
91
) => {
84
- let headerStr = Helpers . convertAnyToString (
92
+ let headerUncastedStr = Helpers . convertAnyToString (
85
93
header ,
86
94
"header"
87
95
) ;
96
+ Helpers . assertHeader ( headerUncastedStr ) ;
97
+ let headerStr = headerUncastedStr as string ;
88
98
return Plugins . headerMaxLengthWithSuggestions (
89
99
headerStr ,
90
100
maxLineLength
91
101
) ;
92
102
} ,
93
103
94
- "footer-notes-misplacement" : ( { raw } : { raw : any } ) => {
95
- let rawStr = Helpers . convertAnyToString ( raw , "raw" ) . trim ( ) ;
96
- return Plugins . footerNotesMisplacement ( rawStr ) ;
104
+ "footer-notes-misplacement" : ( { body } : { body : any } ) => {
105
+ let bodyStr = Helpers . convertAnyToString ( body , "body" ) ;
106
+ return Plugins . footerNotesMisplacement ( bodyStr ) ;
97
107
} ,
98
108
99
- "footer-references-existence" : ( { raw } : { raw : any } ) => {
100
- let rawStr = Helpers . convertAnyToString ( raw , "raw" ) . trim ( ) ;
101
- return Plugins . footerReferencesExistence ( rawStr ) ;
109
+ "footer-references-existence" : ( { body } : { body : any } ) => {
110
+ let bodyStr = Helpers . convertAnyToString ( body , "body" ) ;
111
+
112
+ return Plugins . footerReferencesExistence ( bodyStr ) ;
102
113
} ,
103
114
104
115
"prefer-slash-over-backslash" : ( {
105
116
header,
106
117
} : {
107
118
header : any ;
108
119
} ) => {
109
- let headerStr = Helpers . convertAnyToString (
120
+ let headerUncastedStr = Helpers . convertAnyToString (
110
121
header ,
111
122
"header"
112
123
) ;
124
+ Helpers . assertHeader ( headerUncastedStr ) ;
125
+ let headerStr = headerUncastedStr as string ;
113
126
return Plugins . preferSlashOverBackslash ( headerStr ) ;
114
127
} ,
115
128
116
129
"proper-issue-refs" : ( { raw } : { raw : any } ) => {
117
- let rawStr = Helpers . convertAnyToString ( raw , "raw" ) . trim ( ) ;
130
+ let rawUncastedStr = Helpers . convertAnyToString ( raw , "raw" ) ;
131
+ Helpers . assertRaw ( rawUncastedStr ) ;
132
+ let rawStr = ( rawUncastedStr as string ) . trim ( ) ;
133
+
118
134
return Plugins . properIssueRefs ( rawStr ) ;
119
135
} ,
120
136
121
137
"title-uppercase" : ( { header } : { header : any } ) => {
122
- let headerStr = Helpers . convertAnyToString (
138
+ let headerUncastedStr = Helpers . convertAnyToString (
123
139
header ,
124
140
"header"
125
141
) ;
142
+ Helpers . assertHeader ( headerUncastedStr ) ;
143
+ let headerStr = headerUncastedStr as string ;
144
+
126
145
return Plugins . titleUppercase ( headerStr ) ;
127
146
} ,
128
147
129
148
"too-many-spaces" : ( { raw } : { raw : any } ) => {
130
- let rawStr = Helpers . convertAnyToString ( raw , "raw" ) ;
149
+ let rawUncastedStr = Helpers . convertAnyToString ( raw , "raw" ) ;
150
+ Helpers . assertRaw ( rawUncastedStr ) ;
151
+ let rawStr = ( rawUncastedStr as string ) . trim ( ) ;
152
+
131
153
return Plugins . tooManySpaces ( rawStr ) ;
132
154
} ,
133
155
134
156
"type-space-after-colon" : ( { header } : { header : any } ) => {
135
- let headerStr = Helpers . convertAnyToString (
157
+ let headerUncastedStr = Helpers . convertAnyToString (
136
158
header ,
137
159
"header"
138
160
) ;
161
+ Helpers . assertHeader ( headerUncastedStr ) ;
162
+ let headerStr = headerUncastedStr as string ;
139
163
return Plugins . typeSpaceAfterColon ( headerStr ) ;
140
164
} ,
141
165
142
166
"type-with-square-brackets" : ( { header } : { header : any } ) => {
143
- let headerStr = Helpers . convertAnyToString (
167
+ let headerUncastedStr = Helpers . convertAnyToString (
144
168
header ,
145
169
"header"
146
170
) ;
171
+ Helpers . assertHeader ( headerUncastedStr ) ;
172
+ let headerStr = headerUncastedStr as string ;
147
173
return Plugins . typeWithSquareBrackets ( headerStr ) ;
148
174
} ,
149
175
150
176
// NOTE: we use 'header' instead of 'subject' as a workaround to this bug: https://github.com/conventional-changelog/commitlint/issues/3404
151
177
"subject-lowercase" : ( { header } : { header : any } ) => {
152
- let headerStr = Helpers . convertAnyToString (
178
+ let headerUncastedStr = Helpers . convertAnyToString (
153
179
header ,
154
180
"header"
155
181
) ;
182
+ Helpers . assertHeader ( headerUncastedStr ) ;
183
+ let headerStr = headerUncastedStr as string ;
156
184
return Plugins . subjectLowercase ( headerStr ) ;
157
185
} ,
158
186
159
187
"type-space-after-comma" : ( { header } : { header : any } ) => {
160
- let headerStr = Helpers . convertAnyToString (
188
+ let headerUncastedStr = Helpers . convertAnyToString (
161
189
header ,
162
190
"header"
163
191
) ;
192
+ Helpers . assertHeader ( headerUncastedStr ) ;
193
+ let headerStr = headerUncastedStr as string ;
164
194
return Plugins . typeSpaceAfterComma ( headerStr ) ;
165
195
} ,
166
196
167
197
"body-soft-max-line-length" : (
168
- { raw } : { raw : any } ,
198
+ { body } : { body : any } ,
169
199
_ : any ,
170
200
maxLineLength : number
171
201
) => {
172
- let rawStr = Helpers . convertAnyToString ( raw , "raw" ) . trim ( ) ;
173
- return Plugins . bodySoftMaxLineLength ( rawStr , maxLineLength ) ;
202
+ let bodyStr = Helpers . convertAnyToString ( body , "body" ) ;
203
+ return Plugins . bodySoftMaxLineLength (
204
+ bodyStr ,
205
+ maxLineLength
206
+ ) ;
174
207
} ,
175
208
176
209
"trailing-whitespace" : ( { raw } : { raw : any } ) => {
177
- let rawStr = Helpers . convertAnyToString ( raw , "raw" ) ;
210
+ let rawUncastedStr = Helpers . convertAnyToString ( raw , "raw" ) ;
211
+ Helpers . assertRaw ( rawUncastedStr ) ;
212
+ let rawStr = rawUncastedStr as string ;
213
+
178
214
return Plugins . trailingWhitespace ( rawStr ) ;
179
215
} ,
180
216
181
217
"type-space-before-paren" : ( { header } : { header : any } ) => {
182
- let headerStr = Helpers . convertAnyToString (
218
+ let headerUncastedStr = Helpers . convertAnyToString (
183
219
header ,
184
220
"header"
185
221
) ;
222
+ Helpers . assertHeader ( headerUncastedStr ) ;
223
+ let headerStr = headerUncastedStr as string ;
186
224
return Plugins . typeSpaceBeforeParen ( headerStr ) ;
187
225
} ,
188
226
} ,
0 commit comments