Ad

Disabling "expression Expected" From PhpStorm 10

- 1 answer

I'm doing some react.js in PhpStorm 10 and even though JSX Harmony is enabled as the JavaScript language level, it still gives all sorts of nonsense errors.

So I disabled inspection completely for JavaScript but it still gives errors like "expression expected" or "Expecting newline or semicolon".

How do I get ride of those for JS?

    <script type="text/babel">
        var MyComponent = React.createClass({
           render: function () {
               return <div>
               <h1><p>{this.props.text}</p></h1>
               </div>;
           }
        });

        React.render(<div><MyComponent text="text1" />
<MyComponent text="text2" /></div>, document.getElementById('container'));
    </script>

enter image description here

Ad

Answer

At the moment such inline scripts with type="text/babel" are not supported -- IDE only recognizes text/jsx as type for now.

https://youtrack.jetbrains.com/issue/WEB-18276 -- watch this ticket (star/vote/comment) to get notified on progress.

Possible workarounds (that I'm aware of):

  • change type to text/jsx (but then the in-browser babel most likely will not transform it, unless you can configure it somehow)
  • keep your JS code in a separate .jsx file

UPDATE: (23/03/2016) The aforementioned ticket is now marked as "Fixed" -- this functionality should be available in next update of 2016.1.

Ad
source: stackoverflow.com
Ad