I can't seem to configure the Eclipse Javascript formatting options so that it generates markup JSLint doesn't complain about - primarily whitespace settings when the "tolerate sloppy whitespace" option isn't set on JSLint. It is possible to configure this?
For example, JSLint expects function declarations to be spaced as shown:
function () {
}
function foo() {
}
but I can only get the settings to produce:
function () {
}
function foo () {
}
or
function() {
}
function foo() {
}
Alternatively is there a lightweight editor/IDE which will format my javascript code to create markup that satisfies the whims of JSLint?
Try jshint-eclipse plugin. Also see this question asked earlier.
Quote from the JSHint page :
JSHint is a fork of JSLint, the tool written and maintained by Douglas Crockford.
The project originally started as an effort to make a more configurable version of JSLint—the one that doesn't enforce one particular coding style on its users—but then transformed into a separate static analysis tool with its own goals and ideals.
jshint-eclipse is an eclipse plugin that integrates JSHint with Eclipse.
The update site for jshint-eclipse is : http://github.eclipsesource.com/jshint-eclipse/updates/
Update
I wanted to post some snapshots to show the effect of installing this plugin on Javascript files.
Note that the Problems view is empty.
The JSHint plugin needs some configuration to be done after installation. This is also listed on the jshint-eclipse site :
On a project that contains JavaScript files, open the context menu and select Properties On the JSHint page, enable JSHint for this project
I did the above and enabled JSHint for *.js files like so :
After doing that with the same JS file as before, the Problem view begins showing errors:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With