Is it possible to configure Eclipse Javascript formatting to match JSLint?

I cannot configure the Eclipse Javascript formatting options so that it generates markup. JSLint does not complain - first of all, space parameters when the option "allow inaccurate spaces" is not set in JSLint. Can this be customized?

For example, JSLint expects function declarations to be posted, as shown:

function () { } function foo() { } 

but I can only get the settings:

 function () { } function foo () { }
function () { } function foo () { } 

or

 function() { } function foo() { }
function() { } function foo() { } 

Alternatively, is there a lightweight editor / IDE that will format my javascript code to create markup that suits JSLint's whims?

+6
source share
1 answer

Try the jshint-eclipse plugin. Also see this question asked earlier.

Quote from the JSHint page :

JSHint is a JSLint fork, a tool written and maintained by Douglas Crockford.

Initially, the project began by creating a more customized version of JSLint - one that does not apply one specific coding style for its users, and then turns into a separate static analysis tool with its own goals and ideals.

jshint-eclipse is an eclipse plugin that integrates JSHint with Eclipse.

Update site for jshint-eclipse:
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.

Before

Note that the "Problems" view is empty.

No problems in the code

After

The JSHint plugin needs some configuration that needs to be done after installation. This is also stated on the jshint-eclipse website :

In 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 included JSHint for * .js files as follows:

enter image description here

After that, with the same JS file as before, errors are displayed in the "Problem" view:

enter image description here

+1
source

Source: https://habr.com/ru/post/922062/


All Articles