quick-lint / quick-lint-js

quick-lint-js finds bugs in JavaScript programs
https://quick-lint-js.com
GNU General Public License v3.0
1.52k stars 191 forks source link

12$: warn on '} if' on same line with no 'else' #1217

Open strager opened 3 months ago

strager commented 3 months ago
if (x) {
} if (y) {  // warn please!
}
if (x) { } if (y) { }  // unsure if we should warn...

Inspiration: https://twitter.com/tsoding/status/1782676054093533328

strager commented 3 months ago

Proposed logic:

After parsing the { } body of an if, check if the next token is Token_Type::kw_if and if has_leading_newline is false. If yes, then warn.

qnguyen1013 commented 3 months ago

Hey Strager, I'm a recent cs college grad and am trying to get into open source, would love to try and tackle this issue!

strager commented 3 months ago

@qnguyen1013 Sure thing! Here are our contribution guides: https://quick-lint-js.com/contribute/

If you need any help, let me know.

singalhimanshu commented 2 months ago

hi @strager would like to take this issue if no one else is actively working on it.