File tree Expand file tree Collapse file tree 3 files changed +61
-9
lines changed Expand file tree Collapse file tree 3 files changed +61
-9
lines changed Original file line number Diff line number Diff line change 64
64
"build" : " rm -fr ./dist && NODE_ENV=production babel ./src --out-dir ./dist --copy-files --source-maps" ,
65
65
"create-readme" : " gitdown ./.README/README.md --output-file ./README.md && npm run add-assertions" ,
66
66
"lint" : " eslint ./src ./test" ,
67
- "test-cov" : " BABEL_ENV=test nyc mocha --recursive --require @babel/register --reporter progress" ,
68
- "test" : " BABEL_ENV=test nyc --reporter text-summary mocha --recursive --require @babel/register --reporter progress"
67
+ "test-cov" : " BABEL_ENV=test nyc mocha --recursive --require @babel/register --reporter progress --timeout 5000 " ,
68
+ "test" : " BABEL_ENV=test nyc --reporter text-summary mocha --recursive --require @babel/register --reporter progress --timeout 5000 "
69
69
},
70
70
"nyc" : {
71
71
"require" : [
Original file line number Diff line number Diff line change @@ -108,14 +108,17 @@ export default iterateJsdoc(({
108
108
source = source . slice ( idx ) ;
109
109
110
110
source = source . replace ( exampleCodeRegex , ( n0 , n1 ) => {
111
- if ( ! n1 ) {
112
- return n0 ;
111
+ let nonJSPreface ;
112
+ let nonJSPrefaceLineCount ;
113
+ if ( n1 ) {
114
+ const index = n0 . indexOf ( n1 ) ;
115
+ nonJSPreface = n0 . slice ( 0 , index ) ;
116
+ nonJSPrefaceLineCount = countChars ( nonJSPreface , '\n' ) ;
117
+ } else {
118
+ nonJSPreface = '' ;
119
+ nonJSPrefaceLineCount = 0 ;
113
120
}
114
121
115
- const index = n0 . indexOf ( n1 ) ;
116
- const nonJSPreface = n0 . slice ( 0 , index ) ;
117
- const nonJSPrefaceLineCount = countChars ( nonJSPreface , '\n' ) ;
118
-
119
122
nonJSPrefacingLines += nonJSPrefaceLineCount ;
120
123
121
124
// Ignore `preMatch` delta if newlines here
@@ -127,7 +130,7 @@ export default iterateJsdoc(({
127
130
nonJSPrefacingCols += colDelta + nonJSPreface . length ;
128
131
}
129
132
130
- return n1 ;
133
+ return n1 || n0 ;
131
134
} ) ;
132
135
}
133
136
Original file line number Diff line number Diff line change @@ -297,6 +297,55 @@ export default {
297
297
noDefaultExampleRules : true
298
298
}
299
299
}
300
+ } ,
301
+ {
302
+ code : `
303
+ /**
304
+ * @example quux2()
305
+ */
306
+ function quux2 () {
307
+
308
+ }
309
+ ` ,
310
+ errors : [
311
+ {
312
+ message : '@example error (semi): Missing semicolon.'
313
+ }
314
+ ] ,
315
+ settings : {
316
+ jsdoc : {
317
+ matchingFileName : 'test/jsdocUtils.js'
318
+ }
319
+ }
320
+ } ,
321
+ {
322
+ code : `
323
+ /**
324
+ * @example // begin
325
+ alert('hello')
326
+ // end
327
+ */
328
+ function quux () {
329
+
330
+ }
331
+ ` ,
332
+ errors : [
333
+ {
334
+ message : '@example warning (semi): Missing semicolon.'
335
+ }
336
+ ] ,
337
+ settings : {
338
+ jsdoc : {
339
+ baseConfig : {
340
+ rules : {
341
+ semi : [ 'warn' , 'always' ]
342
+ }
343
+ } ,
344
+ eslintrcForExamples : false ,
345
+ exampleCodeRegex : '// begin[\\s\\S]*// end' ,
346
+ noDefaultExampleRules : true
347
+ }
348
+ }
300
349
}
301
350
] ,
302
351
valid : [
You can’t perform that action at this time.
0 commit comments