Skip to content

Commit

Permalink
- jslint - Check exported properties are ordered.
Browse files Browse the repository at this point in the history
- jslint - Add grammar for "export async function ...".
  • Loading branch information
kaizhu256 committed May 20, 2023
1 parent b31343b commit af101b2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
- coverage - add macros `/*coverage-disable*/` and `/*coverage-enable*/`.
- jslint - add html and css linting back into jslint.
- jslint - add new warning requiring paren around plus-separated concatenations.
- jslint - require regexp to use open-form.
- jslint - try to improve parser to be able to parse jquery.js without stopping.
- jslint - unify analysis of variable-assignment/function-parameters into one function

# v2023.5.1-beta
- jslint - Check exported properties are ordered.
- jslint - Add grammar for "export async function ...".
- python - Add shell-function shLintPython().
- jslint - Add grammar for regexp-named-capture-group and regexp-named-backreference.
- jslint - Add grammar for side-effect import-statement.
Expand Down
17 changes: 15 additions & 2 deletions jslint.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6188,7 +6188,8 @@ function jslint_phase3_parse(state) {
}

function stmt_export() {
const the_export = token_now;
let export_list = [];
let the_export = token_now;
let the_id;
let the_name;
let the_thing;
Expand Down Expand Up @@ -6232,9 +6233,13 @@ function jslint_phase3_parse(state) {
export_dict.default = the_thing;
the_export.expression.push(the_thing);
} else {
if (token_nxt.id === "function") {

// PR-439 - Add grammar for "export async function ...".

if (token_nxt.id === "function" || token_nxt.id === "async") {

// test_cause:
// ["export async function aa(){}", "stmt_export", "freeze_exports", "async", 8]
// ["export function aa(){}", "stmt_export", "freeze_exports", "function", 8]

warn("freeze_exports");
Expand Down Expand Up @@ -6284,6 +6289,7 @@ function jslint_phase3_parse(state) {
stop("expected_identifier_a");
}
the_id = token_nxt.id;
export_list.push(token_nxt);
the_name = token_global.context[the_id];
if (the_name === undefined) {

Expand All @@ -6310,6 +6316,13 @@ function jslint_phase3_parse(state) {
break;
}
}

// PR-439 - Check exported properties are ordered.

// test_cause:
// ["export {bb, aa}", "check_ordered", "expected_a_b_before_c_d", "aa", 13]

check_ordered("export", export_list);
advance("}");
semicolon();
} else {
Expand Down
8 changes: 8 additions & 0 deletions test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,14 @@ jstestDescribe((
],
module: [
"export default Object.freeze();",

// PR-439 - Add grammar for "export async function ...".

(
"export default Object.freeze(async function () {\n"
+ " return await 0;\n"
+ "});\n"
),
"import {aa, bb} from \"aa\";\naa(bb);",
"import {} from \"aa\";",
"import(\"aa\").then(function () {\n return;\n});",
Expand Down

0 comments on commit af101b2

Please sign in to comment.