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 192 forks source link

feat: track whitespace #1135

Closed arieldon closed 8 months ago

arieldon commented 8 months ago

This set of commits addresses issues #282 and #1113 by tracking whitespace and adding a few new diagnostics. quick-lint will print warnings about mismatched curly brace indentation, if/else indentation, and misleading indentation after a braceless if.

Commit 2379dea modifies a couple existing tests by adding whitespace to them to avoid triggering Diag_Mismatched_Curly_Indentation.

arieldon commented 8 months ago

I addressed your "must fix" comments. The diagnostics are more flexible now. They do not necessarily report wonky indentation, but they still use indentation to try to track where to place a closing right curly brace. They also still report misleading indentation for if and else statements.

I have not tried your suggestion about changing the way we track indentation in Lexer yet. Diag_Misleading_If_Or_Else_Body_Indentation also still reports the if and not the actual misleading indentation.

arieldon commented 8 months ago

I'm not able to figure out a heuristic and an implementation for it that doesn't feel complex and hacky. I'm going to close this PR for now. Thank you for your suggestions and help nonetheless.