-
Notifications
You must be signed in to change notification settings - Fork 463
/
apidoc.html
2076 lines (1817 loc) · 57.7 KB
/
apidoc.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="JSLint API Doc">
<title>JSLint apidoc</title>
<style>
/* jslint utility2:true */
/*csslint*/
body {
margin: 0;
padding: 20px;
}
.apidocCodeCommentSpan,
.apidocCodeKeywordSpan {
background: royalblue;
color: white;
}
.apidocCodeCommentSpan {
display: block;
}
.apidocCodePre {
background: #eef;
border: 1px solid;
font-size: 14px;
overflow-wrap: break-word;
padding: 5px;
white-space: pre-wrap;
}
.apidocDiv {
color: #555;
font-family: sans-serif;
}
.apidocDiv a[href] {
color: royalblue;
text-decoration: none;
}
.apidocDiv a[href]:hover {
text-decoration: underline;
}
.apidocDiv li a {
display: inline-block;
padding: 8px 0;
}
.apidocDiv ul {
list-style: none;
padding-left: 20px;
}
.apidocFooterDiv {
margin-top: 20px;
text-align: center;
}
.apidocModuleA {
font-size: 24px;
font-weight: bold;
}
.apidocSectionDiv {
border-top: 1px solid;
margin-top: 20px;
}
.apidocSignatureSpan {
color: #666;
white-space: pre-wrap;
}
</style>
</head>
<body>
<div class="apidocDiv">
<h1>API Doc for <a href="https://github.com/jslint-org/jslint">JSLint (v2024.11.24)</a></h1>
<div class="apidocSectionDiv">
<a href="#apidocTableOfContents1" id="apidocTableOfContents1">
<h1>Table of Contents</h1>
</a>
<ul>
<li>
<a class="apidocModuleA" href="#apidoc.module.%22.%2Fjslint.mjs%22">Module "./jslint.mjs"</a>
<ul>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.assertErrorThrownAsync">1.
function assertErrorThrownAsync<span class="apidocSignatureSpan">(asyncFunc, regexp)</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.assertJsonEqual">2.
function assertJsonEqual<span class="apidocSignatureSpan">(aa, bb, message)</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.assertOrThrow">3.
function assertOrThrow<span class="apidocSignatureSpan">(condition, message)</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.debugInline">4.
function debugInline<span class="apidocSignatureSpan">(...argv)</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.fsWriteFileWithParents">5.
function fsWriteFileWithParents<span class="apidocSignatureSpan">(pathname, data)</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.globExclude">6.
function globExclude<span class="apidocSignatureSpan">({
excludeList = [],
includeList = [],
pathnameList = []
})</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.htmlEscape">7.
function htmlEscape<span class="apidocSignatureSpan">(str)</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.jslint">8.
function jslint<span class="apidocSignatureSpan">(
source = "",
option_dict = empty(),
global_list = []
)</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.jslint_apidoc">9.
function jslint_apidoc<span class="apidocSignatureSpan">({
example_list,
github_repo,
module_list,
package_name,
pathname,
version
})</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.jslint_assert">10.
function jslint_assert<span class="apidocSignatureSpan">(condition, message)</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.jslint_cli">11.
function jslint_cli<span class="apidocSignatureSpan">({
console_error,
console_log,
file,
import_meta_url,
mode_cli,
mode_noop,
option,
process_argv,
process_env,
process_exit,
source
})</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.jslint_phase1_split">12.
function jslint_phase1_split<span class="apidocSignatureSpan">()</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.jslint_phase2_lex">13.
function jslint_phase2_lex<span class="apidocSignatureSpan">(state)</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.jslint_phase3_parse">14.
function jslint_phase3_parse<span class="apidocSignatureSpan">(state)</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.jslint_phase4_walk">15.
function jslint_phase4_walk<span class="apidocSignatureSpan">(state)</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.jslint_phase5_whitage">16.
function jslint_phase5_whitage<span class="apidocSignatureSpan">(state)</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.jslint_report">17.
function jslint_report<span class="apidocSignatureSpan">({
exports,
froms,
functions,
global,
json,
module,
property,
stop,
warnings
})</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.jstestDescribe">18.
function jstestDescribe<span class="apidocSignatureSpan">(description, testFunction)</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.jstestIt">19.
function jstestIt<span class="apidocSignatureSpan">(description, testFunction, mode)</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.jstestOnExit">20.
function jstestOnExit<span class="apidocSignatureSpan">(exitCode, mode)</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.moduleFsInit">21.
function moduleFsInit<span class="apidocSignatureSpan">()</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.noop">22.
function noop<span class="apidocSignatureSpan">(val)</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.objectDeepCopyWithKeysSorted">23.
function objectDeepCopyWithKeysSorted<span class="apidocSignatureSpan">(obj)</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.v8CoverageListMerge">24.
function v8CoverageListMerge<span class="apidocSignatureSpan">(processCovs)</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.v8CoverageReportCreate">25.
function v8CoverageReportCreate<span class="apidocSignatureSpan">({
consoleError,
coverageDir,
processArgv = []
})</span>
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.jslint_charset_ascii">26.
string jslint_charset_ascii
</a>
</li>
<li>
<a class="apidocElementLiA" href="#apidoc.elem.%22.%2Fjslint.mjs%22.jslint_edition">27.
string jslint_edition
</a>
</li>
</ul>
</li>
</ul>
</div>
<div class="apidocSectionDiv">
<h1><a href="#apidoc.module.%22.%2Fjslint.mjs%22" id="apidoc.module.%22.%2Fjslint.mjs%22">Module "./jslint.mjs"</a></h1>
<ul>
<li>
<h2>
<a href="#apidoc.elem.%22.%2Fjslint.mjs%22.assertErrorThrownAsync" id="apidoc.elem.%22.%2Fjslint.mjs%22.assertErrorThrownAsync">1.
function assertErrorThrownAsync<span class="apidocSignatureSpan">(asyncFunc, regexp)</span>
</a>
</h2>
</li>
<li>Description and source-code:<pre class="apidocCodePre">async function assertErrorThrownAsync(asyncFunc, regexp) {
<span class="apidocCodeCommentSpan">
// This function will assert calling <asyncFunc> throws an error.
</span> let err;
try {
await asyncFunc();
} catch (errCaught) {
err = errCaught;
}
assertOrThrow(err, "No error thrown.");
assertOrThrow(
!regexp || new RegExp(regexp).test(err.message),
err
);
}</pre></li>
<li>Example usage:<pre class="apidocCodePre">...
jstestDescribe((
"test v8CoverageReportCreate handling-behavior"
), function testBehaviorV8CoverageReportCreate() {
jstestIt((
"test null-case handling-behavior"
), async function () {
await <span class="apidocCodeKeywordSpan">assertErrorThrownAsync</span>(function () {
return v8CoverageReportCreate({});
}, "invalid coverageDir");
});
jstestIt((
"test coverage-report jslint.mjs handling-behavior"
), async function () {
// test remove-old-coverage handling-behavior
...</pre></li>
<li>
<h2>
<a href="#apidoc.elem.%22.%2Fjslint.mjs%22.assertJsonEqual" id="apidoc.elem.%22.%2Fjslint.mjs%22.assertJsonEqual">2.
function assertJsonEqual<span class="apidocSignatureSpan">(aa, bb, message)</span>
</a>
</h2>
</li>
<li>Description and source-code:<pre class="apidocCodePre">function assertJsonEqual(aa, bb, message) {
<span class="apidocCodeCommentSpan">
// This function will assert JSON.stringify(<aa>) === JSON.stringify(<bb>).
</span> aa = JSON.stringify(objectDeepCopyWithKeysSorted(aa), undefined, 1);
bb = JSON.stringify(objectDeepCopyWithKeysSorted(bb), undefined, 1);
if (aa !== bb) {
throw new Error(
"\n" + aa + "\n!==\n" + bb
+ (
typeof message === "string"
? " - " + message
: message
? " - " + JSON.stringify(message)
: ""
)
);
}
}</pre></li>
<li>Example usage:<pre class="apidocCodePre">...
// Debug data1.
// await moduleFs.promises.writeFile(
// ".test_v8_coverage_node_sqlite_merged.json",
// JSON.stringify(objectDeepCopyWithKeysSorted(data1), undefined, 4) + "\n"
// );
<span class="apidocCodeKeywordSpan">assertJsonEqual</span>(data1, data2);
});
});
jstestDescribe((
"test v8CoverageReportCreate handling-behavior"
), function testBehaviorV8CoverageReportCreate() {
jstestIt((
...</pre></li>
<li>
<h2>
<a href="#apidoc.elem.%22.%2Fjslint.mjs%22.assertOrThrow" id="apidoc.elem.%22.%2Fjslint.mjs%22.assertOrThrow">3.
function assertOrThrow<span class="apidocSignatureSpan">(condition, message)</span>
</a>
</h2>
</li>
<li>Description and source-code:<pre class="apidocCodePre">function assertOrThrow(condition, message) {
<span class="apidocCodeCommentSpan">
// This function will throw <message> if <condition> is falsy.
</span> if (!condition) {
throw (
(!message || typeof message === "string")
? new Error(String(message).slice(0, 2048))
: message
);
}
}</pre></li>
<li>Example usage:<pre class="apidocCodePre">...
assertJsonEqual(1, 2, "undefined");
});
await assertErrorThrownAsync(function () {
assertJsonEqual(1, 2, {});
});
// test assertOrThrow error handling-behavior
await assertErrorThrownAsync(function () {
<span class="apidocCodeKeywordSpan">assertOrThrow</span>(undefined, "undefined");
});
await assertErrorThrownAsync(function () {
assertOrThrow(undefined, new Error());
});
});
});
...</pre></li>
<li>
<h2>
<a href="#apidoc.elem.%22.%2Fjslint.mjs%22.debugInline" id="apidoc.elem.%22.%2Fjslint.mjs%22.debugInline">4.
function debugInline<span class="apidocSignatureSpan">(...argv)</span>
</a>
</h2>
</li>
<li>Description and source-code:<pre class="apidocCodePre">function debug(...argv) {
<span class="apidocCodeCommentSpan">
// This function will print <argv> to stderr and then return <argv>[0].
</span> __consoleError("\n\ndebugInline");
__consoleError(...argv);
__consoleError("\n");
return argv[0];
}</pre></li>
<li>Example usage:<pre class="apidocCodePre">N/A</pre></li>
<li>
<h2>
<a href="#apidoc.elem.%22.%2Fjslint.mjs%22.fsWriteFileWithParents" id="apidoc.elem.%22.%2Fjslint.mjs%22.fsWriteFileWithParents">5.
function fsWriteFileWithParents<span class="apidocSignatureSpan">(pathname, data)</span>
</a>
</h2>
</li>
<li>Description and source-code:<pre class="apidocCodePre">async function fsWriteFileWithParents(pathname, data) {
<span class="apidocCodeCommentSpan">
// This function will write <data> to <pathname> and lazy-mkdirp if necessary.
</span> await moduleFsInit();
// Try writing to pathname.
try {
await moduleFs.promises.writeFile(pathname, data);
} catch (ignore) {
// Lazy mkdirp.
await moduleFs.promises.mkdir(modulePath.dirname(pathname), {
recursive: true
});
// Retry writing to pathname.
await moduleFs.promises.writeFile(pathname, data);
}
console.error("wrote file " + pathname);
}</pre></li>
<li>Example usage:<pre class="apidocCodePre">...
}
]
}, undefined, 4)
]
].map(async function ([
file, data
]) {
await <span class="apidocCodeKeywordSpan">fsWriteFileWithParents</span>(file, data);
}));
await jslint.jslint_cli({
console_error: noop, // comment to debug
mode_cli: true,
process_argv: [
"node", "jslint.mjs",
"v8_coverage_report=.tmp/coverage_misc"
...</pre></li>
<li>
<h2>
<a href="#apidoc.elem.%22.%2Fjslint.mjs%22.globExclude" id="apidoc.elem.%22.%2Fjslint.mjs%22.globExclude">6.
function globExclude<span class="apidocSignatureSpan">({
excludeList = [],
includeList = [],
pathnameList = []
})</span>
</a>
</h2>
</li>
<li>Description and source-code:<pre class="apidocCodePre">function globExclude({
excludeList = [],
includeList = [],
pathnameList = []
}) {
<span class="apidocCodeCommentSpan">
// This function will
// 1. Exclude pathnames in <pathnameList> that don't match glob-patterns in
// <includeList>.
// 2. Exclude pathnames in <pathnameList> that match glob-patterns in
// <excludeList>.
</span> function globAssertNotWeird(list, name) {
// This function will check if <list> of strings contain weird characters.
[
[
"\n", (
/^.*?([\u0000-\u0007\r]).*/gm
)
],
[
"\r", (
/^.*?([\n]).*/gm
)
]
].forEach(function ([
separator, rgx
]) {
list.join(separator).replace(rgx, function (match0, char) {
throw new Error(
"Weird character "
+ JSON.stringify(char)
+ " found in " + name + " "
+ JSON.stringify(match0)
);
});
});
}
function globToRegexp(pattern) {
// This function will translate glob <pattern> to javascript-regexp,
// which javascript can then use to "glob" pathnames.
let ii = 0;
let isClass = false;
let strClass = "";
let strRegex = "";
pattern = pattern.replace((
/\/\/+/g
), "/");
pattern = pattern.replace((
/\*\*\*+/g
), "**");
pattern.replace((
/\\\\|\\\[|\\\]|\[|\]|./g
), function (match0) {
switch (match0) {
case "[":
if (isClass) {
strClass += "[";
return;
}
strClass += "\u0000";
strRegex += "\u0000";
isClass = true;
return;
case "]":
if (isClass) {
isClass = false;...
}
</pre></li>
<li>Example usage:<pre class="apidocCodePre">...
"test/support/helper.js": (
/^test\/support\/helper\.js$/gm
)
}).forEach(function ([
pattern, rgx
]) {
assertJsonEqual(
<span class="apidocCodeKeywordSpan">globExclude</span>({
excludeList: [
pattern
]
}).excludeList[0].source,
rgx.source
);
assertJsonEqual(
...</pre></li>
<li>
<h2>
<a href="#apidoc.elem.%22.%2Fjslint.mjs%22.htmlEscape" id="apidoc.elem.%22.%2Fjslint.mjs%22.htmlEscape">7.
function htmlEscape<span class="apidocSignatureSpan">(str)</span>
</a>
</h2>
</li>
<li>Description and source-code:<pre class="apidocCodePre">function htmlEscape(str) {
<span class="apidocCodeCommentSpan">
// This function will make <str> html-safe by escaping & < >.
</span> return String(str).replace((
/&/g
), "&amp;").replace((
/</g
), "&lt;").replace((
/>/g
), "&gt;");
}</pre></li>
<li>Example usage:<pre class="apidocCodePre">...
inHole = isHole;
}
chunk += char;
});
lineHtml += htmlEscape(chunk);
break;
default:
lineHtml += <span class="apidocCodeKeywordSpan">htmlEscape</span>(line);
}
html += String(`
<pre>
<span class="lineno">
<a href="#${lineId}" id="${lineId}">${String(ii + 1).padStart(5, " ")}.</a>
</span>
<span class="count
...</pre></li>
<li>
<h2>
<a href="#apidoc.elem.%22.%2Fjslint.mjs%22.jslint" id="apidoc.elem.%22.%2Fjslint.mjs%22.jslint">8.
function jslint<span class="apidocSignatureSpan">(
source = "",
option_dict = empty(),
global_list = []
)</span>
</a>
</h2>
</li>
<li>Description and source-code:<pre class="apidocCodePre">function jslint(
source = "", // A text to analyze.
option_dict = empty(), // An object whose keys correspond to option
// ... names.
global_list = [] // An array of strings containing global
// ... variables that the file is allowed
// ... readonly access.
) {
<span class="apidocCodeCommentSpan">
// The jslint function itself.
</span> let catch_list = []; // The array containing all catch-blocks.
let catch_stack = [ // The stack of catch-blocks.
{
context: empty()
}
];
let cause_dict = empty(); // The object of test-causes.
let directive_list = []; // The directive comments.
let export_dict = empty(); // The exported names and values.
let function_list = []; // The array containing all functions.
let function_stack = []; // The stack of functions.
let global_dict = empty(); // The object containing the global
// ... declarations.
let import_list = []; // The array collecting all import-from strings.
let line_list = String( // The array containing source lines.
"\n" + source
).split(jslint_rgx_crlf).map(function (line_source) {
return {
line_source
};
});
let mode_stop = false; // true if JSLint cannot finish.
let property_dict = empty(); // The object containing the tallied
// ... property names.
let state = empty(); // jslint state-object to be passed between
// jslint functions.
let syntax_dict = empty(); // The object containing the parser.
let tenure = empty(); // The predefined property registry.
let token_global = { // The global object; the outermost context.
async: 0,
body: true,
context: empty(),
finally: 0,
from: 0,
...
}
</pre></li>
<li>Example usage:<pre class="apidocCodePre">...
import fs from "fs";
(async function () {
let result;
let source = "function foo() {console.log(\u0027hello world\u0027);}\n";
// Create JSLint report from <source> in javascript.
result = jslint.<span class="apidocCodeKeywordSpan">jslint</span>(source);
result = jslint.jslint_report(result);
result = `<body class="JSLINT_ JSLINT_REPORT_">\n${result}</body>\n`;
await fs.promises.mkdir(".artifact/", {recursive: true});
await fs.promises.writeFile(".artifact/jslint_report_hello.html", result);
console.error("wrote file .artifact/jslint_report_hello.html");
}());
...</pre></li>
<li>
<h2>
<a href="#apidoc.elem.%22.%2Fjslint.mjs%22.jslint_apidoc" id="apidoc.elem.%22.%2Fjslint.mjs%22.jslint_apidoc">9.
function jslint_apidoc<span class="apidocSignatureSpan">({
example_list,
github_repo,
module_list,
package_name,
pathname,
version
})</span>
</a>
</h2>
</li>
<li>Description and source-code:<pre class="apidocCodePre">async function jslint_apidoc({
example_list,
github_repo,
module_list,
package_name,
pathname,
version
}) {
<span class="apidocCodeCommentSpan">
// This function will create API Doc from <module_list>.
</span> let elem_ii = 0;
let html;
function elem_create(moduleObj, key, moduleName) {
// This function will create a sub API Doc from elem <moduleObj>[<key>].
let example = "N/A";
let id = encodeURIComponent("apidoc.elem." + moduleName + "." + key);
let name;
let signature;
let source;
name = htmlEscape((typeof moduleObj[key]) + " " + key);
if (typeof moduleObj[key] !== "function") {
return {
name,
signature: (`
<a class="apidocElementLiA" href="#${id}">
${name}
</a>
`),
source: (`
<li>
<h2>
<a href="#${id}" id="${id}">
${name}
</a>
</h2>
</li>
`)
};
}
// init source
source = htmlEscape(trim_start(moduleObj[key].toString()));
// init signature
source = source.replace((
/(\([\S\s]*?\)) \{/
), function (match0, match1) {
signature = htmlEscape(
match1.replace((
/ *?\/\*[\S\s]*?\*\/ */g
), "").replace((
/ *?\/\/.*/g
), "").replace((
/\n{2,}/g
), "\n")
);
return match0;
});
// init comment
source = source.replace((
/\n(?:\/\/.*?\n)+\n/
), "<span class=\"apidocCodeCommentSpan\">$&</span>");
// init example
example_list.some(function (example2) {
example2.replace(
new RegExp((
"((?:\\n.*?){8}(function )?)\\b"
+ key
+ "(\\((?:.*?\\n){8})"
), "g"),
...
}
</pre></li>
<li>Example usage:<pre class="apidocCodePre">...
command[1] = command.slice(1).join("=");
switch (command[0]) {
// PR-362 - Add API Doc.
case "jslint_apidoc":
await <span class="apidocCodeKeywordSpan">jslint_apidoc</span>(Object.assign(JSON.parse(process_argv[3]), {
pathname: command[1]
}));
return;
// PR-363 - Add command jslint_report.
case "jslint_report":
...</pre></li>
<li>
<h2>
<a href="#apidoc.elem.%22.%2Fjslint.mjs%22.jslint_assert" id="apidoc.elem.%22.%2Fjslint.mjs%22.jslint_assert">10.
function jslint_assert<span class="apidocSignatureSpan">(condition, message)</span>
</a>
</h2>
</li>
<li>Description and source-code:<pre class="apidocCodePre">function jslint_assert(condition, message) {
<span class="apidocCodeCommentSpan">
// This function will throw <message> if <condition> is falsy.
</span> if (condition) {
return condition;
}
throw new Error(
`This was caused by a bug in JSLint.
Please open an issue with this stack-trace (and possible example-code) at
https://github.com/jslint-org/jslint/issues.
edition = "${jslint_edition}";
${String(message).slice(0, 2000)}`
);
}</pre></li>
<li>Example usage:<pre class="apidocCodePre">...
// ["let aa={};", "whitage", "opener", "", 0]
test_cause("opener");
// Probably deadcode.
// case "${}":
<span class="apidocCodeKeywordSpan">jslint_assert</span>(
!(left.id + right.id === "${}"),
"Expected !(left.id + right.id === \"${}\")."
);
switch (left.id + right.id) {
case "()":
case "[]":
case "{}":
...</pre></li>
<li>
<h2>
<a href="#apidoc.elem.%22.%2Fjslint.mjs%22.jslint_cli" id="apidoc.elem.%22.%2Fjslint.mjs%22.jslint_cli">11.
function jslint_cli<span class="apidocSignatureSpan">({
console_error,
console_log,
file,
import_meta_url,
mode_cli,
mode_noop,
option,
process_argv,
process_env,
process_exit,
source
})</span>
</a>
</h2>
</li>
<li>Description and source-code:<pre class="apidocCodePre">async function jslint_cli({
console_error,
console_log,
file,
import_meta_url,
mode_cli,
mode_noop,
option,
process_argv,
process_env,
process_exit,
source
}) {
<span class="apidocCodeCommentSpan">
// This function will run jslint from nodejs-cli.
</span> let command;
let data;
let exit_code = 0;
let mode_report;
let mode_wrapper_vim;
let result;
function jslint_from_file({
code,
file,
line_offset = 0,
mode_conditional,
option = empty()
}) {
let result_from_file;
if (
mode_conditional
&& !(
/^\/\*jslint\b/m
).test(code.slice(0, 65536))
) {
return;
}
option = Object.assign(empty(), option, {
file
});
switch ((
/\.\w+?$|$/m
).exec(file)[0]) {
case ".html":
// Recursively jslint embedded "<script>\n...\n</script>".
code.replace((
/^<script\b[^>]*?>\n([\S\s]*?\n)<\/script>$/gm
), function (ignore, match1, ii) {
jslint_from_file({
code: match1,
file: file + ".<script>.js",
line_offset: string_line_count(code.slice(0, ii)) + 1,
option: Object.assign(empty(), {
browser: true
}, option)
});
return "";
});
return;
case ".md":
// Recursively jslint embedded "node --eval '\n...\n'".
jslint_node_eval({
code,
file,
mode_conditional: true,
option
});
return;
case ".sh":
// Recursively jslint embedded "node --eval '\n...\n'".
jslint_node_eval({
code,
file,
option
});
return;
...
}
</pre></li>
<li>Example usage:<pre class="apidocCodePre">...
}, undefined, 4)
]
].map(async function ([
file, data
]) {
await fsWriteFileWithParents(file, data);
}));
await jslint.<span class="apidocCodeKeywordSpan">jslint_cli</span>({
console_error: noop, // comment to debug
mode_cli: true,
process_argv: [
"node", "jslint.mjs",
"v8_coverage_report=.tmp/coverage_misc"
// "node", ".tmp/coverage_misc/aa.js"
]
...</pre></li>
<li>
<h2>
<a href="#apidoc.elem.%22.%2Fjslint.mjs%22.jslint_phase1_split" id="apidoc.elem.%22.%2Fjslint.mjs%22.jslint_phase1_split">12.
function jslint_phase1_split<span class="apidocSignatureSpan">()</span>