sbhtw sbhtw - 1 month ago 4x
Javascript Question

qx.log.appender Syntax

When declaring qx.log.appender.Native or qx.log.appender.Console, my IDE (PyCharm) complains about the syntax:

// Enable logging in debug variant
if (qx.core.Environment.get("qx.debug"))

(as documented here)

The warning I get is

Expression statement is not assignment or call

Is this preprocessor magic or a feature of JavaScript syntax I'm not aware yet?

Clarification as my question is ambiguous:

I know that this is perfectly fine JavaScript syntax. From the comments I conclude that here's no magic JS behavior that causes the log appenders to be attached, but rather some preprocessor feature?!

But how does this work? Is it an hardcoded handling or is this syntax available for all classes which follow a specific convention?

The hints how to turn off linter warnings are useful, but I rather wanted to know how this "magic" works


Although what's there by default is legal code, I find it to be somewhat ugly since it's a "useless statement" (result is ignored), aside from the fact that my editor complains about it too. In my code I always change it to something like this:

var appender;

appender = qx.log.appender.Native;
appender = qx.log.appender.Console;