1
votes

I recently switched to PHPStorm and it's great, but I have a bunch of .js files that contain Smarty tags to insert a bit of scaffolding; but this breaks PHPStorm's syntax checker, highlighting all my code in red because it's not seeing the opening tags that the smarty tag will insert.

{include file="../../WidgetClassStart.js"}

    return widgets_Base.extend( {

The error is "'return' outside function definition".

Can I get PHPStorm's syntax checker / compiler to either evaluate the Smarty tag's contents or ignore this specific pattern (since it's the same everywhere) for that specific error?

1
Same problem - The code base I must work in does this everywhere, so there are red lines under everything. It makes it impossible to see other errors or warnings. - Tristan

1 Answers

0
votes

I ended up putting a

var widget;

in WidgetClassStart.js;

In every widget I replaced "return ..." with

widget = ...

And then I return that var in the WidgetClassEnd.js file,

return widget;

so now WidgetClassEnd.js is the only place this error occurs and all my widgets are at least free from red squiggly lines.