1
1
import lint from './lint' ;
2
+ import { RuleConfigSeverity } from '@commitlint/types' ;
2
3
3
4
test ( 'throws without params' , async ( ) => {
4
5
const error = ( lint as any ) ( ) ;
@@ -20,21 +21,21 @@ test('positive on stub message and no rule', async () => {
20
21
21
22
test ( 'positive on stub message and adhered rule' , async ( ) => {
22
23
const actual = await lint ( 'foo: bar' , {
23
- 'type-enum' : [ 2 , 'always' , [ 'foo' ] ] ,
24
+ 'type-enum' : [ RuleConfigSeverity . Error , 'always' , [ 'foo' ] ] ,
24
25
} ) ;
25
26
expect ( actual . valid ) . toBe ( true ) ;
26
27
} ) ;
27
28
28
29
test ( 'negative on stub message and broken rule' , async ( ) => {
29
30
const actual = await lint ( 'foo: bar' , {
30
- 'type-enum' : [ 2 , 'never' , [ 'foo' ] ] ,
31
+ 'type-enum' : [ RuleConfigSeverity . Error , 'never' , [ 'foo' ] ] ,
31
32
} ) ;
32
33
expect ( actual . valid ) . toBe ( false ) ;
33
34
} ) ;
34
35
35
36
test ( 'positive on ignored message and broken rule' , async ( ) => {
36
37
const actual = await lint ( 'Revert "some bogus commit"' , {
37
- 'type-empty' : [ 2 , 'never' ] ,
38
+ 'type-empty' : [ RuleConfigSeverity . Error , 'never' ] ,
38
39
} ) ;
39
40
expect ( actual . valid ) . toBe ( true ) ;
40
41
expect ( actual . input ) . toBe ( 'Revert "some bogus commit"' ) ;
@@ -44,7 +45,7 @@ test('negative on ignored message, disabled ignored messages and broken rule', a
44
45
const actual = await lint (
45
46
'Revert "some bogus commit"' ,
46
47
{
47
- 'type-empty' : [ 2 , 'never' ] ,
48
+ 'type-empty' : [ RuleConfigSeverity . Error , 'never' ] ,
48
49
} ,
49
50
{
50
51
defaultIgnores : false ,
@@ -58,7 +59,7 @@ test('positive on custom ignored message and broken rule', async () => {
58
59
const actual = await lint (
59
60
ignoredMessage ,
60
61
{
61
- 'type-empty' : [ 2 , 'never' ] ,
62
+ 'type-empty' : [ RuleConfigSeverity . Error , 'never' ] ,
62
63
} ,
63
64
{
64
65
ignores : [ ( c ) => c === ignoredMessage ] ,
@@ -72,8 +73,8 @@ test('positive on stub message and opts', async () => {
72
73
const actual = await lint (
73
74
'foo-bar' ,
74
75
{
75
- 'type-enum' : [ 2 , 'always' , [ 'foo' ] ] ,
76
- 'type-empty' : [ 2 , 'never' ] ,
76
+ 'type-enum' : [ RuleConfigSeverity . Error , 'always' , [ 'foo' ] ] ,
77
+ 'type-empty' : [ RuleConfigSeverity . Error , 'never' ] ,
77
78
} ,
78
79
{
79
80
parserOpts : {
@@ -85,7 +86,7 @@ test('positive on stub message and opts', async () => {
85
86
} ) ;
86
87
87
88
test ( 'throws for invalid rule names' , async ( ) => {
88
- const error = lint ( 'foo' , { foo : [ 2 , 'always' ] , bar : [ 1 , 'never' ] } ) ;
89
+ const error = lint ( 'foo' , { foo : [ RuleConfigSeverity . Error , 'always' ] , bar : [ RuleConfigSeverity . Warning , 'never' ] } ) ;
89
90
90
91
await expect ( error ) . rejects . toThrow ( / ^ F o u n d i n v a l i d r u l e n a m e s : f o o , b a r / ) ;
91
92
} ) ;
@@ -150,8 +151,8 @@ test('throws for rule with invalid condition', async () => {
150
151
151
152
test ( 'throws for rule with out of range condition' , async ( ) => {
152
153
const error = lint ( 'type(scope): foo' , {
153
- 'type-enum' : [ 1 , 'foo' ] as any ,
154
- 'header-max-length' : [ 1 , 'bar' ] as any ,
154
+ 'type-enum' : [ RuleConfigSeverity . Warning , 'foo' ] as any ,
155
+ 'header-max-length' : [ RuleConfigSeverity . Warning , 'bar' ] as any ,
155
156
} ) ;
156
157
157
158
await expect ( error ) . rejects . toThrow ( 'type-enum must be "always" or "never"' ) ;
@@ -162,15 +163,15 @@ test('throws for rule with out of range condition', async () => {
162
163
163
164
test ( 'succeds for issue' , async ( ) => {
164
165
const report = await lint ( 'somehting #1' , {
165
- 'references-empty' : [ 2 , 'never' ] ,
166
+ 'references-empty' : [ RuleConfigSeverity . Error , 'never' ] ,
166
167
} ) ;
167
168
168
169
expect ( report . valid ) . toBe ( true ) ;
169
170
} ) ;
170
171
171
172
test ( 'fails for issue' , async ( ) => {
172
173
const report = await lint ( 'somehting #1' , {
173
- 'references-empty' : [ 2 , 'always' ] ,
174
+ 'references-empty' : [ RuleConfigSeverity . Error , 'always' ] ,
174
175
} ) ;
175
176
176
177
expect ( report . valid ) . toBe ( false ) ;
@@ -180,7 +181,7 @@ test('succeds for custom issue prefix', async () => {
180
181
const report = await lint (
181
182
'somehting REF-1' ,
182
183
{
183
- 'references-empty' : [ 2 , 'never' ] ,
184
+ 'references-empty' : [ RuleConfigSeverity . Error , 'never' ] ,
184
185
} ,
185
186
{
186
187
parserOpts : {
@@ -196,7 +197,7 @@ test('fails for custom issue prefix', async () => {
196
197
const report = await lint (
197
198
'somehting #1' ,
198
199
{
199
- 'references-empty' : [ 2 , 'never' ] ,
200
+ 'references-empty' : [ RuleConfigSeverity . Error , 'never' ] ,
200
201
} ,
201
202
{
202
203
parserOpts : {
@@ -212,7 +213,7 @@ test('fails for custom plugin rule', async () => {
212
213
const report = await lint (
213
214
'somehting #1' ,
214
215
{
215
- 'plugin-rule' : [ 2 , 'never' ] ,
216
+ 'plugin-rule' : [ RuleConfigSeverity . Error , 'never' ] ,
216
217
} ,
217
218
{
218
219
plugins : {
@@ -232,7 +233,7 @@ test('passes for custom plugin rule', async () => {
232
233
const report = await lint (
233
234
'somehting #1' ,
234
235
{
235
- 'plugin-rule' : [ 2 , 'never' ] ,
236
+ 'plugin-rule' : [ RuleConfigSeverity . Error , 'never' ] ,
236
237
} ,
237
238
{
238
239
plugins : {
@@ -275,7 +276,7 @@ test('returns original message with commit header, body and footer, parsing comm
275
276
const report = await lint (
276
277
message ,
277
278
{
278
- 'references-empty' : [ 2 , 'never' ] ,
279
+ 'references-empty' : [ RuleConfigSeverity . Error , 'never' ] ,
279
280
} ,
280
281
{
281
282
parserOpts : {
@@ -291,7 +292,7 @@ test('passes for async rule', async () => {
291
292
const report = await lint (
292
293
'somehting #1' ,
293
294
{
294
- 'async-rule' : [ 2 , 'never' ] ,
295
+ 'async-rule' : [ RuleConfigSeverity . Error , 'never' ] ,
295
296
} ,
296
297
{
297
298
plugins : {
0 commit comments