Question

This is my JavaScript (much stripped down):

function addContent() {
    var content = [];
    content.append(
        makeVal({
            value : 1
        })
    ); // Generates lint message
}

Running a lint program over this, I get the message

unexpected end of line; it is ambiguous whether these lines are part of the same statement

on line 7. If I concatenate lines 6 and 7 the message goes away.

Can anyone explain where this ambiguity is? It seems to me that the parenthesis on line 7 is unambiguously closing the call to append().

Was it helpful?

Solution

It looks that way to me, too. Sounds like a bug in the lint program you're using.

You can understand why it would wonder, because the call to makeVal fits the profile of code that's relying on semicolon insertion — unless you look correctly at the wider context and realize it's within argument list for the append call. Seems to me the lint program is not actually parsing the language, just looking for patterns, which is going to mean it's going to have both false positives and false negatives.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top