-1

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?

someone
  • 21
  • 1
  • 1

2 Answers2

0

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.

  • Did you try add on your project : Web Page Suport -> Include Web Browser Library. – joelbarbosa Sep 09 '17 at 18:26
  • Yes I did. What I can copy-past to show? I mean which config or other file? What else I have to check? I spent more then day reinstalling and trying different plugins and editors – someone Sep 09 '17 at 18:57
  • In previous post I mant I tried JSDT I didn't try "Web Page Suport -> Include Web Browser Library" But how it related with code formatting for javascript? – someone Sep 09 '17 at 19:26
  • I thought that with "Include Web Browser Library" could helper the eclipse find the right way to dealing with it. What is your eclipse version? – joelbarbosa Sep 09 '17 at 20:11
  • Eclipse for JavaScript and Web Developers Version: Oxygen Release (4.7.0) Build id: 20170620-1800 – someone Sep 09 '17 at 23:17
  • Finally it start works with some .js files But it doesn't work for other. And I still couldn't find regularity. – someone Sep 09 '17 at 23:24
  • What kind of project is the file in, and where is it in relation to a source folder on the Include Path? – nitind Sep 10 '17 at 03:39
  • JavaScript project But I tried yo convert it in Tern project too. None of the features of the Tern works either. – someone Sep 10 '17 at 14:03
  • Re "the Include Path" In project in Sources the option "Include (All)" Excluded: \*\*/node_modules/\*, ... and couple more not important paths – someone Sep 10 '17 at 14:13
  • In some cases JSDT fails to format file, especially if code uses newer js syntax. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=357829 – user2075606 Nov 29 '17 at 12:30
0

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.

Christophe Roussy
  • 16,299
  • 4
  • 85
  • 85