ES6 functions reported as error in WebStorm

I'm working on a Meteor project that includes ES6, and it's not recognizing properly and reporting as error.

 

As an example:

 

this.autorun( () => this.subscribe('products',
this.state.get('products.skip'),
this.state.get('products.limit'),
this.state.get('products.sort')
));


The first line is reporting 2 errors - both the () and the arrow function. But it works perfectly in program.

I made sure in config ES6 was selected for JavaScript and it was, and made sure to import packages as library in order to make sure it was detected by Meteor if that was the issue... and still this issue persists.

 

Very annoying that if I use ES6 the entire directory branch turns red, makes it really hard to find out if there really is an error.

 

Any advice on how I could fix this?

14 comments
Comment actions Permalink

works fine for me:

 

 

Please try invalidating caches - does the problem persist? If yes, please attach screenshots of your settings plus the screenshot of the file with errors. Does the problem occur in .js files? Or?

2
Comment actions Permalink

I'm also having issues with formatting .vue files.

This code is valid and works fine, although Webstorm is reporting errors

When beautifying this code it gets even worse, effectively introducing real errors.

Before going into further detail, does anyone know of any issues around es6 formatting ?

0
Comment actions Permalink

seems to be fixed with latest update

WebStorm 2016.3.1
Build #WS-163.7743.51, built on November 22, 2016

0
Comment actions Permalink

hm... not fixed.

Problem randomply occurs

0
Comment actions Permalink

Please try invalidating caches (File | Invalidate caches, restart)

1
Comment actions Permalink

Invalidating caches only fixes the problem temporarily. Need to do this almost every day.

No one else having this problem?

0
Comment actions Permalink

there must be some errors that lead to index corruption. Please recreate the issue and attach your idea.log

-1
Comment actions Permalink

I might found a solution, the below worked for me.

Webstorm > Preferences > Languages and Frameworks -> Javascript > ECMA Script6

IMPORTANT NOTE: do NOT go to Languages and Frameworks from File > Default Settings

Cheers.

3
Comment actions Permalink

Same goes for PHPStorm, but what I realized is the errors were  being generated from JSHint.  It looks like PHPStorm/WebStorm do not sync the version to JSHint.

 

The fix for me:

 

Under Code Quality Tools > JSHint, make sure "EcmaScript.next esnext" is checked.

1
Comment actions Permalink

I've been having this issue for the last year or so, the only solution is invalidating caches, sometimes that fix lasts for a few weeks, other times it only lasts a few hours. I've tried all of the solutions mentioned above in this thread.

0
Comment actions Permalink

> the only solution is invalidating caches, sometimes that fix lasts for a few weeks, other times it only lasts a few hours.

 

I can think of 2 possible reasons for this behavior:

- you share some files/folders between projects that have different JavaScript Language versions set: once you open both, ES6 features won't be recognized until the second project is closed and version re-set/caches invalidated (https://youtrack.jetbrains.com/issue/WEB-16665)

- your indexes get broken because of some errors

In the latter case, please try the following:

- invalidate caches, delete all idea.log.* files

- wait until the problem appears again

- provide all generated idea.log.* files

1
Comment actions Permalink

JSHint was flagging (underlining) ES6 constructs until I had all of these tweaks in place:

  • Selected ECMAScript 6
  • Invalidated caches / Restarted ...
  • Set JSHint "Warn about incompatibilities with the specified ECMAScript version"

 

Select ES6




Trash the cache


Set JSHint warning to ECMAScript 6


1
Comment actions Permalink

I wanna share some experience if someone like me got here for answer and didn't find it.

I've went to Settings | Languages & Frameworks | JavaScript and set it to ECMA6, but still got ES6 features underlined with red and a message that current JS version does not support them (File | Invalidate caches/restart didn't help either).
I was hoping to get an answer from logs and found that Help | Show log in explorer contains rather much data, so I decided to first delete everything from  that directory. After that, I restarted WebStorm and... errors are gone.
I have absolutely no idea, what happened and how is that ever possible, but if solutions provided here don't work for you, try doing the same.

0
Comment actions Permalink

Just for the ones that make the mistake I did.

For WebStrorm (javascript):

I imported a function named init while having a init field in the window global object

(Banged my head against the wall for an hour. Maybe this saves someone's else time :))

0

Please sign in to leave a comment.