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?

0

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
Avatar
Permanently deleted user

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
Avatar
Permanently deleted user

seems to be fixed with latest update

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

0
Avatar
Permanently deleted user

hm... not fixed.

Problem randomply occurs

0

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

1
Avatar
Permanently deleted user

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

No one else having this problem?

0

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

-1
Avatar
Permanently deleted user

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.

4
Avatar
Permanently deleted user

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

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

> 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
Avatar
Permanently deleted user

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

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

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

请先登录再写评论。