@jslint-org/jslint 2022.6.21 → 2022.9.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -2
- package/README.md +377 -27
- package/jslint.mjs +231 -158
- package/jslint_wrapper_vscode.js +54 -5
- package/package.json +1 -1
package/jslint.mjs
CHANGED
|
@@ -100,17 +100,17 @@
|
|
|
100
100
|
catch_stack, causes, char, children, clear, closer, closure, code, column,
|
|
101
101
|
concat, consoleError, console_error, console_log, constant, context,
|
|
102
102
|
convert, count, coverageDir, create, cwd, d, dead, debugInline, default,
|
|
103
|
-
delta, devel, directive,
|
|
103
|
+
delta, devel, directive, directive_ignore_line, directive_list, directives,
|
|
104
104
|
dirname, disrupt, dot, edition, elem_list, ellipsis, else, end, endOffset,
|
|
105
105
|
endsWith, entries, env, error, eval, every, example_list, excludeList, exec,
|
|
106
|
-
execArgv, exit, exitCode, export_dict, exports, expression, extra,
|
|
107
|
-
fileList, fileURLToPath, filter, finally, flag, floor, for, forEach,
|
|
106
|
+
execArgv, exit, exitCode, export_dict, exports, expression, extra, fart,
|
|
107
|
+
file, fileList, fileURLToPath, filter, finally, flag, floor, for, forEach,
|
|
108
108
|
formatted_message, free, freeze, from, froms, fsWriteFileWithParents,
|
|
109
109
|
fud_stmt, functionName, function_list, function_stack, functions, get,
|
|
110
110
|
getset, github_repo, globExclude, global, global_dict, global_list,
|
|
111
111
|
holeList, htmlEscape, id, identifier, import, import_list, import_meta_url,
|
|
112
112
|
inc, includeList, indent2, index, indexOf, init, initial, isArray,
|
|
113
|
-
isBlockCoverage, isHole, isNaN, is_equal,
|
|
113
|
+
isBlockCoverage, isHole, isNaN, is_equal, is_weird, join, jslint,
|
|
114
114
|
jslint_apidoc, jslint_assert, jslint_charset_ascii, jslint_cli,
|
|
115
115
|
jslint_edition, jslint_phase1_split, jslint_phase2_lex, jslint_phase3_parse,
|
|
116
116
|
jslint_phase4_walk, jslint_phase5_whitage, jslint_report, json,
|
|
@@ -153,7 +153,7 @@ let debugInline = (function () {
|
|
|
153
153
|
return argv[0];
|
|
154
154
|
}
|
|
155
155
|
debug(); // Coverage-hack.
|
|
156
|
-
__consoleError = console.error;
|
|
156
|
+
__consoleError = console.error; //jslint-ignore-line
|
|
157
157
|
return debug;
|
|
158
158
|
}());
|
|
159
159
|
let jslint_charset_ascii = (
|
|
@@ -165,7 +165,7 @@ let jslint_charset_ascii = (
|
|
|
165
165
|
+ "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
|
|
166
166
|
+ "`abcdefghijklmnopqrstuvwxyz{|}~\u007f"
|
|
167
167
|
);
|
|
168
|
-
let jslint_edition = "v2022.
|
|
168
|
+
let jslint_edition = "v2022.9.20";
|
|
169
169
|
let jslint_export; // The jslint object to be exported.
|
|
170
170
|
let jslint_fudge = 1; // Fudge starting line and starting
|
|
171
171
|
// ... column to 1.
|
|
@@ -860,11 +860,22 @@ function jslint(
|
|
|
860
860
|
c,
|
|
861
861
|
d
|
|
862
862
|
);
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
863
|
+
|
|
864
|
+
// Issue #408
|
|
865
|
+
// Warnings that should be ignored sometimes suppress legitimate warnings.
|
|
866
|
+
|
|
867
|
+
if (the_warning.directive_ignore_line) {
|
|
868
|
+
return the_warning;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
// If there is already a warning on this token, suppress the new one. It is
|
|
872
|
+
// likely that the first warning will be the most meaningful.
|
|
873
|
+
|
|
874
|
+
if (the_token.warning) {
|
|
866
875
|
warning_list.pop();
|
|
876
|
+
return the_warning;
|
|
867
877
|
}
|
|
878
|
+
the_token.warning = the_warning;
|
|
868
879
|
return the_warning;
|
|
869
880
|
}
|
|
870
881
|
|
|
@@ -1014,6 +1025,7 @@ function jslint(
|
|
|
1014
1025
|
break;
|
|
1015
1026
|
|
|
1016
1027
|
// PR-347 - Disable warning "missing_browser".
|
|
1028
|
+
//
|
|
1017
1029
|
// case "missing_browser":
|
|
1018
1030
|
// mm = `/*global*/ requires the Assume a browser option.`;
|
|
1019
1031
|
// break;
|
|
@@ -1098,6 +1110,7 @@ function jslint(
|
|
|
1098
1110
|
break;
|
|
1099
1111
|
|
|
1100
1112
|
// PR-347 - Disable warning "unexpected_directive_a".
|
|
1113
|
+
//
|
|
1101
1114
|
// case "unexpected_directive_a":
|
|
1102
1115
|
// mm = `When using modules, don't use directive '/\u002a${a}'.`;
|
|
1103
1116
|
// break;
|
|
@@ -1219,12 +1232,12 @@ function jslint(
|
|
|
1219
1232
|
if (option_dict.trace) {
|
|
1220
1233
|
warning.stack_trace = new Error().stack;
|
|
1221
1234
|
}
|
|
1222
|
-
if (warning.
|
|
1235
|
+
if (warning.directive_ignore_line) {
|
|
1223
1236
|
|
|
1224
1237
|
// test_cause:
|
|
1225
|
-
// ["0 //jslint-
|
|
1238
|
+
// ["0 //jslint-ignore-line", "semicolon", "directive_ignore_line", "", 0]
|
|
1226
1239
|
|
|
1227
|
-
test_cause("
|
|
1240
|
+
test_cause("directive_ignore_line");
|
|
1228
1241
|
return warning;
|
|
1229
1242
|
}
|
|
1230
1243
|
warning_list.push(warning);
|
|
@@ -1328,6 +1341,7 @@ function jslint(
|
|
|
1328
1341
|
);
|
|
1329
1342
|
|
|
1330
1343
|
// PR-347 - Disable warning "missing_browser".
|
|
1344
|
+
//
|
|
1331
1345
|
// if (!option_dict.browser) {
|
|
1332
1346
|
// directive_list.forEach(function (comment) {
|
|
1333
1347
|
// if (comment.directive === "global") {
|
|
@@ -2413,7 +2427,7 @@ function jslint_phase2_lex(state) {
|
|
|
2413
2427
|
if (!option_dict.devel && jslint_rgx_todo.test(snippet)) {
|
|
2414
2428
|
|
|
2415
2429
|
// test_cause:
|
|
2416
|
-
// ["//todo", "lex_comment", "todo_comment", "(comment)", 1] //jslint-
|
|
2430
|
+
// ["//todo", "lex_comment", "todo_comment", "(comment)", 1] //jslint-ignore-line
|
|
2417
2431
|
|
|
2418
2432
|
warn("todo_comment", the_comment);
|
|
2419
2433
|
}
|
|
@@ -2700,6 +2714,7 @@ function jslint_phase2_lex(state) {
|
|
|
2700
2714
|
return char_after("]");
|
|
2701
2715
|
|
|
2702
2716
|
// PR-362 - Relax regexp-warning against using <space>.
|
|
2717
|
+
//
|
|
2703
2718
|
// case " ":
|
|
2704
2719
|
//
|
|
2705
2720
|
// // test_cause:
|
|
@@ -2780,6 +2795,7 @@ function jslint_phase2_lex(state) {
|
|
|
2780
2795
|
return;
|
|
2781
2796
|
|
|
2782
2797
|
// PR-362 - Relax regexp-warning against using <space>.
|
|
2798
|
+
//
|
|
2783
2799
|
// case " ":
|
|
2784
2800
|
//
|
|
2785
2801
|
// // test_cause:
|
|
@@ -3278,19 +3294,20 @@ function jslint_phase2_lex(state) {
|
|
|
3278
3294
|
|
|
3279
3295
|
switch (key) {
|
|
3280
3296
|
case "beta": // Enable experimental warnings.
|
|
3281
|
-
case "bitwise": // Allow bitwise
|
|
3297
|
+
case "bitwise": // Allow bitwise operator.
|
|
3282
3298
|
case "browser": // Assume browser environment.
|
|
3283
|
-
case "convert": // Allow conversion
|
|
3299
|
+
case "convert": // Allow conversion operator.
|
|
3284
3300
|
case "couch": // Assume CouchDb environment.
|
|
3285
3301
|
case "devel": // Allow console.log() and friends.
|
|
3286
3302
|
case "ecma": // Assume ECMAScript environment.
|
|
3287
3303
|
case "eval": // Allow eval().
|
|
3304
|
+
case "fart": // Allow complex fat-arrow.
|
|
3288
3305
|
case "for": // Allow for-statement.
|
|
3289
3306
|
case "getset": // Allow get() and set().
|
|
3290
3307
|
case "indent2": // Use 2-space indent.
|
|
3291
3308
|
case "long": // Allow long lines.
|
|
3292
3309
|
case "node": // Assume Node.js environment.
|
|
3293
|
-
case "nomen": // Allow weird property
|
|
3310
|
+
case "nomen": // Allow weird property name.
|
|
3294
3311
|
case "single": // Allow single-quote strings.
|
|
3295
3312
|
case "subscript": // Allow identifier in subscript-notation.
|
|
3296
3313
|
case "test_cause": // Test jslint's causes.
|
|
@@ -3336,12 +3353,16 @@ console.log(JSON.stringify(Object.keys(window).sort(), undefined, 4));
|
|
|
3336
3353
|
|
|
3337
3354
|
"AbortController",
|
|
3338
3355
|
// "Buffer",
|
|
3339
|
-
"
|
|
3356
|
+
// "Crypto",
|
|
3357
|
+
// "CryptoKey",
|
|
3340
3358
|
"Event",
|
|
3341
3359
|
"EventTarget",
|
|
3342
3360
|
"MessageChannel",
|
|
3343
3361
|
"MessageEvent",
|
|
3344
3362
|
"MessagePort",
|
|
3363
|
+
// "Request",
|
|
3364
|
+
// "Response",
|
|
3365
|
+
// "SubtleCrypto",
|
|
3345
3366
|
"TextDecoder",
|
|
3346
3367
|
"TextEncoder",
|
|
3347
3368
|
"URL",
|
|
@@ -3355,7 +3376,9 @@ console.log(JSON.stringify(Object.keys(window).sort(), undefined, 4));
|
|
|
3355
3376
|
"clearInterval",
|
|
3356
3377
|
"clearTimeout",
|
|
3357
3378
|
// "console",
|
|
3379
|
+
// "crypto",
|
|
3358
3380
|
// "exports",
|
|
3381
|
+
// "fetch",
|
|
3359
3382
|
// "global",
|
|
3360
3383
|
// "module",
|
|
3361
3384
|
"performance",
|
|
@@ -3365,7 +3388,6 @@ console.log(JSON.stringify(Object.keys(window).sort(), undefined, 4));
|
|
|
3365
3388
|
// "setImmediate",
|
|
3366
3389
|
"setInterval",
|
|
3367
3390
|
"setTimeout",
|
|
3368
|
-
"structuredClone",
|
|
3369
3391
|
|
|
3370
3392
|
// Web worker only.
|
|
3371
3393
|
// https://github.com/mdn/content/blob/main/files/en-us/web/api
|
|
@@ -3408,6 +3430,7 @@ console.log(JSON.stringify(Object.keys(window).sort(), undefined, 4));
|
|
|
3408
3430
|
"sessionStorage",
|
|
3409
3431
|
// "setInterval",
|
|
3410
3432
|
// "setTimeout",
|
|
3433
|
+
"structuredClone",
|
|
3411
3434
|
"window"
|
|
3412
3435
|
], "browser");
|
|
3413
3436
|
break;
|
|
@@ -3469,6 +3492,7 @@ import https from "https";
|
|
|
3469
3492
|
|
|
3470
3493
|
case "ecma":
|
|
3471
3494
|
object_assign_from_list(global_dict, [
|
|
3495
|
+
"AggregateError",
|
|
3472
3496
|
"Array",
|
|
3473
3497
|
"ArrayBuffer",
|
|
3474
3498
|
"Atomics",
|
|
@@ -3539,7 +3563,7 @@ import moduleHttps from "https";
|
|
|
3539
3563
|
let result = "";
|
|
3540
3564
|
await new Promise(function (resolve) {
|
|
3541
3565
|
moduleHttps.get((
|
|
3542
|
-
"https://raw.githubusercontent.com/nodejs/node/
|
|
3566
|
+
"https://raw.githubusercontent.com/nodejs/node/v16.x/doc/api"
|
|
3543
3567
|
+ "/globals.md"
|
|
3544
3568
|
), function (res) {
|
|
3545
3569
|
res.on("data", function (chunk) {
|
|
@@ -3562,12 +3586,16 @@ import moduleHttps from "https";
|
|
|
3562
3586
|
object_assign_from_list(global_dict, [
|
|
3563
3587
|
"AbortController",
|
|
3564
3588
|
"Buffer",
|
|
3565
|
-
"
|
|
3589
|
+
// "Crypto",
|
|
3590
|
+
// "CryptoKey",
|
|
3566
3591
|
"Event",
|
|
3567
3592
|
"EventTarget",
|
|
3568
3593
|
"MessageChannel",
|
|
3569
3594
|
"MessageEvent",
|
|
3570
3595
|
"MessagePort",
|
|
3596
|
+
// "Request",
|
|
3597
|
+
// "Response",
|
|
3598
|
+
// "SubtleCrypto",
|
|
3571
3599
|
"TextDecoder",
|
|
3572
3600
|
"TextEncoder",
|
|
3573
3601
|
"URL",
|
|
@@ -3581,7 +3609,9 @@ import moduleHttps from "https";
|
|
|
3581
3609
|
"clearInterval",
|
|
3582
3610
|
"clearTimeout",
|
|
3583
3611
|
"console",
|
|
3612
|
+
// "crypto",
|
|
3584
3613
|
"exports",
|
|
3614
|
+
// "fetch",
|
|
3585
3615
|
"global",
|
|
3586
3616
|
"module",
|
|
3587
3617
|
"performance",
|
|
@@ -3590,8 +3620,7 @@ import moduleHttps from "https";
|
|
|
3590
3620
|
"require",
|
|
3591
3621
|
"setImmediate",
|
|
3592
3622
|
"setInterval",
|
|
3593
|
-
"setTimeout"
|
|
3594
|
-
"structuredClone"
|
|
3623
|
+
"setTimeout"
|
|
3595
3624
|
], "Node.js");
|
|
3596
3625
|
break;
|
|
3597
3626
|
}
|
|
@@ -3658,7 +3687,7 @@ import moduleHttps from "https";
|
|
|
3658
3687
|
) {
|
|
3659
3688
|
|
|
3660
3689
|
// test_cause:
|
|
3661
|
-
// ["/////////////////////////////////////////////////////////////////////////////////", "read_line", "too_long", "", 1] //jslint-
|
|
3690
|
+
// ["/////////////////////////////////////////////////////////////////////////////////", "read_line", "too_long", "", 1] //jslint-ignore-line
|
|
3662
3691
|
|
|
3663
3692
|
warn_at("too_long", line);
|
|
3664
3693
|
}
|
|
@@ -3676,7 +3705,7 @@ import moduleHttps from "https";
|
|
|
3676
3705
|
// Scan each line for following ignore-directives:
|
|
3677
3706
|
// "/*jslint-disable*/"
|
|
3678
3707
|
// "/*jslint-enable*/"
|
|
3679
|
-
// "//jslint-
|
|
3708
|
+
// "//jslint-ignore-line"
|
|
3680
3709
|
|
|
3681
3710
|
if (line_source === "/*jslint-disable*/") {
|
|
3682
3711
|
|
|
@@ -3694,13 +3723,16 @@ import moduleHttps from "https";
|
|
|
3694
3723
|
stop_at("unopened_enable", line);
|
|
3695
3724
|
}
|
|
3696
3725
|
line_disable = undefined;
|
|
3697
|
-
} else if (
|
|
3726
|
+
} else if (
|
|
3727
|
+
line_source.endsWith(" //jslint-ignore-line")
|
|
3728
|
+
|| line_source.endsWith(" //jslint-quiet")
|
|
3729
|
+
) {
|
|
3698
3730
|
|
|
3699
3731
|
// test_cause:
|
|
3700
|
-
// ["0 //jslint-
|
|
3732
|
+
// ["0 //jslint-ignore-line", "read_line", "jslint_ignore_line", "", 0]
|
|
3701
3733
|
|
|
3702
|
-
test_cause("
|
|
3703
|
-
line_list[line].
|
|
3734
|
+
test_cause("jslint_ignore_line");
|
|
3735
|
+
line_list[line].directive_ignore_line = true;
|
|
3704
3736
|
}
|
|
3705
3737
|
if (line_disable !== undefined) {
|
|
3706
3738
|
|
|
@@ -3739,7 +3771,6 @@ import moduleHttps from "https";
|
|
|
3739
3771
|
from,
|
|
3740
3772
|
id,
|
|
3741
3773
|
identifier: Boolean(identifier),
|
|
3742
|
-
is_fart: false,
|
|
3743
3774
|
line,
|
|
3744
3775
|
nr: token_list.length,
|
|
3745
3776
|
thru: column,
|
|
@@ -3804,7 +3835,7 @@ import moduleHttps from "https";
|
|
|
3804
3835
|
token_prv_expr.id === ")"
|
|
3805
3836
|
&& paren_backtrack_list[paren_depth]
|
|
3806
3837
|
) {
|
|
3807
|
-
paren_backtrack_list[paren_depth].
|
|
3838
|
+
paren_backtrack_list[paren_depth].fart = the_token;
|
|
3808
3839
|
}
|
|
3809
3840
|
break;
|
|
3810
3841
|
}
|
|
@@ -3905,7 +3936,11 @@ function jslint_phase3_parse(state) {
|
|
|
3905
3936
|
|
|
3906
3937
|
// Attempt to give helpful names to anonymous functions.
|
|
3907
3938
|
|
|
3908
|
-
if (
|
|
3939
|
+
if (
|
|
3940
|
+
token_now.identifier
|
|
3941
|
+
&& token_now.id !== "function"
|
|
3942
|
+
&& token_now.id !== "async"
|
|
3943
|
+
) {
|
|
3909
3944
|
anon = token_now.id;
|
|
3910
3945
|
} else if (
|
|
3911
3946
|
token_now.id === "(string)"
|
|
@@ -4838,17 +4873,21 @@ function jslint_phase3_parse(state) {
|
|
|
4838
4873
|
return left;
|
|
4839
4874
|
}
|
|
4840
4875
|
|
|
4841
|
-
function parse_fart() {
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4876
|
+
function parse_fart(the_fart) {
|
|
4877
|
+
|
|
4878
|
+
// Give the function properties storing its names and for observing the depth
|
|
4879
|
+
// of loops and switches.
|
|
4880
|
+
|
|
4881
|
+
Object.assign(the_fart, {
|
|
4882
|
+
arity: "binary",
|
|
4883
|
+
context: empty(),
|
|
4884
|
+
finally: 0,
|
|
4885
|
+
level: functionage.level + 1,
|
|
4886
|
+
loop: 0,
|
|
4887
|
+
name: anon,
|
|
4888
|
+
switch: 0,
|
|
4889
|
+
try: 0
|
|
4890
|
+
});
|
|
4852
4891
|
|
|
4853
4892
|
// PR-384 - Relax warning "function_in_loop".
|
|
4854
4893
|
//
|
|
@@ -4860,45 +4899,27 @@ function jslint_phase3_parse(state) {
|
|
|
4860
4899
|
// warn("function_in_loop", the_fart);
|
|
4861
4900
|
// }
|
|
4862
4901
|
|
|
4863
|
-
// Give the function properties storing its names and for observing the depth
|
|
4864
|
-
// of loops and switches.
|
|
4865
|
-
|
|
4866
|
-
the_fart.context = empty();
|
|
4867
|
-
the_fart.finally = 0;
|
|
4868
|
-
the_fart.loop = 0;
|
|
4869
|
-
the_fart.parameters = parameters;
|
|
4870
|
-
the_fart.signature = signature;
|
|
4871
|
-
the_fart.switch = 0;
|
|
4872
|
-
the_fart.try = 0;
|
|
4873
|
-
|
|
4874
4902
|
// Push the current function context and establish a new one.
|
|
4875
4903
|
|
|
4904
|
+
function_list.push(the_fart);
|
|
4876
4905
|
function_stack.push(functionage);
|
|
4877
4906
|
functionage = the_fart;
|
|
4878
|
-
the_fart.parameters.forEach(function enroll_parameter(name) {
|
|
4879
|
-
if (name.identifier) {
|
|
4880
|
-
enroll(name, "parameter", true);
|
|
4881
|
-
} else {
|
|
4882
|
-
|
|
4883
|
-
// PR-385 - Bugfix - Fixes issue #382 - fix warnings against destructured fart.
|
|
4884
4907
|
|
|
4885
|
-
//
|
|
4886
|
-
// ["([aa])=>0", "enroll_parameter", "use_function_not_fart", "=>", 7]
|
|
4887
|
-
// ["({aa})=>0", "enroll_parameter", "use_function_not_fart", "=>", 7]
|
|
4908
|
+
// Parse the parameter list.
|
|
4888
4909
|
|
|
4889
|
-
|
|
4910
|
+
prefix_function_parameter(the_fart);
|
|
4911
|
+
advance("=>");
|
|
4890
4912
|
|
|
4891
|
-
//
|
|
4913
|
+
// The function's body is a block.
|
|
4892
4914
|
|
|
4893
|
-
name.names.forEach(enroll_parameter);
|
|
4894
|
-
}
|
|
4895
|
-
});
|
|
4896
4915
|
if (token_nxt.id === "{") {
|
|
4916
|
+
if (!option_dict.fart) {
|
|
4897
4917
|
|
|
4898
4918
|
// test_cause:
|
|
4899
4919
|
// ["()=>{}", "parse_fart", "use_function_not_fart", "=>", 3]
|
|
4900
4920
|
|
|
4901
|
-
|
|
4921
|
+
warn("use_function_not_fart", the_fart);
|
|
4922
|
+
}
|
|
4902
4923
|
the_fart.block = block("body");
|
|
4903
4924
|
} else if (
|
|
4904
4925
|
syntax_dict[token_nxt.id] !== undefined
|
|
@@ -4911,9 +4932,15 @@ function jslint_phase3_parse(state) {
|
|
|
4911
4932
|
// ["()=>delete aa", "parse_fart", "unexpected_a_after_b", "=>", 5]
|
|
4912
4933
|
|
|
4913
4934
|
stop("unexpected_a_after_b", token_nxt, token_nxt.id, "=>");
|
|
4935
|
+
|
|
4936
|
+
// The function's body is an expression.
|
|
4937
|
+
|
|
4914
4938
|
} else {
|
|
4915
4939
|
the_fart.expression = parse_expression(0);
|
|
4916
4940
|
}
|
|
4941
|
+
|
|
4942
|
+
// Restore the previous context.
|
|
4943
|
+
|
|
4917
4944
|
functionage = function_stack.pop();
|
|
4918
4945
|
return the_fart;
|
|
4919
4946
|
}
|
|
@@ -5256,15 +5283,35 @@ function jslint_phase3_parse(state) {
|
|
|
5256
5283
|
}
|
|
5257
5284
|
|
|
5258
5285
|
function prefix_async() {
|
|
5259
|
-
let the_async;
|
|
5286
|
+
let the_async = token_now;
|
|
5260
5287
|
let the_function;
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5288
|
+
token_nxt.arity = the_async.arity;
|
|
5289
|
+
|
|
5290
|
+
// PR-414 - Parse async fart.
|
|
5291
|
+
|
|
5292
|
+
if (token_nxt.fart) {
|
|
5293
|
+
advance("(");
|
|
5294
|
+
the_function = Object.assign(token_now.fart, {
|
|
5295
|
+
async: 1
|
|
5296
|
+
});
|
|
5297
|
+
if (!option_dict.fart) {
|
|
5298
|
+
|
|
5299
|
+
// test_cause:
|
|
5300
|
+
// ["async()=>0", "prefix_async", "use_function_not_fart", "=>", 8]
|
|
5301
|
+
|
|
5302
|
+
warn("use_function_not_fart", the_function);
|
|
5303
|
+
}
|
|
5304
|
+
prefix_lparen();
|
|
5305
|
+
|
|
5306
|
+
// Parse async function.
|
|
5307
|
+
|
|
5308
|
+
} else {
|
|
5309
|
+
advance("function");
|
|
5310
|
+
the_function = Object.assign(token_now, {
|
|
5311
|
+
async: 1
|
|
5312
|
+
});
|
|
5313
|
+
prefix_function();
|
|
5314
|
+
}
|
|
5268
5315
|
if (the_function.async === 1) {
|
|
5269
5316
|
|
|
5270
5317
|
// test_cause:
|
|
@@ -5351,7 +5398,6 @@ function jslint_phase3_parse(state) {
|
|
|
5351
5398
|
}
|
|
5352
5399
|
}
|
|
5353
5400
|
}
|
|
5354
|
-
the_function.level = functionage.level + 1;
|
|
5355
5401
|
|
|
5356
5402
|
// Probably deadcode.
|
|
5357
5403
|
// if (mode_mega) {
|
|
@@ -5381,6 +5427,7 @@ function jslint_phase3_parse(state) {
|
|
|
5381
5427
|
async: the_function.async || 0,
|
|
5382
5428
|
context: empty(),
|
|
5383
5429
|
finally: 0,
|
|
5430
|
+
level: functionage.level + 1,
|
|
5384
5431
|
loop: 0,
|
|
5385
5432
|
statement_prv: undefined,
|
|
5386
5433
|
switch: 0,
|
|
@@ -5389,43 +5436,27 @@ function jslint_phase3_parse(state) {
|
|
|
5389
5436
|
if (the_function.arity !== "statement" && typeof name === "object") {
|
|
5390
5437
|
|
|
5391
5438
|
// test_cause:
|
|
5392
|
-
// ["let aa=function bb(){return;};", "prefix_function", "expression", "", 0]
|
|
5439
|
+
// ["let aa=function bb(){return;};", "prefix_function", "expression", "bb", 0]
|
|
5393
5440
|
|
|
5394
|
-
test_cause("expression");
|
|
5441
|
+
test_cause("expression", name.id);
|
|
5395
5442
|
enroll(name, "function", true);
|
|
5396
5443
|
name.dead = false;
|
|
5397
5444
|
name.init = true;
|
|
5398
5445
|
name.used = 1;
|
|
5399
5446
|
}
|
|
5400
5447
|
|
|
5401
|
-
// Bugfix - fix function-
|
|
5448
|
+
// PR-334 - Bugfix - fix function-redefinition not warned inside function-call.
|
|
5402
5449
|
// Push the current function context and establish a new one.
|
|
5403
5450
|
|
|
5404
|
-
function_stack.push(functionage);
|
|
5405
5451
|
function_list.push(the_function);
|
|
5452
|
+
function_stack.push(functionage);
|
|
5406
5453
|
functionage = the_function;
|
|
5407
5454
|
|
|
5408
5455
|
// Parse the parameter list.
|
|
5409
5456
|
|
|
5410
5457
|
advance("(");
|
|
5411
|
-
|
|
5412
|
-
// test_cause:
|
|
5413
|
-
// ["function aa(){}", "prefix_function", "opener", "", 0]
|
|
5414
|
-
|
|
5415
|
-
test_cause("opener");
|
|
5416
|
-
token_now.free = false;
|
|
5417
5458
|
token_now.arity = "function";
|
|
5418
|
-
|
|
5419
|
-
functionage.parameters.forEach(function enroll_parameter(name) {
|
|
5420
|
-
if (name.identifier) {
|
|
5421
|
-
enroll(name, "parameter", false);
|
|
5422
|
-
} else {
|
|
5423
|
-
|
|
5424
|
-
// Recurse enroll_parameter().
|
|
5425
|
-
|
|
5426
|
-
name.names.forEach(enroll_parameter);
|
|
5427
|
-
}
|
|
5428
|
-
});
|
|
5459
|
+
prefix_function_parameter(the_function);
|
|
5429
5460
|
|
|
5430
5461
|
// The function's body is a block.
|
|
5431
5462
|
|
|
@@ -5476,19 +5507,40 @@ function jslint_phase3_parse(state) {
|
|
|
5476
5507
|
return the_function;
|
|
5477
5508
|
}
|
|
5478
5509
|
|
|
5479
|
-
function
|
|
5480
|
-
|
|
5481
|
-
|
|
5510
|
+
function prefix_function_parameter(the_function) {
|
|
5511
|
+
|
|
5512
|
+
// This function will parse input <parameters> at beginning of <the_function>
|
|
5513
|
+
|
|
5482
5514
|
let optional;
|
|
5515
|
+
let parameters = [];
|
|
5516
|
+
let signature = ["("];
|
|
5483
5517
|
let subparam;
|
|
5484
|
-
function
|
|
5518
|
+
function param_enroll(name) {
|
|
5519
|
+
if (name.identifier) {
|
|
5520
|
+
enroll(name, "parameter", false);
|
|
5521
|
+
} else {
|
|
5522
|
+
|
|
5523
|
+
// test_cause:
|
|
5524
|
+
// ["([aa])=>0", "param_enroll", "use_function_not_fart", "=>", 7]
|
|
5525
|
+
// ["({aa})=>0", "param_enroll", "use_function_not_fart", "=>", 7]
|
|
5526
|
+
|
|
5527
|
+
if (the_function.id === "=>" && !option_dict.fart) {
|
|
5528
|
+
warn("use_function_not_fart", the_function);
|
|
5529
|
+
}
|
|
5530
|
+
|
|
5531
|
+
// Recurse param_enroll().
|
|
5532
|
+
|
|
5533
|
+
name.names.forEach(param_enroll);
|
|
5534
|
+
}
|
|
5535
|
+
}
|
|
5536
|
+
function param_parse() {
|
|
5485
5537
|
let ellipsis = false;
|
|
5486
5538
|
let param;
|
|
5487
5539
|
if (token_nxt.id === "{") {
|
|
5488
5540
|
if (optional !== undefined) {
|
|
5489
5541
|
|
|
5490
5542
|
// test_cause:
|
|
5491
|
-
// ["function aa(aa=0,{}){}", "
|
|
5543
|
+
// ["function aa(aa=0,{}){}", "param_parse", "required_a_optional_b", "aa", 18]
|
|
5492
5544
|
|
|
5493
5545
|
warn(
|
|
5494
5546
|
"required_a_optional_b",
|
|
@@ -5506,8 +5558,8 @@ function jslint_phase3_parse(state) {
|
|
|
5506
5558
|
if (!subparam.identifier) {
|
|
5507
5559
|
|
|
5508
5560
|
// test_cause:
|
|
5509
|
-
// ["function aa(aa=0,{}){}", "
|
|
5510
|
-
// ["function aa({0}){}", "
|
|
5561
|
+
// ["function aa(aa=0,{}){}", "param_parse", "expected_identifier_a", "}", 19]
|
|
5562
|
+
// ["function aa({0}){}", "param_parse", "expected_identifier_a", "0", 14]
|
|
5511
5563
|
|
|
5512
5564
|
return stop("expected_identifier_a");
|
|
5513
5565
|
}
|
|
@@ -5522,7 +5574,7 @@ function jslint_phase3_parse(state) {
|
|
|
5522
5574
|
if (!subparam.identifier) {
|
|
5523
5575
|
|
|
5524
5576
|
// test_cause:
|
|
5525
|
-
// ["function aa({aa:0}){}", "
|
|
5577
|
+
// ["function aa({aa:0}){}", "param_parse", "expected_identifier_a", "}", 18]
|
|
5526
5578
|
|
|
5527
5579
|
return stop(
|
|
5528
5580
|
"expected_identifier_a",
|
|
@@ -5532,7 +5584,7 @@ function jslint_phase3_parse(state) {
|
|
|
5532
5584
|
}
|
|
5533
5585
|
|
|
5534
5586
|
// test_cause:
|
|
5535
|
-
// ["function aa({aa=aa},aa){}", "
|
|
5587
|
+
// ["function aa({aa=aa},aa){}", "param_parse", "equal", "", 0]
|
|
5536
5588
|
|
|
5537
5589
|
test_cause("equal");
|
|
5538
5590
|
if (token_nxt.id === "=") {
|
|
@@ -5548,7 +5600,7 @@ function jslint_phase3_parse(state) {
|
|
|
5548
5600
|
break;
|
|
5549
5601
|
}
|
|
5550
5602
|
}
|
|
5551
|
-
|
|
5603
|
+
parameters.push(param);
|
|
5552
5604
|
|
|
5553
5605
|
// test_cause:
|
|
5554
5606
|
// ["
|
|
@@ -5561,13 +5613,14 @@ function jslint_phase3_parse(state) {
|
|
|
5561
5613
|
if (token_nxt.id === ",") {
|
|
5562
5614
|
advance(",");
|
|
5563
5615
|
signature.push(", ");
|
|
5564
|
-
|
|
5616
|
+
param_parse();
|
|
5617
|
+
return;
|
|
5565
5618
|
}
|
|
5566
5619
|
} else if (token_nxt.id === "[") {
|
|
5567
5620
|
if (optional !== undefined) {
|
|
5568
5621
|
|
|
5569
5622
|
// test_cause:
|
|
5570
|
-
// ["function aa(aa=0,[]){}", "
|
|
5623
|
+
// ["function aa(aa=0,[]){}", "param_parse", "required_a_optional_b", "aa", 18]
|
|
5571
5624
|
|
|
5572
5625
|
warn(
|
|
5573
5626
|
"required_a_optional_b",
|
|
@@ -5585,7 +5638,7 @@ function jslint_phase3_parse(state) {
|
|
|
5585
5638
|
if (!subparam.identifier) {
|
|
5586
5639
|
|
|
5587
5640
|
// test_cause:
|
|
5588
|
-
// ["function aa(aa=0,[]){}", "
|
|
5641
|
+
// ["function aa(aa=0,[]){}", "param_parse", "expected_identifier_a", "]", 19]
|
|
5589
5642
|
|
|
5590
5643
|
return stop("expected_identifier_a");
|
|
5591
5644
|
}
|
|
@@ -5593,7 +5646,7 @@ function jslint_phase3_parse(state) {
|
|
|
5593
5646
|
param.names.push(subparam);
|
|
5594
5647
|
|
|
5595
5648
|
// test_cause:
|
|
5596
|
-
// ["function aa([aa=aa],aa){}", "
|
|
5649
|
+
// ["function aa([aa=aa],aa){}", "param_parse", "id", "", 0]
|
|
5597
5650
|
|
|
5598
5651
|
test_cause("id");
|
|
5599
5652
|
if (token_nxt.id === "=") {
|
|
@@ -5607,12 +5660,13 @@ function jslint_phase3_parse(state) {
|
|
|
5607
5660
|
break;
|
|
5608
5661
|
}
|
|
5609
5662
|
}
|
|
5610
|
-
|
|
5663
|
+
parameters.push(param);
|
|
5611
5664
|
advance("]");
|
|
5612
5665
|
if (token_nxt.id === ",") {
|
|
5613
5666
|
advance(",");
|
|
5614
5667
|
signature.push(", ");
|
|
5615
|
-
|
|
5668
|
+
param_parse();
|
|
5669
|
+
return;
|
|
5616
5670
|
}
|
|
5617
5671
|
} else {
|
|
5618
5672
|
if (token_nxt.id === "...") {
|
|
@@ -5622,7 +5676,7 @@ function jslint_phase3_parse(state) {
|
|
|
5622
5676
|
if (optional !== undefined) {
|
|
5623
5677
|
|
|
5624
5678
|
// test_cause:
|
|
5625
|
-
// ["function aa(aa=0,...){}", "
|
|
5679
|
+
// ["function aa(aa=0,...){}", "param_parse", "required_a_optional_b", "aa", 21]
|
|
5626
5680
|
|
|
5627
5681
|
warn(
|
|
5628
5682
|
"required_a_optional_b",
|
|
@@ -5635,12 +5689,12 @@ function jslint_phase3_parse(state) {
|
|
|
5635
5689
|
if (!token_nxt.identifier) {
|
|
5636
5690
|
|
|
5637
5691
|
// test_cause:
|
|
5638
|
-
// ["function aa(0){}", "
|
|
5692
|
+
// ["function aa(0){}", "param_parse", "expected_identifier_a", "0", 13]
|
|
5639
5693
|
|
|
5640
5694
|
return stop("expected_identifier_a");
|
|
5641
5695
|
}
|
|
5642
5696
|
param = token_nxt;
|
|
5643
|
-
|
|
5697
|
+
parameters.push(param);
|
|
5644
5698
|
advance();
|
|
5645
5699
|
signature.push(param.id);
|
|
5646
5700
|
if (ellipsis) {
|
|
@@ -5654,7 +5708,7 @@ function jslint_phase3_parse(state) {
|
|
|
5654
5708
|
if (optional !== undefined) {
|
|
5655
5709
|
|
|
5656
5710
|
// test_cause:
|
|
5657
|
-
// ["function aa(aa=0,bb){}", "
|
|
5711
|
+
// ["function aa(aa=0,bb){}", "param_parse", "required_a_optional_b", "aa", 18]
|
|
5658
5712
|
|
|
5659
5713
|
warn(
|
|
5660
5714
|
"required_a_optional_b",
|
|
@@ -5667,17 +5721,26 @@ function jslint_phase3_parse(state) {
|
|
|
5667
5721
|
if (token_nxt.id === ",") {
|
|
5668
5722
|
advance(",");
|
|
5669
5723
|
signature.push(", ");
|
|
5670
|
-
|
|
5724
|
+
param_parse();
|
|
5725
|
+
return;
|
|
5671
5726
|
}
|
|
5672
5727
|
}
|
|
5673
5728
|
}
|
|
5674
5729
|
}
|
|
5730
|
+
|
|
5731
|
+
// test_cause:
|
|
5732
|
+
// ["function aa(){}", "prefix_function_parameter", "opener", "(", 0]
|
|
5733
|
+
|
|
5734
|
+
test_cause("opener", token_now.id);
|
|
5735
|
+
token_now.free = false;
|
|
5675
5736
|
if (token_nxt.id !== ")" && token_nxt.id !== "(end)") {
|
|
5676
|
-
|
|
5737
|
+
param_parse();
|
|
5677
5738
|
}
|
|
5678
5739
|
advance(")");
|
|
5679
5740
|
signature.push(")");
|
|
5680
|
-
|
|
5741
|
+
parameters.forEach(param_enroll);
|
|
5742
|
+
the_function.parameters = parameters;
|
|
5743
|
+
the_function.signature = signature.join("");
|
|
5681
5744
|
}
|
|
5682
5745
|
|
|
5683
5746
|
function prefix_lbrace() {
|
|
@@ -5888,9 +5951,8 @@ function jslint_phase3_parse(state) {
|
|
|
5888
5951
|
|
|
5889
5952
|
// PR-385 - Bugfix - Fixes issue #382 - failure to detect destructured fart.
|
|
5890
5953
|
|
|
5891
|
-
if (token_now.
|
|
5892
|
-
|
|
5893
|
-
return parse_fart();
|
|
5954
|
+
if (token_now.fart) {
|
|
5955
|
+
return parse_fart(token_now.fart);
|
|
5894
5956
|
}
|
|
5895
5957
|
|
|
5896
5958
|
// test_cause:
|
|
@@ -7420,7 +7482,7 @@ function jslint_phase4_walk(state) {
|
|
|
7420
7482
|
i_set = a_set[the_token.id];
|
|
7421
7483
|
if (i_set !== undefined) {
|
|
7422
7484
|
i_set.forEach(function (task) {
|
|
7423
|
-
|
|
7485
|
+
task(the_token);
|
|
7424
7486
|
});
|
|
7425
7487
|
}
|
|
7426
7488
|
|
|
@@ -7429,7 +7491,7 @@ function jslint_phase4_walk(state) {
|
|
|
7429
7491
|
i_set = a_set["(all)"];
|
|
7430
7492
|
if (i_set !== undefined) {
|
|
7431
7493
|
i_set.forEach(function (task) {
|
|
7432
|
-
|
|
7494
|
+
task(the_token);
|
|
7433
7495
|
});
|
|
7434
7496
|
}
|
|
7435
7497
|
}
|
|
@@ -8422,12 +8484,16 @@ function jslint_phase4_walk(state) {
|
|
|
8422
8484
|
} else {
|
|
8423
8485
|
preamble(thing);
|
|
8424
8486
|
walk_expression(thing.expression);
|
|
8425
|
-
|
|
8487
|
+
|
|
8488
|
+
// PR-414 - Bugfix - fix fart-body not being walked.
|
|
8489
|
+
|
|
8490
|
+
if (thing.id === "function" || thing.id === "=>") {
|
|
8426
8491
|
|
|
8427
8492
|
// test_cause:
|
|
8428
|
-
// ["aa=
|
|
8493
|
+
// ["aa=()=>0", "walk_expression", "function", "=>", 0]
|
|
8494
|
+
// ["aa=function(){}", "walk_expression", "function", "function", 0]
|
|
8429
8495
|
|
|
8430
|
-
test_cause("function");
|
|
8496
|
+
test_cause("function", thing.id);
|
|
8431
8497
|
|
|
8432
8498
|
// Recurse walk_statement().
|
|
8433
8499
|
|
|
@@ -8463,33 +8529,36 @@ function jslint_phase4_walk(state) {
|
|
|
8463
8529
|
}
|
|
8464
8530
|
|
|
8465
8531
|
function walk_statement(thing) {
|
|
8466
|
-
if (thing) {
|
|
8467
|
-
|
|
8532
|
+
if (!thing) {
|
|
8533
|
+
return;
|
|
8534
|
+
}
|
|
8535
|
+
if (Array.isArray(thing)) {
|
|
8468
8536
|
|
|
8469
8537
|
// test_cause:
|
|
8470
8538
|
// ["+[]", "walk_statement", "isArray", "", 0]
|
|
8471
8539
|
|
|
8472
|
-
|
|
8540
|
+
test_cause("isArray");
|
|
8473
8541
|
|
|
8474
8542
|
// Recurse walk_statement().
|
|
8475
8543
|
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8481
|
-
|
|
8544
|
+
thing.forEach(walk_statement);
|
|
8545
|
+
return;
|
|
8546
|
+
}
|
|
8547
|
+
preamble(thing);
|
|
8548
|
+
walk_expression(thing.expression);
|
|
8549
|
+
if (thing.arity === "binary") {
|
|
8550
|
+
if (thing.id !== "(") {
|
|
8482
8551
|
|
|
8483
8552
|
// test_cause:
|
|
8484
8553
|
// ["0&&0", "walk_statement", "unexpected_expression_a", "&&", 2]
|
|
8485
8554
|
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8555
|
+
warn("unexpected_expression_a", thing);
|
|
8556
|
+
}
|
|
8557
|
+
} else if (
|
|
8558
|
+
thing.arity !== "statement"
|
|
8559
|
+
&& thing.arity !== "assignment"
|
|
8560
|
+
&& thing.id !== "import"
|
|
8561
|
+
) {
|
|
8493
8562
|
|
|
8494
8563
|
// test_cause:
|
|
8495
8564
|
// ["!0", "walk_statement", "unexpected_expression_a", "!", 1]
|
|
@@ -8498,16 +8567,14 @@ function jslint_phase4_walk(state) {
|
|
|
8498
8567
|
// ["0", "walk_statement", "unexpected_expression_a", "0", 1]
|
|
8499
8568
|
// ["typeof 0", "walk_statement", "unexpected_expression_a", "typeof", 1]
|
|
8500
8569
|
|
|
8501
|
-
|
|
8502
|
-
|
|
8570
|
+
warn("unexpected_expression_a", thing);
|
|
8571
|
+
}
|
|
8503
8572
|
|
|
8504
8573
|
// Recurse walk_statement().
|
|
8505
8574
|
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
8509
|
-
}
|
|
8510
|
-
}
|
|
8575
|
+
walk_statement(thing.block);
|
|
8576
|
+
walk_statement(thing.else);
|
|
8577
|
+
postamble(thing);
|
|
8511
8578
|
}
|
|
8512
8579
|
|
|
8513
8580
|
postaction = action(posts);
|
|
@@ -9186,6 +9253,7 @@ function jslint_phase5_whitage(state) {
|
|
|
9186
9253
|
)
|
|
9187
9254
|
|| left.id === "function"
|
|
9188
9255
|
|| left.id === ":"
|
|
9256
|
+
|| left.id === "async"
|
|
9189
9257
|
|| (
|
|
9190
9258
|
(
|
|
9191
9259
|
left.identifier
|
|
@@ -9742,6 +9810,7 @@ pyNj+JctcQLXenBOCms46aMkenIx45WpXqxxVJQLz/vgpmAVa0fmDv6Pue9xVTBPfVxCUGfj\
|
|
|
9742
9810
|
let {
|
|
9743
9811
|
context,
|
|
9744
9812
|
from,
|
|
9813
|
+
id,
|
|
9745
9814
|
level,
|
|
9746
9815
|
line,
|
|
9747
9816
|
name,
|
|
@@ -9758,14 +9827,18 @@ pyNj+JctcQLXenBOCms46aMkenIx45WpXqxxVJQLz/vgpmAVa0fmDv6Pue9xVTBPfVxCUGfj\
|
|
|
9758
9827
|
+ address(line, from + 1)
|
|
9759
9828
|
+ "<dfn>"
|
|
9760
9829
|
+ (
|
|
9761
|
-
|
|
9762
|
-
?
|
|
9830
|
+
id === "=>"
|
|
9831
|
+
? (
|
|
9832
|
+
"\u00ab" + htmlEscape(name) + "\u00bb"
|
|
9833
|
+
+ htmlEscape(signature)
|
|
9834
|
+
+ " =>"
|
|
9835
|
+
)
|
|
9763
9836
|
: (
|
|
9764
9837
|
typeof name === "string"
|
|
9765
9838
|
? "\u00ab" + htmlEscape(name) + "\u00bb"
|
|
9766
9839
|
: htmlEscape(name.id)
|
|
9767
|
-
)
|
|
9768
|
-
)
|
|
9840
|
+
) + htmlEscape(signature)
|
|
9841
|
+
)
|
|
9769
9842
|
+ "</dfn>"
|
|
9770
9843
|
);
|
|
9771
9844
|
params = [];
|
|
@@ -10214,7 +10287,7 @@ function v8CoverageListMerge(processCovs) {
|
|
|
10214
10287
|
let resultTree;
|
|
10215
10288
|
let rightChildren;
|
|
10216
10289
|
|
|
10217
|
-
// TODO(perf): Binary search (check overhead) //jslint-
|
|
10290
|
+
// TODO(perf): Binary search (check overhead) //jslint-ignore-line
|
|
10218
10291
|
|
|
10219
10292
|
while (ii < tree.children.length) {
|
|
10220
10293
|
child = tree.children[ii];
|
|
@@ -10292,7 +10365,7 @@ function v8CoverageListMerge(processCovs) {
|
|
|
10292
10365
|
|
|
10293
10366
|
// This function will normalize-and-sort <funcCov>.ranges.
|
|
10294
10367
|
// Sorts the ranges (pre-order sort).
|
|
10295
|
-
// TODO: Tree-based normalization of the ranges. //jslint-
|
|
10368
|
+
// TODO: Tree-based normalization of the ranges. //jslint-ignore-line
|
|
10296
10369
|
// @param funcCov Function coverage to normalize.
|
|
10297
10370
|
|
|
10298
10371
|
funcCov.ranges = treeToRanges(treeFromSortedRanges(
|