javascript code formatting doesn't work at all in eclipse under xubuntu. Same problems with auto-completion and with validation. I tried different way to install Eclipse and its different plugins nodeclipse, tern, jsdt ... I tried to open file with different editors. I tried to change formatting profile. But everywere everything just doesn't work. It perfectly works for C/C++. But javascript not. It look like something generally wrong with my eclipse+javascript+node.js environment. But what?
2 Answers
Did you try JSDT pluging? https://eclipse.org/webtools/jsdt/ It adds a JavaScript project type and perspective to the Eclipse Workbench as well as a number of views, editors, wizards, and builders.
10 Comments
The Eclipse "JavaScript Editor" (from JSDT) always had some issues. Formatting does work, but can break under some circumstances.
The JavaScript-Plugin in Eclipse is buggy and evil since a few years.
Quota from: Auto-formatting of JavaScript code in Eclipse
This is not just my opinion, this has been going on for years as the Eclipse community had a hard time catching up with the Java/JavaEE evolutions (and C/C++ and ...) in parallel to all the JavaScript changes. I do not blame them as this is all for free !
The Eclipse JavaScript Editor (JSDT one) can 'choke' on various keywords for example: myObject.import(xyz); will break it (on some versions at least) due to the import keyword.
Sometimes I also noticed that some types of calculations involving divisions and many brackets broke the formatter. Autocompletion also has many issues, support is far from that of Java or C/C++.
It can also get slow due to code folding, but that can be disabled in Editor/Folding and spell checking which can also be disabled.
Eclipse Wild Web Developer
With the latest Eclipse releases since 2019 / 2020 you can use Eclipse Wild Web Developer (Red Hat is the main contributor):
Background:
Because of technical reasons (reimplementation of parsers mostly) and strategical priorities (Java EE), Eclipse IDE and the WebTools project have hard time catching up with innovation in the front-end Web development world. As a result, several editors for typical web languages (CSS, HTML, JavaScript...) shipped in the Simultaneous Release are of low quality compared to the state of the domain and competiting IDEs.
Yes we noticed ^^
Eclipse Wild Web Developer integrates existing artifacts like TextMate grammars and Language Servers to provide a rich development experience to Web developers using typical programming languages for the Web (CSS, HTML, JSon, JavaScript, TypeScript...).
Eclipse Wild Web Developer is about integrating existing technologies for those languages more than creating more specific language smartness.
That is a wise decision. This reminds me of Unity vs Gnome in Ubuntu ... or various browsers ending up using Chromium. Maintaining your own stuff and keeping the pace is hard.