Search code examples
javascriptecmascript-6vuejs2webstormbabeljs

ES6 syntax are highlighted as error in .vue files in WebStorm. How can I fix this?


enter image description here

WebStorm version: 10.0.1

Above image shows the JavaScript part of the .vue file. It works without problems but the IDE highlights the ES6 syntax as an error.

I saw people recommending using type="text/babel" or type="text/ecmascript-6" but in both cases it is all grey and there is no highlight:

enter image description here

In this thread it asks about my exact problem. Developer says it's gonna be fixed. (Though I thought the problem is IDE related).

It must be a very common problem among WebStorm users as most people use ES6 with Vue. Anyone fixed this?


Solution

  • Your WebStorm version (10.0.1) is too old.

    Adding the type="text/babel" to the <script> tag suggestion -- it's supported since 10.0.3 only.

    The "proper" fix for ES6 in inline scripts is available in WebStorm 2016.2 (which is over 1 year old already) -- https://youtrack.jetbrains.com/issue/WEB-16444


    I suggest to get latest WebStorm 2017.2.5 and give it a go (see how your code works there).

    Note that it now comes with own Vue.js plugin bundled .. so you may need to remove your plugin first (if you plan to import settings from current version).