Lloyd Banks
Lloyd Banks

Reputation: 36649

'Statement Expected' Syntax Error Highlighting on First Line of JS File in PHPStorm

I have a JS file where no matter what is put on the first line (comment or code), PHPStorm lists a syntax error. When I hover over the error, the description says "Statement Expected". What it looks like:

enter image description here

Is this a bug with the IDE or something that can be disabled?

EDIT

Sample file here

Upvotes: 16

Views: 20219

Answers (3)

redflasher
redflasher

Reputation: 717

You can turn off "Properties > Languages & Frameworks > Template Data Languages" and error "statement expected" will go out. enter image description here

Upvotes: 2

vikram eklare
vikram eklare

Reputation: 820

In most of the cases this issue occurs due to copy paste. There may be some characters/line feed which may need to rewrite in your IDE.

In such cases simply copy your code to notepad and again copy it back to your IDE.

Upvotes: 4

LazyOne
LazyOne

Reputation: 165158

You have UTF-8 BOM signature (EF BB BF) just before var myApp= line (first code line in that file)

enter image description here

If you remove it IDE will stop complaining.

P.S.
Yes -- IDE should be smarter in such case and should provide better error message and error location. Feel free to submit new ticket to the Issue Tracker at http://youtrack.jetbrains.com/issues/WI

Upvotes: 20

Related Questions