Skip to content

Commit

Permalink
Merge pull request #297 from kaizhu256/v2021.5.27
Browse files Browse the repository at this point in the history
v2021.5.27
  • Loading branch information
kaizhu256 authored May 28, 2021
2 parents a422783 + fde0580 commit f6a0008
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 17 deletions.
11 changes: 7 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Douglas Crockford
[email protected]

## Status
| Branch | [master<br>(v2021.5.26)](https://github.com/jslint-org/jslint/tree/master) | [beta<br>(testing)](https://github.com/jslint-org/jslint/tree/beta) | [alpha<br>(development)](https://github.com/jslint-org/jslint/tree/alpha) |
| Branch | [master<br>(v2021.5.27)](https://github.com/jslint-org/jslint/tree/master) | [beta<br>(testing)](https://github.com/jslint-org/jslint/tree/beta) | [alpha<br>(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) |
Expand Down
7 changes: 7 additions & 0 deletions browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
});
Expand Down
5 changes: 5 additions & 0 deletions help.html
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,11 @@ <h1><code>/*jslint*/</code></h1>
<td><code>this</code></td>
<td><code>true</code> if <code>this</code> should be allowed. </td>
</tr>
<tr>
<td id="unordered">Tolerate unordered properties and params.</td>
<td><code>unordered</code></td>
<td><code>true</code> if objects and functions are allowed to declare properties and params in non-alphabetical order.</td>
</tr>
<tr>
<td id="white">Tolerate whitespace mess</td>
<td><code>white</code></td>
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@
<div><label><input title=long type=checkbox>long lines</label></div>
<div><label><input title=single type=checkbox>single quote strings</label></div>
<div><label><input title=this type=checkbox>this</label></div>
<div><label><input title=unordered type=checkbox>unordered properties and params</label></div>
<div><label><input title=white type=checkbox>whitespace mess</label></div>
</div>
<div>Global variables...
Expand Down
38 changes: 27 additions & 11 deletions jslint.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -129,12 +129,17 @@
wrapped, writable, y
*/

const edition = "v2021.5.27";

function assert_or_throw(passed, message) {

// this function will throw <message> if <passed> 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);
}
}

Expand Down Expand Up @@ -195,7 +200,9 @@ const allowed_option = {
"TextEncoder", "URL", "URLSearchParams", "__dirname", "__filename"
],
single: true,
test_internal_error: true,
this: true,
unordered: true,
white: true
};

Expand Down Expand Up @@ -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];
});

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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 === ":") {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -5647,7 +5663,7 @@ function jslint(
});
return {
directives,
edition: "v2021.5.27-beta",
edition,
exports,
froms,
functions,
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function noop() {
white: true
}).warnings.length === 0);
assertOrThrow(jslint("", {
test_uncaught_error: true
test_internal_error: true
}).warnings.length === 1);
}());

Expand Down

0 comments on commit f6a0008

Please sign in to comment.