Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EcmaScript 6 - Tern IDE for Eclipse validation errors

I am using Eclipse Mars with the Tern IDE für ES6 support on version 1.1.0 (the snapshot). I get validation errors on arrow functions and const-exports as can be seen in this screenshot:

enter image description here

I worked through these descriptions but the errors won't vanish: https://github.com/angelozerr/tern.java/wiki/Tern-&-ECMAScript6-support https://github.com/angelozerr/tern.java/wiki/Tern-Linter

I don't know however whats really supported by the Tern plugin, but according to the documentation on http://ternjs.net/ Tern should support arrow functions since 0.14. The IDE-page on github however only mentions class, import and promise support (which is beyond basic in my eyes for a plugin to support ES6).

Is there anyone who is developing ES6 with Eclipse with (more or less) full feature support? I kinda feel like a unicorn...

like image 338
Ahab Avatar asked Nov 02 '15 13:11

Ahab


1 Answers

Your error comes from JSDT Validator which doesn't support ES6 syntax (and not from tern).

tern 1.1.0-SNAPSHOT provides support for ES6 for completion, hyperlink, validation but not for ES6 validation. The linter https://github.com/angelozerr/tern.java/wiki/Tern-Linter is a type checker validator and not a syntax validator.

To validate ES6 with Eclipse IDE & tern.java, you must:

  • disable JSDT Validator. For that you can remove the JSDT nature from your .project. Or install (never tested) the not released Eclipse JEE distribution which provides an option to turn off internal parsing and validation. See http://tools.jboss.org/documentation/whatsnew/jbosstools/4.3.0.Final.html#javascript-development-tools-improvements

  • after that, you can use JSHint to validate ES6, with https://github.com/angelozerr/tern.java/wiki/Tern-Linter-JSHint. To enable JSHint to validate ES6 correctly it needs to get the "esnext"-option enabled otherwise ES6 syntax will be marked as errors. The option is found in the project properties\Tern\Validation\JSHint under "Relaxing options".

like image 155
Angelo Avatar answered Oct 30 '22 06:10

Angelo