@@ -36,56 +36,48 @@ test('core', async (t) => {
36
36
'# Another main heading.'
37
37
] . join ( '\n' )
38
38
39
+ let file = await remark ( )
40
+ . use ( noHeadingPunctuation )
41
+ . use ( noMultipleToplevelHeadings )
42
+ . use ( lint )
43
+ . process ( toVFile ( { path : 'virtual.md' , value : doc } ) )
44
+
39
45
t . deepEqual (
40
- asStrings (
41
- (
42
- await remark ( )
43
- . use ( noHeadingPunctuation )
44
- . use ( noMultipleToplevelHeadings )
45
- . use ( lint )
46
- . process ( toVFile ( { path : 'virtual.md' , value : doc } ) )
47
- ) . messages
48
- ) ,
46
+ asStrings ( file . messages ) ,
49
47
[
50
48
'virtual.md:3:1-3:24: Don’t add a trailing `.` to headings' ,
51
49
'virtual.md:3:1-3:24: Don’t use multiple top level headings (1:1)'
52
50
] ,
53
51
'should support `remark-lint` last'
54
52
)
55
53
54
+ file = await remark ( )
55
+ . use ( lint )
56
+ . use ( noHeadingPunctuation )
57
+ . use ( noMultipleToplevelHeadings )
58
+ . process ( toVFile ( { path : 'virtual.md' , value : doc } ) )
59
+
56
60
t . deepEqual (
57
- asStrings (
58
- (
59
- await remark ( )
60
- . use ( lint )
61
- . use ( noHeadingPunctuation )
62
- . use ( noMultipleToplevelHeadings )
63
- . process ( toVFile ( { path : 'virtual.md' , value : doc } ) )
64
- ) . messages
65
- ) ,
61
+ asStrings ( file . messages ) ,
66
62
[
67
63
'virtual.md:3:1-3:24: Don’t add a trailing `.` to headings' ,
68
64
'virtual.md:3:1-3:24: Don’t use multiple top level headings (1:1)'
69
65
] ,
70
66
'should support `remark-lint` first'
71
67
)
72
68
73
- t . deepEqual (
74
- asStrings ( ( await remark ( ) . use ( lint ) . process ( '.' ) ) . messages ) ,
75
- [ ] ,
76
- 'should support no rules'
77
- )
69
+ file = await remark ( ) . use ( lint ) . process ( '.' )
78
70
79
- t . deepEqual (
80
- asStrings ( ( await remark ( ) . use ( finalNewline ) . process ( '' ) ) . messages ) ,
81
- [ ] ,
82
- 'should support successful rules'
83
- )
71
+ t . deepEqual ( asStrings ( file . messages ) , [ ] , 'should support no rules' )
72
+
73
+ file = await remark ( ) . use ( finalNewline ) . process ( '' )
74
+
75
+ t . deepEqual ( asStrings ( file . messages ) , [ ] , 'should support successful rules' )
76
+
77
+ file = await remark ( ) . use ( finalNewline , [ 2 ] ) . process ( '.' )
84
78
85
79
t . deepEqual (
86
- ( await remark ( ) . use ( finalNewline , [ 2 ] ) . process ( '.' ) ) . messages . map ( ( d ) =>
87
- JSON . parse ( JSON . stringify ( d ) )
88
- ) ,
80
+ file . messages . map ( ( d ) => JSON . parse ( JSON . stringify ( d ) ) ) ,
89
81
[
90
82
{
91
83
name : '1:1' ,
@@ -106,36 +98,42 @@ test('core', async (t) => {
106
98
'should support a list with a severity'
107
99
)
108
100
101
+ file = await remark ( ) . use ( finalNewline , true ) . process ( '.' )
102
+
109
103
t . deepEqual (
110
- asStrings ( ( await remark ( ) . use ( finalNewline , true ) . process ( '.' ) ) . messages ) ,
104
+ asStrings ( file . messages ) ,
111
105
[ '1:1: Missing newline character at end of file' ] ,
112
106
'should support a boolean (`true`)'
113
107
)
114
108
109
+ file = await remark ( ) . use ( finalNewline , false ) . process ( '.' )
110
+
115
111
t . deepEqual (
116
- asStrings ( ( await remark ( ) . use ( finalNewline , false ) . process ( '.' ) ) . messages ) ,
112
+ asStrings ( file . messages ) ,
117
113
[ ] ,
118
114
'should support a boolean (`false`)'
119
115
)
120
116
117
+ file = await remark ( ) . use ( finalNewline , [ true ] ) . process ( '.' )
118
+
121
119
t . deepEqual (
122
- asStrings ( ( await remark ( ) . use ( finalNewline , [ true ] ) . process ( '.' ) ) . messages ) ,
120
+ asStrings ( file . messages ) ,
123
121
[ '1:1: Missing newline character at end of file' ] ,
124
122
'should support a list with a boolean severity (true, for on)'
125
123
)
126
124
125
+ file = await remark ( ) . use ( finalNewline , [ false ] ) . process ( '.' )
126
+
127
127
t . deepEqual (
128
- asStrings (
129
- ( await remark ( ) . use ( finalNewline , [ false ] ) . process ( '.' ) ) . messages
130
- ) ,
128
+ asStrings ( file . messages ) ,
131
129
[ ] ,
132
130
'should support a list with boolean severity (false, for off)'
133
131
)
134
132
133
+ file = await remark ( ) . use ( finalNewline , [ 'error' ] ) . process ( '.' )
134
+
135
135
t . deepEqual (
136
- ( await remark ( ) . use ( finalNewline , [ 'error' ] ) . process ( '.' ) ) . messages . map (
137
- ( d ) => JSON . parse ( JSON . stringify ( d ) )
138
- ) ,
136
+ file . messages . map ( ( d ) => JSON . parse ( JSON . stringify ( d ) ) ) ,
139
137
[
140
138
{
141
139
name : '1:1' ,
@@ -156,10 +154,10 @@ test('core', async (t) => {
156
154
'should support a list with string severity (`error`)'
157
155
)
158
156
157
+ file = await remark ( ) . use ( finalNewline , [ 'on' ] ) . process ( '.' )
158
+
159
159
t . deepEqual (
160
- ( await remark ( ) . use ( finalNewline , [ 'on' ] ) . process ( '.' ) ) . messages . map ( ( d ) =>
161
- JSON . parse ( JSON . stringify ( d ) )
162
- ) ,
160
+ file . messages . map ( ( d ) => JSON . parse ( JSON . stringify ( d ) ) ) ,
163
161
[
164
162
{
165
163
name : '1:1' ,
@@ -180,10 +178,10 @@ test('core', async (t) => {
180
178
'should support a list with string severity (`on`)'
181
179
)
182
180
181
+ file = await remark ( ) . use ( finalNewline , [ 'warn' ] ) . process ( '.' )
182
+
183
183
t . deepEqual (
184
- ( await remark ( ) . use ( finalNewline , [ 'warn' ] ) . process ( '.' ) ) . messages . map (
185
- ( d ) => JSON . parse ( JSON . stringify ( d ) )
186
- ) ,
184
+ file . messages . map ( ( d ) => JSON . parse ( JSON . stringify ( d ) ) ) ,
187
185
[
188
186
{
189
187
name : '1:1' ,
@@ -204,10 +202,10 @@ test('core', async (t) => {
204
202
'should support a list with string severity (`warn`)'
205
203
)
206
204
205
+ file = await remark ( ) . use ( finalNewline , [ 'off' ] ) . process ( '.' )
206
+
207
207
t . deepEqual (
208
- asStrings (
209
- ( await remark ( ) . use ( finalNewline , [ 'off' ] ) . process ( '.' ) ) . messages
210
- ) ,
208
+ asStrings ( file . messages ) ,
211
209
[ ] ,
212
210
'should support a list with string severity (`off`)'
213
211
)
@@ -228,17 +226,17 @@ test('core', async (t) => {
228
226
'should fail on incorrect severities (too low)'
229
227
)
230
228
229
+ file = await remark ( )
230
+ . use (
231
+ lintRule ( 'test:rule' , ( tree , file ) => {
232
+ file . message ( 'Test message' )
233
+ } ) ,
234
+ [ 'warn' ]
235
+ )
236
+ . process ( '.' )
237
+
231
238
t . deepEqual (
232
- (
233
- await remark ( )
234
- . use (
235
- lintRule ( 'test:rule' , ( tree , file ) => {
236
- file . message ( 'Test message' )
237
- } ) ,
238
- [ 'warn' ]
239
- )
240
- . process ( '.' )
241
- ) . messages . map ( ( d ) => JSON . parse ( JSON . stringify ( d ) ) ) ,
239
+ file . messages . map ( ( d ) => JSON . parse ( JSON . stringify ( d ) ) ) ,
242
240
[
243
241
{
244
242
name : '1:1' ,
@@ -270,9 +268,11 @@ test('rules', async (t) => {
270
268
const info = rule ( base )
271
269
const href = url . pathToFileURL ( base ) . href + '/index.js'
272
270
271
+ // type-coverage:ignore-next-line
272
+ const pluginMod = await import ( href )
273
273
/** @type {Plugin } */
274
274
// type-coverage:ignore-next-line
275
- const fn = ( await import ( href ) ) . default
275
+ const fn = pluginMod . default
276
276
277
277
if ( Object . keys ( info . tests ) . length === 0 ) {
278
278
t . pass ( info . ruleId + ': no tests' )
0 commit comments