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

20$: Warn on missing parentheses in 'if' statement

Open strager opened this issue 2 years ago • 2 comments

function f() {
  return true;
}
if (f) {
}

The above code should warn on the call to f, stating "missing '()' in function call".

strager avatar Apr 26 '22 06:04 strager

We'd need to do two things in variable_analyzer:

  • track the type of declared identifiers (we already sorta do this with variable_init_kind), and
  • track the usage style of variables (we already sorta do this with used_variable_kind).

At first I thought this would be complicated, but because we have similar features already, maybe this'll be relatively straightforward.

strager avatar Apr 26 '22 06:04 strager

We can do something similar with code like if (f == 42) {}.

strager avatar May 01 '22 02:05 strager