quick-lint-js icon indicating copy to clipboard operation
quick-lint-js copied to clipboard

#265 Warn on redundant semicolon after else

Open someoneigna opened this issue 3 years ago • 3 comments

Summary

Warn when a semicolon is found after else.

After this change a warning is reported for the semicolons at 7:7 12:15 and 16:2

let x = 0;
function f() {}
function g() {}

if (x) {
    f();
} else; {
    g();
}


if (x) {} else;
{ }

if (x) {} else
;{ }

Output in VIM plugin format is:

{"qflist": [{"col": 7, "lnum": 7, "end_col": 7, "end_lnum": 7, "type": "W", "nr": "E202", "vcol": 0, "text": "redundant semicolon after else", "filename": "invalid.js"},
{"col": 15, "lnum": 12, "end_col": 15, "end_lnum": 12, "type": "W", "nr": "E202", "vcol": 0, "text": "redundant semicolon after else", "filename": "invalid.js"},
{"col": 1, "lnum": 16, "end_col": 1, "end_lnum": 16, "type": "W", "nr": "E202", "vcol": 0, "text": "redundant semicolon after else", "filename": "invalid.js"}]}

else;;; {} is also valid code but was left out for simplicity. (loop of peek and skip required).

someoneigna avatar May 13 '21 03:05 someoneigna

CLA Assistant Lite bot Thank you for your contribution! Like many free software projects, you must sign our Contributor License Agreement before we can accept your contribution.

EDIT: All contributors have signed quick-lint-js' Contributor License Agreement (CLA-v1.md).

github-actions[bot] avatar May 13 '21 03:05 github-actions[bot]

I have read and hereby agree to quick-lint-js' Contributor License Agreement (CLA-v1.md).

someoneigna avatar May 13 '21 03:05 someoneigna

Did you want me to review your latest changes, or are you still hacking?

strager avatar May 27 '21 08:05 strager