4

I am using the Eclipse (version Indigo) JavaScript code formatter and using the jshint-eclipse plugin with white: true option for code convention validation.

Eclipse code formatter and JSHint plugin conflict with the anonymous function declaration format. The JavaScript code formatter formats anonymous functions like the following:

var f1 = function() {
};

But the jshint-eclipse plugin gives a "Missing spaces after function" warning. The right format for this plugin is:

var f1 = function () {
};

NOTE THE SPACE AFTER THE function

Is there a way to format anonymus function declaration differently with eclipse than regular function declarations. I would like to add one space after "function" for anonymous functions but not for normal functions.

Thanks.

Update a relevang eclipse bug is here

Vanuan
  • 31,770
  • 10
  • 98
  • 102
Norbert Tamas
  • 4,464
  • 5
  • 23
  • 28

2 Answers2

0

There is a bug for this: https://bugs.eclipse.org/bugs/show_bug.cgi?id=315507

Similar bug in Aptana was fixed: http://jira.appcelerator.org/browse/APSTUD-3792

I've worked out a patch for this: https://github.com/eclipse/webtools.jsdt.core/pull/1 which hopefully will be merged and released soon.

Vanuan
  • 31,770
  • 10
  • 98
  • 102
-2

Check the JavaScript formatting preferences (Preference->JavaScript->Code Style->Formatter) on the White Space tab, for the Declarations of Functions.

nitind
  • 19,089
  • 4
  • 34
  • 43
  • 1
    Thanks for answering nitind. I checked that but there is no way to set the declaration formatting separately for anonymous function declaration and regular function declaration. – Norbert Tamas Mar 06 '12 at 13:43