@jslint-org/jslint 2022.2.20 → 2022.3.30
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/README.md +1 -1
- package/jslint.mjs +182 -118
- package/jslint_wrapper_cjs.cjs +4 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ Douglas Crockford <douglas@crockford.com>
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
# Status
|
|
6
|
-
| Branch | [master<br>(v2022.
|
|
6
|
+
| Branch | [master<br>(v2022.3.30)](https://github.com/jslint-org/jslint/tree/master) | [beta<br>(Web Demo)](https://github.com/jslint-org/jslint/tree/beta) | [alpha<br>(Development)](https://github.com/jslint-org/jslint/tree/alpha) |
|
|
7
7
|
|--:|:--:|:--:|:--:|
|
|
8
8
|
| CI | [](https://github.com/jslint-org/jslint/actions?query=branch%3Amaster) | [](https://github.com/jslint-org/jslint/actions?query=branch%3Abeta) | [](https://github.com/jslint-org/jslint/actions?query=branch%3Aalpha) |
|
|
9
9
|
| Coverage | [](https://jslint-org.github.io/jslint/branch-master/.artifact/coverage/index.html) | [](https://jslint-org.github.io/jslint/branch-beta/.artifact/coverage/index.html) | [](https://jslint-org.github.io/jslint/branch-alpha/.artifact/coverage/index.html) |
|
package/jslint.mjs
CHANGED
|
@@ -167,11 +167,96 @@ let jslint_charset_ascii = (
|
|
|
167
167
|
+ "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
|
|
168
168
|
+ "`abcdefghijklmnopqrstuvwxyz{|}~\u007f"
|
|
169
169
|
);
|
|
170
|
-
let jslint_edition = "v2022.
|
|
170
|
+
let jslint_edition = "v2022.3.30";
|
|
171
171
|
let jslint_export; // The jslint object to be exported.
|
|
172
172
|
let jslint_fudge = 1; // Fudge starting line and starting
|
|
173
173
|
// ... column to 1.
|
|
174
174
|
let jslint_import_meta_url = ""; // import.meta.url used by cli.
|
|
175
|
+
let jslint_rgx_cap = (
|
|
176
|
+
/^[A-Z]/
|
|
177
|
+
);
|
|
178
|
+
let jslint_rgx_crlf = (
|
|
179
|
+
/\n|\r\n?/
|
|
180
|
+
);
|
|
181
|
+
let jslint_rgx_digits_bits = (
|
|
182
|
+
/^[01_]*/
|
|
183
|
+
);
|
|
184
|
+
let jslint_rgx_digits_decimals = (
|
|
185
|
+
/^[0-9_]*/
|
|
186
|
+
);
|
|
187
|
+
let jslint_rgx_digits_hexs = (
|
|
188
|
+
/^[0-9A-F_]*/i
|
|
189
|
+
);
|
|
190
|
+
let jslint_rgx_digits_octals = (
|
|
191
|
+
/^[0-7_]*/
|
|
192
|
+
);
|
|
193
|
+
let jslint_rgx_directive = (
|
|
194
|
+
/^(jslint|property|global)\s+(.*)$/
|
|
195
|
+
);
|
|
196
|
+
let jslint_rgx_directive_part = (
|
|
197
|
+
/([a-zA-Z$_][a-zA-Z0-9$_]*)(?::\s*(true|false))?,?\s*|$/g
|
|
198
|
+
);
|
|
199
|
+
let jslint_rgx_identifier = (
|
|
200
|
+
/^([a-zA-Z_$][a-zA-Z0-9_$]*)$/
|
|
201
|
+
);
|
|
202
|
+
let jslint_rgx_json_number = (
|
|
203
|
+
|
|
204
|
+
// https://datatracker.ietf.org/doc/html/rfc7159#section-6
|
|
205
|
+
// number = [ minus ] int [ frac ] [ exp ]
|
|
206
|
+
|
|
207
|
+
/^-?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][\-+]?\d+)?$/
|
|
208
|
+
);
|
|
209
|
+
let jslint_rgx_mega = (
|
|
210
|
+
|
|
211
|
+
// Vim-hack - vim-editor has trouble parsing naked '`' in regexp
|
|
212
|
+
|
|
213
|
+
/[\u0060\\]|\$\{/
|
|
214
|
+
);
|
|
215
|
+
let jslint_rgx_module = (
|
|
216
|
+
/^[a-zA-Z0-9_$:.@\-\/]+$/
|
|
217
|
+
);
|
|
218
|
+
let jslint_rgx_numeric_separator_illegal = (
|
|
219
|
+
/__|_$|_n$/m
|
|
220
|
+
);
|
|
221
|
+
let jslint_rgx_slash_star_or_slash = (
|
|
222
|
+
/\/\*|\/$/
|
|
223
|
+
);
|
|
224
|
+
let jslint_rgx_tab = (
|
|
225
|
+
/\t/g
|
|
226
|
+
);
|
|
227
|
+
let jslint_rgx_todo = (
|
|
228
|
+
/\b(?:todo|TO\s?DO|HACK)\b/
|
|
229
|
+
);
|
|
230
|
+
let jslint_rgx_token = new RegExp(
|
|
231
|
+
"^("
|
|
232
|
+
+ "(\\s+)"
|
|
233
|
+
+ "|([a-zA-Z_$][a-zA-Z0-9_$]*)"
|
|
234
|
+
+ "|[(){}\\[\\],:;'\"~\\`]"
|
|
235
|
+
+ "|\\?[?.]?"
|
|
236
|
+
+ "|=(?:==?|>)?"
|
|
237
|
+
+ "|\\.+"
|
|
238
|
+
+ "|\\*[*\\/=]?"
|
|
239
|
+
+ "|\\/[*\\/]?"
|
|
240
|
+
+ "|\\+[=+]?"
|
|
241
|
+
+ "|-[=\\-]?"
|
|
242
|
+
+ "|[\\^%]=?"
|
|
243
|
+
+ "|&[&=]?"
|
|
244
|
+
+ "|\\"
|
|
245
|
+
+ "|[|=]?"
|
|
246
|
+
+ "|>{1,3}=?"
|
|
247
|
+
+ "|<<?=?"
|
|
248
|
+
+ "|!(?:!|==?)?"
|
|
249
|
+
|
|
250
|
+
// PR-351 - Add BigInt support.
|
|
251
|
+
// PR-390 - Add numeric-separator support.
|
|
252
|
+
|
|
253
|
+
+ "|((?:0_?|[1-9][0-9_]*)n?)"
|
|
254
|
+
+ ")"
|
|
255
|
+
+ "(.*)$"
|
|
256
|
+
);
|
|
257
|
+
let jslint_rgx_weird_property = (
|
|
258
|
+
/^_|\$|Sync$|_$/m
|
|
259
|
+
);
|
|
175
260
|
let jstestCountFailed = 0;
|
|
176
261
|
let jstestCountTotal = 0;
|
|
177
262
|
let jstestItCount = 0;
|
|
@@ -307,10 +392,7 @@ function jslint(
|
|
|
307
392
|
let import_list = []; // The array collecting all import-from strings.
|
|
308
393
|
let line_list = String( // The array containing source lines.
|
|
309
394
|
"\n" + source
|
|
310
|
-
).split(
|
|
311
|
-
// rx_crlf
|
|
312
|
-
/\n|\r\n?/
|
|
313
|
-
).map(function (line_source) {
|
|
395
|
+
).split(jslint_rgx_crlf).map(function (line_source) {
|
|
314
396
|
return {
|
|
315
397
|
line_source
|
|
316
398
|
};
|
|
@@ -687,6 +769,12 @@ function jslint(
|
|
|
687
769
|
// case "function_in_loop":
|
|
688
770
|
// mm = `Don't create functions within a loop.`;
|
|
689
771
|
// break;
|
|
772
|
+
|
|
773
|
+
// PR-390 - Add numeric-separator check.
|
|
774
|
+
|
|
775
|
+
case "illegal_num_separator":
|
|
776
|
+
mm = `Illegal numeric separator '_' at column ${column}.`;
|
|
777
|
+
break;
|
|
690
778
|
case "infix_in":
|
|
691
779
|
mm = (
|
|
692
780
|
`Unexpected 'in'. Compare with undefined,`
|
|
@@ -1841,6 +1929,8 @@ function jslint_phase2_lex(state) {
|
|
|
1841
1929
|
let line_mega; // The starting line of megastring.
|
|
1842
1930
|
let line_source = ""; // The remaining line source string.
|
|
1843
1931
|
let line_whole = ""; // The whole line source string.
|
|
1932
|
+
let mode_digits_empty_string = 1;
|
|
1933
|
+
let mode_digits_numeric_separator = 2;
|
|
1844
1934
|
let mode_directive = true; // true if directives are still allowed.
|
|
1845
1935
|
let mode_mega = false; // true if currently parsing a megastring
|
|
1846
1936
|
// ... literal.
|
|
@@ -1848,33 +1938,7 @@ function jslint_phase2_lex(state) {
|
|
|
1848
1938
|
// ... this line.
|
|
1849
1939
|
let paren_backtrack_list = []; // List of most recent "(" tokens at any
|
|
1850
1940
|
// ... paren-depth.
|
|
1851
|
-
let paren_depth = 0;
|
|
1852
|
-
let rx_token = new RegExp(
|
|
1853
|
-
"^("
|
|
1854
|
-
+ "(\\s+)"
|
|
1855
|
-
+ "|([a-zA-Z_$][a-zA-Z0-9_$]*)"
|
|
1856
|
-
+ "|[(){}\\[\\],:;'\"~\\`]"
|
|
1857
|
-
+ "|\\?[?.]?"
|
|
1858
|
-
+ "|=(?:==?|>)?"
|
|
1859
|
-
+ "|\\.+"
|
|
1860
|
-
+ "|\\*[*\\/=]?"
|
|
1861
|
-
+ "|\\/[*\\/]?"
|
|
1862
|
-
+ "|\\+[=+]?"
|
|
1863
|
-
+ "|-[=\\-]?"
|
|
1864
|
-
+ "|[\\^%]=?"
|
|
1865
|
-
+ "|&[&=]?"
|
|
1866
|
-
+ "|\\"
|
|
1867
|
-
+ "|[|=]?"
|
|
1868
|
-
+ "|>{1,3}=?"
|
|
1869
|
-
+ "|<<?=?"
|
|
1870
|
-
+ "|!(?:!|==?)?"
|
|
1871
|
-
|
|
1872
|
-
// PR-351 - Add BigInt support.
|
|
1873
|
-
|
|
1874
|
-
+ "|(0n?|[1-9][0-9]*n?)"
|
|
1875
|
-
+ ")"
|
|
1876
|
-
+ "(.*)$"
|
|
1877
|
-
);
|
|
1941
|
+
let paren_depth = 0; // Keeps track of current paren-depth.
|
|
1878
1942
|
let snippet = ""; // A piece of string.
|
|
1879
1943
|
let token_1; // The first token.
|
|
1880
1944
|
let token_prv = token_global; // The previous token including
|
|
@@ -1956,7 +2020,7 @@ function jslint_phase2_lex(state) {
|
|
|
1956
2020
|
|
|
1957
2021
|
warn_at("unexpected_a", line, column, char);
|
|
1958
2022
|
}
|
|
1959
|
-
if (read_digits("x") > 5) {
|
|
2023
|
+
if (read_digits("x", undefined) > 5) {
|
|
1960
2024
|
|
|
1961
2025
|
// test_cause:
|
|
1962
2026
|
// ["\"\\u{123456}\"", "char_after_escape", "too_many_digits", "", 11]
|
|
@@ -1973,7 +2037,7 @@ function jslint_phase2_lex(state) {
|
|
|
1973
2037
|
return char_after();
|
|
1974
2038
|
}
|
|
1975
2039
|
char_before();
|
|
1976
|
-
if (read_digits("x",
|
|
2040
|
+
if (read_digits("x", mode_digits_empty_string) < 4) {
|
|
1977
2041
|
|
|
1978
2042
|
// test_cause:
|
|
1979
2043
|
// ["\"\\u0\"", "char_after_escape", "expected_four_digits", "", 5]
|
|
@@ -2008,6 +2072,26 @@ function jslint_phase2_lex(state) {
|
|
|
2008
2072
|
return char;
|
|
2009
2073
|
}
|
|
2010
2074
|
|
|
2075
|
+
function check_numeric_separator(digits, column) {
|
|
2076
|
+
|
|
2077
|
+
// This function will check for illegal numeric-separator in <digits>.
|
|
2078
|
+
|
|
2079
|
+
digits.replace((
|
|
2080
|
+
jslint_rgx_numeric_separator_illegal
|
|
2081
|
+
), function (ignore, ii) {
|
|
2082
|
+
|
|
2083
|
+
// test_cause:
|
|
2084
|
+
// ["0x0_0_;", "check_numeric_separator", "illegal_num_separator", "", 6]
|
|
2085
|
+
// ["0x0_0__0;", "check_numeric_separator", "illegal_num_separator", "", 6]
|
|
2086
|
+
// ["aa=1_2_;", "check_numeric_separator", "illegal_num_separator", "", 7]
|
|
2087
|
+
// ["aa=1_2__3;", "check_numeric_separator", "illegal_num_separator", "", 7]
|
|
2088
|
+
// ["aa=1_2_n;", "check_numeric_separator", "illegal_num_separator", "", 7]
|
|
2089
|
+
|
|
2090
|
+
warn_at("illegal_num_separator", line, column + ii + 1);
|
|
2091
|
+
return "";
|
|
2092
|
+
});
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2011
2095
|
function lex_comment() {
|
|
2012
2096
|
let body;
|
|
2013
2097
|
let ii = 0;
|
|
@@ -2046,12 +2130,12 @@ function jslint_phase2_lex(state) {
|
|
|
2046
2130
|
// Lex/loop through each line until "*/".
|
|
2047
2131
|
|
|
2048
2132
|
while (true) {
|
|
2049
|
-
//
|
|
2133
|
+
// jslint_rgx_star_slash
|
|
2050
2134
|
ii = line_source.indexOf("*/");
|
|
2051
2135
|
if (ii >= 0) {
|
|
2052
2136
|
break;
|
|
2053
2137
|
}
|
|
2054
|
-
//
|
|
2138
|
+
// jslint_rgx_slash_star
|
|
2055
2139
|
ii = line_source.indexOf("/*");
|
|
2056
2140
|
if (ii >= 0) {
|
|
2057
2141
|
|
|
@@ -2071,8 +2155,7 @@ function jslint_phase2_lex(state) {
|
|
|
2071
2155
|
}
|
|
2072
2156
|
}
|
|
2073
2157
|
jj = line_source.slice(0, ii).search(
|
|
2074
|
-
|
|
2075
|
-
/\/\*|\/$/
|
|
2158
|
+
jslint_rgx_slash_star_or_slash
|
|
2076
2159
|
);
|
|
2077
2160
|
if (jj >= 0) {
|
|
2078
2161
|
|
|
@@ -2090,13 +2173,7 @@ function jslint_phase2_lex(state) {
|
|
|
2090
2173
|
|
|
2091
2174
|
// Uncompleted work comment.
|
|
2092
2175
|
|
|
2093
|
-
if (
|
|
2094
|
-
!option_dict.devel
|
|
2095
|
-
&& (
|
|
2096
|
-
// rx_todo
|
|
2097
|
-
/\b(?:todo|TO\s?DO|HACK)\b/
|
|
2098
|
-
).test(snippet)
|
|
2099
|
-
) {
|
|
2176
|
+
if (!option_dict.devel && jslint_rgx_todo.test(snippet)) {
|
|
2100
2177
|
|
|
2101
2178
|
// test_cause:
|
|
2102
2179
|
// ["//todo", "lex_comment", "todo_comment", "(comment)", 1] //jslint-quiet
|
|
@@ -2108,10 +2185,7 @@ function jslint_phase2_lex(state) {
|
|
|
2108
2185
|
|
|
2109
2186
|
[
|
|
2110
2187
|
the_comment.directive, body
|
|
2111
|
-
] = Array.from(snippet.match(
|
|
2112
|
-
// rx_directive
|
|
2113
|
-
/^(jslint|property|global)\s+(.*)$/
|
|
2114
|
-
) || []).slice(1);
|
|
2188
|
+
] = Array.from(snippet.match(jslint_rgx_directive) || []).slice(1);
|
|
2115
2189
|
if (the_comment.directive === undefined) {
|
|
2116
2190
|
return the_comment;
|
|
2117
2191
|
}
|
|
@@ -2133,10 +2207,12 @@ function jslint_phase2_lex(state) {
|
|
|
2133
2207
|
// Lex/loop through each directive in /*...*/
|
|
2134
2208
|
|
|
2135
2209
|
ii = 0;
|
|
2136
|
-
body.replace((
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2210
|
+
body.replace(jslint_rgx_directive_part, function (
|
|
2211
|
+
match0,
|
|
2212
|
+
key,
|
|
2213
|
+
val,
|
|
2214
|
+
jj
|
|
2215
|
+
) {
|
|
2140
2216
|
if (ii !== jj) {
|
|
2141
2217
|
|
|
2142
2218
|
// test_cause:
|
|
@@ -2210,13 +2286,7 @@ function jslint_phase2_lex(state) {
|
|
|
2210
2286
|
// string.
|
|
2211
2287
|
|
|
2212
2288
|
while (true) {
|
|
2213
|
-
match = line_source.match(
|
|
2214
|
-
|
|
2215
|
-
// Vim-hack - vim-editor has trouble parsing '`' in regexp
|
|
2216
|
-
|
|
2217
|
-
// rx_mega
|
|
2218
|
-
/[\u0060\\]|\$\{/
|
|
2219
|
-
) || {
|
|
2289
|
+
match = line_source.match(jslint_rgx_mega) || {
|
|
2220
2290
|
"0": "",
|
|
2221
2291
|
index: 0
|
|
2222
2292
|
};
|
|
@@ -2293,12 +2363,16 @@ function jslint_phase2_lex(state) {
|
|
|
2293
2363
|
|
|
2294
2364
|
function lex_number() {
|
|
2295
2365
|
let prefix = snippet;
|
|
2366
|
+
|
|
2367
|
+
// PR-390 - Add numeric-separator check.
|
|
2368
|
+
|
|
2369
|
+
check_numeric_separator(prefix, column - prefix.length);
|
|
2296
2370
|
char_after();
|
|
2297
2371
|
switch (prefix === "0" && char) {
|
|
2298
2372
|
case "b":
|
|
2299
2373
|
case "o":
|
|
2300
2374
|
case "x":
|
|
2301
|
-
read_digits(char);
|
|
2375
|
+
read_digits(char, mode_digits_numeric_separator);
|
|
2302
2376
|
|
|
2303
2377
|
// PR-351 - Ignore BigInt suffix 'n'.
|
|
2304
2378
|
|
|
@@ -2308,14 +2382,14 @@ function jslint_phase2_lex(state) {
|
|
|
2308
2382
|
break;
|
|
2309
2383
|
default:
|
|
2310
2384
|
if (char === ".") {
|
|
2311
|
-
read_digits("d");
|
|
2385
|
+
read_digits("d", mode_digits_numeric_separator);
|
|
2312
2386
|
}
|
|
2313
2387
|
if (char === "E" || char === "e") {
|
|
2314
2388
|
char_after(char);
|
|
2315
2389
|
if (char !== "+" && char !== "-") {
|
|
2316
2390
|
char_before();
|
|
2317
2391
|
}
|
|
2318
|
-
read_digits("d");
|
|
2392
|
+
read_digits("d", mode_digits_numeric_separator);
|
|
2319
2393
|
}
|
|
2320
2394
|
}
|
|
2321
2395
|
|
|
@@ -2585,7 +2659,7 @@ function jslint_phase2_lex(state) {
|
|
|
2585
2659
|
}
|
|
2586
2660
|
break;
|
|
2587
2661
|
case "{":
|
|
2588
|
-
if (read_digits("d",
|
|
2662
|
+
if (read_digits("d", mode_digits_empty_string) === 0) {
|
|
2589
2663
|
|
|
2590
2664
|
// test_cause:
|
|
2591
2665
|
// ["aa=/aa{/", "lex_regexp_group", "expected_a_before_b", ",", 8]
|
|
@@ -2598,7 +2672,7 @@ function jslint_phase2_lex(state) {
|
|
|
2598
2672
|
// ["aa=/.{,/", "lex_regexp_group", "comma", "", 0]
|
|
2599
2673
|
|
|
2600
2674
|
test_cause("comma");
|
|
2601
|
-
read_digits("d",
|
|
2675
|
+
read_digits("d", mode_digits_empty_string);
|
|
2602
2676
|
}
|
|
2603
2677
|
if (char_after("}") === "?") {
|
|
2604
2678
|
|
|
@@ -2891,7 +2965,7 @@ function jslint_phase2_lex(state) {
|
|
|
2891
2965
|
}
|
|
2892
2966
|
}
|
|
2893
2967
|
from = column;
|
|
2894
|
-
match = line_source.match(
|
|
2968
|
+
match = line_source.match(jslint_rgx_token);
|
|
2895
2969
|
|
|
2896
2970
|
// match[1] token
|
|
2897
2971
|
// match[2] whitespace
|
|
@@ -3274,41 +3348,48 @@ import moduleHttps from "https";
|
|
|
3274
3348
|
return true;
|
|
3275
3349
|
}
|
|
3276
3350
|
|
|
3277
|
-
function read_digits(base,
|
|
3351
|
+
function read_digits(base, mode) {
|
|
3278
3352
|
let digits = line_source.match(
|
|
3279
3353
|
base === "b"
|
|
3280
|
-
?
|
|
3281
|
-
// rx_bits
|
|
3282
|
-
/^[01]*/
|
|
3283
|
-
)
|
|
3354
|
+
? jslint_rgx_digits_bits
|
|
3284
3355
|
: base === "o"
|
|
3285
|
-
?
|
|
3286
|
-
// rx_octals
|
|
3287
|
-
/^[0-7]*/
|
|
3288
|
-
)
|
|
3356
|
+
? jslint_rgx_digits_octals
|
|
3289
3357
|
: base === "x"
|
|
3290
|
-
?
|
|
3291
|
-
|
|
3292
|
-
/^[0-9A-F]*/i
|
|
3293
|
-
)
|
|
3294
|
-
: (
|
|
3295
|
-
// rx_digits
|
|
3296
|
-
/^[0-9]*/
|
|
3297
|
-
)
|
|
3358
|
+
? jslint_rgx_digits_hexs
|
|
3359
|
+
: jslint_rgx_digits_decimals
|
|
3298
3360
|
)[0];
|
|
3299
|
-
|
|
3300
|
-
|
|
3361
|
+
if (
|
|
3362
|
+
(mode !== mode_digits_empty_string && digits.length === 0)
|
|
3363
|
+
|| digits[0] === "_"
|
|
3364
|
+
) {
|
|
3301
3365
|
|
|
3302
3366
|
// test_cause:
|
|
3303
3367
|
// ["0x", "read_digits", "expected_digits_after_a", "0x", 2]
|
|
3368
|
+
// ["0x_", "read_digits", "expected_digits_after_a", "0x", 2]
|
|
3304
3369
|
|
|
3305
3370
|
warn_at("expected_digits_after_a", line, column, snippet);
|
|
3306
3371
|
}
|
|
3307
|
-
|
|
3308
|
-
|
|
3372
|
+
|
|
3373
|
+
// PR-390 - Add numeric-separator check.
|
|
3374
|
+
|
|
3375
|
+
if (mode === mode_digits_numeric_separator) {
|
|
3376
|
+
check_numeric_separator(digits, column);
|
|
3377
|
+
} else if (digits.indexOf("_") >= 0) {
|
|
3378
|
+
|
|
3379
|
+
// test_cause:
|
|
3380
|
+
// ["\"\\u{1_2}\"", "read_digits", "illegal_num_separator", "", 6]
|
|
3381
|
+
|
|
3382
|
+
warn_at(
|
|
3383
|
+
"illegal_num_separator",
|
|
3384
|
+
line,
|
|
3385
|
+
column + digits.indexOf("_") + 1
|
|
3386
|
+
);
|
|
3387
|
+
}
|
|
3388
|
+
column += digits.length;
|
|
3389
|
+
line_source = line_source.slice(digits.length);
|
|
3309
3390
|
snippet += digits;
|
|
3310
3391
|
char_after();
|
|
3311
|
-
return length;
|
|
3392
|
+
return digits.length;
|
|
3312
3393
|
}
|
|
3313
3394
|
|
|
3314
3395
|
function read_line() {
|
|
@@ -3379,6 +3460,7 @@ import moduleHttps from "https";
|
|
|
3379
3460
|
test_cause("line_disable");
|
|
3380
3461
|
line_source = "";
|
|
3381
3462
|
}
|
|
3463
|
+
// jslint_rgx_tab
|
|
3382
3464
|
if (line_source.indexOf("\t") >= 0) {
|
|
3383
3465
|
if (!option_dict.white) {
|
|
3384
3466
|
|
|
@@ -3387,10 +3469,7 @@ import moduleHttps from "https";
|
|
|
3387
3469
|
|
|
3388
3470
|
warn_at("use_spaces", line, line_source.indexOf("\t") + 1);
|
|
3389
3471
|
}
|
|
3390
|
-
line_source = line_source.replace(
|
|
3391
|
-
// rx_tab
|
|
3392
|
-
/\t/g
|
|
3393
|
-
), " ");
|
|
3472
|
+
line_source = line_source.replace(jslint_rgx_tab, " ");
|
|
3394
3473
|
}
|
|
3395
3474
|
if (!option_dict.white && line_source.endsWith(" ")) {
|
|
3396
3475
|
|
|
@@ -3564,9 +3643,6 @@ function jslint_phase3_parse(state) {
|
|
|
3564
3643
|
let catchage = catch_stack[0]; // The current catch-block.
|
|
3565
3644
|
let functionage = token_global; // The current function.
|
|
3566
3645
|
let mode_var; // "var" if using var; "let" if using let.
|
|
3567
|
-
let rx_identifier = (
|
|
3568
|
-
/^([a-zA-Z_$][a-zA-Z0-9_$]*)$/
|
|
3569
|
-
);
|
|
3570
3646
|
let token_ii = 0; // The number of the next token.
|
|
3571
3647
|
let token_now = token_global; // The current token being examined in
|
|
3572
3648
|
// ... the parse.
|
|
@@ -3583,7 +3659,7 @@ function jslint_phase3_parse(state) {
|
|
|
3583
3659
|
anon = token_now.id;
|
|
3584
3660
|
} else if (
|
|
3585
3661
|
token_now.id === "(string)"
|
|
3586
|
-
&&
|
|
3662
|
+
&& jslint_rgx_identifier.test(token_now.value)
|
|
3587
3663
|
) {
|
|
3588
3664
|
anon = token_now.value;
|
|
3589
3665
|
}
|
|
@@ -4233,7 +4309,7 @@ function jslint_phase3_parse(state) {
|
|
|
4233
4309
|
let the_subscript = parse_expression(0);
|
|
4234
4310
|
if (the_subscript.id === "(string)" || the_subscript.id === "`") {
|
|
4235
4311
|
name = survey(the_subscript);
|
|
4236
|
-
if (
|
|
4312
|
+
if (jslint_rgx_identifier.test(name)) {
|
|
4237
4313
|
|
|
4238
4314
|
// test_cause:
|
|
4239
4315
|
// ["aa[`aa`]", "infix_lbracket", "subscript_a", "aa", 4]
|
|
@@ -4594,13 +4670,7 @@ function jslint_phase3_parse(state) {
|
|
|
4594
4670
|
let negative;
|
|
4595
4671
|
switch (token_nxt.id) {
|
|
4596
4672
|
case "(number)":
|
|
4597
|
-
if (!(
|
|
4598
|
-
|
|
4599
|
-
// https://datatracker.ietf.org/doc/html/rfc7159#section-6
|
|
4600
|
-
// number = [ minus ] int [ frac ] [ exp ]
|
|
4601
|
-
|
|
4602
|
-
/^-?(?:0|[1-9]\d*?)(?:\.\d*?)?(?:[eE][+\-]?\d+?)?$/
|
|
4603
|
-
).test(token_nxt.value)) {
|
|
4673
|
+
if (!jslint_rgx_json_number.test(token_nxt.value)) {
|
|
4604
4674
|
|
|
4605
4675
|
// test_cause:
|
|
4606
4676
|
// ["[-.0]", "parse_json", "unexpected_a", ".", 3]
|
|
@@ -6100,10 +6170,7 @@ function jslint_phase3_parse(state) {
|
|
|
6100
6170
|
advance("from");
|
|
6101
6171
|
advance("(string)");
|
|
6102
6172
|
the_import.import = token_now;
|
|
6103
|
-
if (!(
|
|
6104
|
-
// rx_module
|
|
6105
|
-
/^[a-zA-Z0-9_$:.@\-\/]+$/
|
|
6106
|
-
).test(token_now.value)) {
|
|
6173
|
+
if (!jslint_rgx_module.test(token_now.value)) {
|
|
6107
6174
|
|
|
6108
6175
|
// test_cause:
|
|
6109
6176
|
// ["import aa from \"!aa\"", "stmt_import", "bad_module_name_a", "!aa", 16]
|
|
@@ -6714,13 +6781,13 @@ function jslint_phase3_parse(state) {
|
|
|
6714
6781
|
|
|
6715
6782
|
if (id === "(string)") {
|
|
6716
6783
|
id = name.value;
|
|
6717
|
-
if (!
|
|
6784
|
+
if (!jslint_rgx_identifier.test(id)) {
|
|
6718
6785
|
return id;
|
|
6719
6786
|
}
|
|
6720
6787
|
} else if (id === "`") {
|
|
6721
6788
|
if (name.value.length === 1) {
|
|
6722
6789
|
id = name.value[0].value;
|
|
6723
|
-
if (!
|
|
6790
|
+
if (!jslint_rgx_identifier.test(id)) {
|
|
6724
6791
|
return id;
|
|
6725
6792
|
}
|
|
6726
6793
|
}
|
|
@@ -6753,10 +6820,7 @@ function jslint_phase3_parse(state) {
|
|
|
6753
6820
|
} else if (
|
|
6754
6821
|
!option_dict.name
|
|
6755
6822
|
&& name.identifier
|
|
6756
|
-
&& (
|
|
6757
|
-
// rx_weird_property
|
|
6758
|
-
/^_|\$|Sync$|_$/m
|
|
6759
|
-
).test(id)
|
|
6823
|
+
&& jslint_rgx_weird_property.test(id)
|
|
6760
6824
|
) {
|
|
6761
6825
|
|
|
6762
6826
|
// test_cause:
|
|
@@ -7510,10 +7574,7 @@ function jslint_phase4_walk(state) {
|
|
|
7510
7574
|
test_cause("cack");
|
|
7511
7575
|
cack = !cack;
|
|
7512
7576
|
}
|
|
7513
|
-
if ((
|
|
7514
|
-
// rx_cap
|
|
7515
|
-
/^[A-Z]/
|
|
7516
|
-
).test(left.name.id) !== cack) {
|
|
7577
|
+
if (jslint_rgx_cap.test(left.name.id) !== cack) {
|
|
7517
7578
|
if (the_new !== undefined) {
|
|
7518
7579
|
|
|
7519
7580
|
// test_cause:
|
|
@@ -9382,6 +9443,9 @@ body {
|
|
|
9382
9443
|
: "global"
|
|
9383
9444
|
);
|
|
9384
9445
|
if (global.length + froms.length + exports.length > 0) {
|
|
9446
|
+
if (functions.length === 0) {
|
|
9447
|
+
html += "<br>\n";
|
|
9448
|
+
}
|
|
9385
9449
|
html += "<div class=\"level level0\">\n";
|
|
9386
9450
|
html += detail(module, global);
|
|
9387
9451
|
html += detail("import from", froms);
|
package/jslint_wrapper_cjs.cjs
CHANGED
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
require("vm").runInNewContext(
|
|
6
6
|
(
|
|
7
7
|
"\"use strict\";"
|
|
8
|
-
+ require("fs").readFileSync(
|
|
8
|
+
+ require("fs").readFileSync(
|
|
9
|
+
__dirname + "/jslint.mjs",
|
|
10
|
+
"utf8"
|
|
11
|
+
).replace(
|
|
9
12
|
"\nexport default Object.freeze(jslint_export);",
|
|
10
13
|
"\nmodule.exports = jslint_export;"
|
|
11
14
|
).replace(
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"default": "./jslint_wrapper_cjs.cjs",
|
|
9
9
|
"import": "./jslint.mjs"
|
|
10
10
|
},
|
|
11
|
-
"fileCount":
|
|
11
|
+
"fileCount": 29,
|
|
12
12
|
"keywords": [
|
|
13
13
|
"coverage-report",
|
|
14
14
|
"javascript",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"test2": "sh jslint_ci.sh shCiBase"
|
|
30
30
|
},
|
|
31
31
|
"type": "module",
|
|
32
|
-
"version": "2022.
|
|
32
|
+
"version": "2022.3.30"
|
|
33
33
|
}
|