From 05dc02d6550848e52d0599e5a8461fd48543fb2a Mon Sep 17 00:00:00 2001 From: kai zhu Date: Sun, 10 Jul 2022 13:51:25 -0500 Subject: [PATCH] - bugfix - warnings that should be ignored sometimes suppress legitimate warnings (#409) --- .ci.sh | 2 +- CHANGELOG.md | 3 ++- help.html | 71 ++++++++++++++++++++++++++++++++++++++++++++++------ jslint.mjs | 50 ++++++++++++++++++++++++++++-------- package.json | 2 +- 5 files changed, 106 insertions(+), 22 deletions(-) diff --git a/.ci.sh b/.ci.sh index dececaad7..dcc953aaf 100644 --- a/.ci.sh +++ b/.ci.sh @@ -434,7 +434,7 @@ import moduleFs from "fs"; "type": "git", "url": "https://github.com/jslint-org/jslint.git" }, - "version": "2022.7.1" + "version": "2022.7.2" }, undefined, 4) } ].map(async function ({ diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d7a85cc1..054018b58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,8 @@ - jslint - add new warning "Expected Object.create(null) instead of {}" - node - after node-v14 is deprecated, remove shell-code `export "NODE_OPTIONS=--unhandled-rejections=strict"`. -# v2022.7.1-beta +# v2022.7.2-beta +- bugfix - warnings that should be ignored sometimes suppress legitimate warnings - doc - document jslint directives - vscode - add extra contextmenu commands "JSLint - Do Not Lint Selected Region", "JSLint - Ignore Current Line" diff --git a/help.html b/help.html index 6f99f1224..9ea73e9d8 100644 --- a/help.html +++ b/help.html @@ -381,10 +381,41 @@

/*jslint*/

globals as this directive:
/*global
- clearInterval, clearTimeout, document, event, FileReader, - FormData, history, localStorage, location, name, navigator, - screen, sessionStorage, setInterval, setTimeout, Storage, - URL, window, XMLHttpRequest +AbortController, +Blob, +Event, +EventTarget, +FileReader, +FormData, +IntersectionObserver, +MessageChannel, +MessageEvent, +MessagePort, +MutationObserver, +TextDecoder, +TextEncoder, +URL, +URLSearchParams, +WebAssembly, +Worker, +XMLHttpRequest, +clearInterval, +clearTimeout, +document, +fetch, +importScripts, +indexedDb, +localStorage, +location, +navigator, +performance, +postMessage, +queueMicrotask, +sessionStorage, +setInterval, +setTimeout, +structuredClone, +window
*/
@@ -463,10 +494,34 @@

/*jslint*/

It adds the same globals as this directive:
/*global
- Buffer, clearImmediate, clearInterval, clearTimeout, - console, exports, module, process, require, - setImmediate, setInterval, setTimeout, TextDecoder, - TextEncoder, URL, URLSearchParams, __dirname, __filename +AbortController, +Buffer, +Event, +EventTarget, +MessageChannel, +MessageEvent, +MessagePort, +TextDecoder, +TextEncoder, +URL, +URLSearchParams, +WebAssembly, +__dirname, +__filename, +clearImmediate, +clearInterval, +clearTimeout, +console, +exports, +global, +module, +performance, +process, +queueMicrotask, +require, +setImmediate, +setInterval, +setTimeout
*/
diff --git a/jslint.mjs b/jslint.mjs index af33ba256..f5ffd0d8d 100644 --- a/jslint.mjs +++ b/jslint.mjs @@ -153,7 +153,7 @@ let debugInline = (function () { return argv[0]; } debug(); // Coverage-hack. - __consoleError = console.error; + __consoleError = console.error; //jslint-ignore-line return debug; }()); let jslint_charset_ascii = ( @@ -165,7 +165,7 @@ let jslint_charset_ascii = ( + "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" + "`abcdefghijklmnopqrstuvwxyz{|}~\u007f" ); -let jslint_edition = "v2022.7.1-beta"; +let jslint_edition = "v2022.7.2-beta"; let jslint_export; // The jslint object to be exported. let jslint_fudge = 1; // Fudge starting line and starting // ... column to 1. @@ -860,11 +860,22 @@ function jslint( c, d ); - if (the_token.warning === undefined) { - the_token.warning = the_warning; - } else { + +// Issue #408 +// Warnings that should be ignored sometimes suppress legitimate warnings. + + if (the_warning.directive_ignore_line) { + return the_warning; + } + +// If there is already a warning on this token, suppress the new one. It is +// likely that the first warning will be the most meaningful. + + if (the_token.warning) { warning_list.pop(); + return the_warning; } + the_token.warning = the_warning; return the_warning; } @@ -1014,6 +1025,7 @@ function jslint( break; // PR-347 - Disable warning "missing_browser". +// // case "missing_browser": // mm = `/*global*/ requires the Assume a browser option.`; // break; @@ -1098,6 +1110,7 @@ function jslint( break; // PR-347 - Disable warning "unexpected_directive_a". +// // case "unexpected_directive_a": // mm = `When using modules, don't use directive '/\u002a${a}'.`; // break; @@ -1328,6 +1341,7 @@ function jslint( ); // PR-347 - Disable warning "missing_browser". +// // if (!option_dict.browser) { // directive_list.forEach(function (comment) { // if (comment.directive === "global") { @@ -2700,6 +2714,7 @@ function jslint_phase2_lex(state) { return char_after("]"); // PR-362 - Relax regexp-warning against using . +// // case " ": // // // test_cause: @@ -2780,6 +2795,7 @@ function jslint_phase2_lex(state) { return; // PR-362 - Relax regexp-warning against using . +// // case " ": // // // test_cause: @@ -3336,12 +3352,16 @@ console.log(JSON.stringify(Object.keys(window).sort(), undefined, 4)); "AbortController", // "Buffer", - "DOMException", + // "Crypto", + // "CryptoKey", "Event", "EventTarget", "MessageChannel", "MessageEvent", "MessagePort", + // "Request", + // "Response", + // "SubtleCrypto", "TextDecoder", "TextEncoder", "URL", @@ -3355,7 +3375,9 @@ console.log(JSON.stringify(Object.keys(window).sort(), undefined, 4)); "clearInterval", "clearTimeout", // "console", + // "crypto", // "exports", + // "fetch", // "global", // "module", "performance", @@ -3365,7 +3387,6 @@ console.log(JSON.stringify(Object.keys(window).sort(), undefined, 4)); // "setImmediate", "setInterval", "setTimeout", - "structuredClone", // Web worker only. // https://github.com/mdn/content/blob/main/files/en-us/web/api @@ -3408,6 +3429,7 @@ console.log(JSON.stringify(Object.keys(window).sort(), undefined, 4)); "sessionStorage", // "setInterval", // "setTimeout", + "structuredClone", "window" ], "browser"); break; @@ -3469,6 +3491,7 @@ import https from "https"; case "ecma": object_assign_from_list(global_dict, [ + "AggregateError", "Array", "ArrayBuffer", "Atomics", @@ -3539,7 +3562,7 @@ import moduleHttps from "https"; let result = ""; await new Promise(function (resolve) { moduleHttps.get(( - "https://raw.githubusercontent.com/nodejs/node/master/doc/api" + "https://raw.githubusercontent.com/nodejs/node/v16.x/doc/api" + "/globals.md" ), function (res) { res.on("data", function (chunk) { @@ -3562,12 +3585,16 @@ import moduleHttps from "https"; object_assign_from_list(global_dict, [ "AbortController", "Buffer", - "DOMException", + // "Crypto", + // "CryptoKey", "Event", "EventTarget", "MessageChannel", "MessageEvent", "MessagePort", + // "Request", + // "Response", + // "SubtleCrypto", "TextDecoder", "TextEncoder", "URL", @@ -3581,7 +3608,9 @@ import moduleHttps from "https"; "clearInterval", "clearTimeout", "console", + // "crypto", "exports", + // "fetch", "global", "module", "performance", @@ -3590,8 +3619,7 @@ import moduleHttps from "https"; "require", "setImmediate", "setInterval", - "setTimeout", - "structuredClone" + "setTimeout" ], "Node.js"); break; } diff --git a/package.json b/package.json index 247cfce3b..d3cf62fde 100644 --- a/package.json +++ b/package.json @@ -33,5 +33,5 @@ "test2": "sh jslint_ci.sh shCiBase" }, "type": "module", - "version": "2022.7.1-beta" + "version": "2022.7.2-beta" }