I am using &&
like this and it works
typeof foo === \'function\' && foo(); //if foo exist then call it
instead
The linter's job is to look out for things that while syntactically valid may not follow recommended best practices.
"Expected an assignment or function call" probably means that it expects foo
to be foo()
or foo =
in the first part, that seeing it without a call is, in its opinion, a mistake.
You're free to do whatever you want. Short-circuit evaluation behaves predictably, so it's going to work, but it may be confusing to people unfamiliar with that style.