diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e29630a6..f599a7858 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,14 +11,17 @@ - node - after node-v14 is deprecated, remove shell-code export "NODE_OPTIONS=--unhandled-rejections=strict". - none -## v2021.5.27-beta +## v2021.5.27 +- ci - fix expectedWarningCode not being validated. +- ci - in windows, disable git-autocrlf. - deadcode - replace with assertion-check in function are_similar() - "if (a === b) { return true }". - deadcode - replace with assertion-check in function are_similar() superseded by id-check - "if (Array.isArray(b)) { return false; }". - deadcode - replace with assertion-check in function are_similar() superseded by is_weird() check - "if (a.arity === "function" && a.arity ===...c". -- ci - fix expectedWarningCode not being validated -- ci - in windows, disable git-autocrlf +- jslint - add directive `test_internal_error`. +- jslint - add directive `unordered` to tolerate unordered properties and params. - jslint - inline-document each warning with cause that can reproduce it - part 1. -- style - refactor code moving infix-operators from post-position to pre-position in multiline statements +- style - refactor code moving infix-operators from post-position to pre-position in multiline statements. +- website - add hotkey ctrl-enter to run jslint. - none ## v2021.5.26 diff --git a/README.md b/README.md index d61eb70fb..ada4a95a8 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Douglas Crockford douglas@crockford.com ## Status -| Branch | [master
(v2021.5.26)](https://github.com/jslint-org/jslint/tree/master) | [beta
(testing)](https://github.com/jslint-org/jslint/tree/beta) | [alpha
(development)](https://github.com/jslint-org/jslint/tree/alpha) | +| Branch | [master
(v2021.5.27)](https://github.com/jslint-org/jslint/tree/master) | [beta
(testing)](https://github.com/jslint-org/jslint/tree/beta) | [alpha
(development)](https://github.com/jslint-org/jslint/tree/alpha) | |--:|:--:|:--:|:--:| | CI | [![ci](https://github.com/jslint-org/jslint/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/jslint-org/jslint/actions?query=branch%3Amaster) | [![ci](https://github.com/jslint-org/jslint/actions/workflows/ci.yml/badge.svg?branch=beta)](https://github.com/jslint-org/jslint/actions?query=branch%3Abeta) | [![ci](https://github.com/jslint-org/jslint/actions/workflows/ci.yml/badge.svg?branch=alpha)](https://github.com/jslint-org/jslint/actions?query=branch%3Aalpha) | | Coverage | [![coverage](https://jslint-org.github.io/jslint/branch.master/.build/coverage/coverage-badge.svg)](https://jslint-org.github.io/jslint/branch.master/.build/coverage/index.html) | [![coverage](https://jslint-org.github.io/jslint/branch.beta/.build/coverage/coverage-badge.svg)](https://jslint-org.github.io/jslint/branch.beta/.build/coverage/index.html) | [![coverage](https://jslint-org.github.io/jslint/branch.alpha/.build/coverage/coverage-badge.svg)](https://jslint-org.github.io/jslint/branch.alpha/.build/coverage/index.html) | diff --git a/browser.js b/browser.js index 328df79ba..14bceb0e8 100644 --- a/browser.js +++ b/browser.js @@ -7,6 +7,7 @@ */ /*property + addEventListener, ctrlKey, key, checked, closure, column, context, create, disable, display, edition, exports, filter, focus, forEach, froms, fudge, functions, getElementById, global, id, innerHTML, isArray, join, json, keys, length, level, line, @@ -353,6 +354,12 @@ elem_source.onscroll = function () { } }; +document.addEventListener("keydown", function (evt) { + if (evt.ctrlKey && evt.key === "Enter") { + call_jslint(); + } +}); + document.querySelectorAll("[name='JSLint']").forEach(function (node) { node.onclick = call_jslint; }); diff --git a/help.html b/help.html index 1a55f6192..63c34f0c6 100644 --- a/help.html +++ b/help.html @@ -462,6 +462,11 @@

/*jslint*/

this true if this should be allowed. + + Tolerate unordered properties and params. + unordered + true if objects and functions are allowed to declare properties and params in non-alphabetical order. + Tolerate whitespace mess white diff --git a/index.html b/index.html index 456fbc2c4..3e55d6191 100644 --- a/index.html +++ b/index.html @@ -463,6 +463,7 @@
+
Global variables... diff --git a/jslint.js b/jslint.js index 65c6d7ed9..0b78c6e71 100755 --- a/jslint.js +++ b/jslint.js @@ -1,6 +1,5 @@ #!/usr/bin/env node // jslint.js -// v2021.5.27-beta // Copyright (c) 2015 Douglas Crockford (www.JSLint.com) // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -89,6 +88,7 @@ /*jslint node*/ /*property + unordered, JSLINT_CLI, a, all, and, argv, arity, assign, b, bad_assignment_a, bad_directive_a, bad_get, bad_module_name_a, bad_option_a, bad_property_a, bad_set, bitwise, block, body, browser, c, calls, catch, cli_mode, closer, @@ -113,7 +113,7 @@ promises, property, push, quote, raw, readFile, readdir, redefinition_a_b, repeat, replace, required_a_optional_b, reserved_a, role, search, shebang, signature, single, slice, some, sort, source, split, stack, stack_trace, - startsWith, statement, stop, subscript_a, switch, test, test_uncaught_error, + startsWith, statement, stop, subscript_a, switch, test, test_internal_error, then, this, thru, todo_comment, tokens, too_long, too_many_digits, tree, trim, try, type, u, unclosed_comment, unclosed_mega, unclosed_string, undeclared_a, unexpected_a, unexpected_a_after_b, unexpected_a_before_b, @@ -129,12 +129,17 @@ wrapped, writable, y */ +const edition = "v2021.5.27"; + function assert_or_throw(passed, message) { // this function will throw if is falsy if (!passed) { - throw new Error(message); + throw new Error(`This was caused by a bug in JSLint. +Please open an issue with this stack-trace at +https://github.com/jslint-org/jslint/issues. +edition = "${edition}";` + "\n" + message); } } @@ -195,7 +200,9 @@ const allowed_option = { "TextEncoder", "URL", "URLSearchParams", "__dirname", "__filename" ], single: true, + test_internal_error: true, this: true, + unordered: true, white: true }; @@ -557,7 +564,10 @@ function warn_at(code, line, column, a, b, c, d) { ignore, filling ) { - assert_or_throw(warning[filling] !== undefined); + assert_or_throw( + warning[filling] !== undefined, + "Expected warning[filling] !== undefined." + ); return warning[filling]; }); @@ -2965,10 +2975,12 @@ function parameter_list() { a = b; b = String(subparam.value || subparam.id); if (a > b) { + if (!option.unordered) { // cause: "function aa({bb,aa}){}" - warn("unordered_param_a", subparam); + warn("unordered_param_a", subparam); + } } advance(); signature.push(subparam.id); @@ -3337,10 +3349,12 @@ prefix("{", function () { a = b; b = String(name.value || name.id); if (a > b) { + if (!option.unordered) { // cause: "aa={bb,aa}" - warn("unordered_property_a", name); + warn("unordered_property_a", name); + } } if ( (name.id === "get" || name.id === "set") @@ -3525,10 +3539,12 @@ function do_var() { a = b; b = String(name.value || name.id); if (a > b) { + if (!option.unordered) { // cause: "let{bb,aa}=0" - warn("unordered_param_a", name); + warn("unordered_param_a", name); + } } advance(); if (next_token.id === ":") { @@ -5603,13 +5619,13 @@ function jslint( } }); } - if (option.test_uncaught_error) { - assert_or_throw(undefined, "Uncaught error."); + if (option.test_internal_error) { + assert_or_throw(undefined, "test_internal_error"); } early_stop = false; } catch (e) { e.early_stop = true; - e.message = "[JSLint was unable to finish] - " + e.message; + e.message = "[JSLint was unable to finish]\n" + e.message; if (e.name !== "JSLintError") { e.column = 0; e.line = 0; @@ -5647,7 +5663,7 @@ function jslint( }); return { directives, - edition: "v2021.5.27-beta", + edition, exports, froms, functions, diff --git a/test.js b/test.js index 9b91cb4de..ec67c2636 100644 --- a/test.js +++ b/test.js @@ -78,7 +78,7 @@ function noop() { white: true }).warnings.length === 0); assertOrThrow(jslint("", { - test_uncaught_error: true + test_internal_error: true }).warnings.length === 1); }());