2
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
+ // @ts -check
5
6
6
7
const filter = require ( 'gulp-filter' ) ;
7
8
const es = require ( 'event-stream' ) ;
@@ -20,6 +21,10 @@ const copyrightHeaderLines = [
20
21
' *--------------------------------------------------------------------------------------------*/' ,
21
22
] ;
22
23
24
+ /**
25
+ * @param {string[] | NodeJS.ReadWriteStream } some
26
+ * @param {boolean } linting
27
+ */
23
28
function hygiene ( some , linting = true ) {
24
29
const eslint = require ( './gulp-eslint' ) ;
25
30
const gulpstylelint = require ( './stylelint' ) ;
@@ -39,6 +44,7 @@ function hygiene(some, linting = true) {
39
44
} ) ;
40
45
41
46
const unicode = es . through ( function ( file ) {
47
+ /** @type {string[] } */
42
48
const lines = file . contents . toString ( 'utf8' ) . split ( / \r \n | \r | \n / ) ;
43
49
file . __lines = lines ;
44
50
const allowInComments = lines . some ( line => / a l l o w - a n y - u n i c o d e - c o m m e n t - f i l e / . test ( line ) ) ;
@@ -76,6 +82,7 @@ function hygiene(some, linting = true) {
76
82
} ) ;
77
83
78
84
const indentation = es . through ( function ( file ) {
85
+ /** @type {string[] } */
79
86
const lines = file . __lines || file . contents . toString ( 'utf8' ) . split ( / \r \n | \r | \n / ) ;
80
87
file . __lines = lines ;
81
88
@@ -125,14 +132,13 @@ function hygiene(some, linting = true) {
125
132
) ;
126
133
errorCount ++ ;
127
134
}
128
- cb ( null , file ) ;
135
+ cb ( undefined , file ) ;
129
136
} catch ( err ) {
130
137
cb ( err ) ;
131
138
}
132
139
} ) ;
133
140
134
141
let input ;
135
-
136
142
if ( Array . isArray ( some ) || typeof some === 'string' || ! some ) {
137
143
const options = { base : '.' , follow : true , allowEmpty : true } ;
138
144
if ( some ) {
@@ -164,6 +170,7 @@ function hygiene(some, linting = true) {
164
170
. pipe ( filter ( copyrightFilter ) )
165
171
. pipe ( copyrights ) ;
166
172
173
+ /** @type {import('stream').Stream[] } */
167
174
const streams = [
168
175
result . pipe ( filter ( tsFormattingFilter ) ) . pipe ( formatting )
169
176
] ;
@@ -220,6 +227,9 @@ function hygiene(some, linting = true) {
220
227
221
228
module . exports . hygiene = hygiene ;
222
229
230
+ /**
231
+ * @param {string[] } paths
232
+ */
223
233
function createGitIndexVinyls ( paths ) {
224
234
const cp = require ( 'child_process' ) ;
225
235
const repositoryPath = process . cwd ( ) ;
@@ -294,12 +304,14 @@ if (require.main === module) {
294
304
295
305
createGitIndexVinyls ( some )
296
306
. then (
297
- ( vinyls ) =>
298
- new Promise ( ( c , e ) =>
307
+ ( vinyls ) => {
308
+ /** @type {Promise<void> } */
309
+ return ( new Promise ( ( c , e ) =>
299
310
hygiene ( es . readArray ( vinyls ) . pipe ( filter ( all ) ) )
300
311
. on ( 'end' , ( ) => c ( ) )
301
312
. on ( 'error' , e )
302
- )
313
+ ) )
314
+ }
303
315
)
304
316
. catch ( ( err ) => {
305
317
console . error ( ) ;
0 commit comments