A Comparison of JavaScript Linting Tools

Well let’s compare the difference, with a simpler to examine situation involving parenthesis.

The question is: should an opening parenthesis always be followed by a space, and a closing parenthesis have a space just before it?

When there is no inter-parenthetical space involved, we have the following code:

function calc(a) {
    return (a + 3) * 4;
}

When there is a space involved, we end up with confusion in regard to the function parenthesis:

// air-gapped parenthesis
function calc ( a ) {
    return ( a + 3 ) * 4;
}

Do function parameters parenthesis behave the same as expression parenthesis? Or are they different?

// only air-gap expression parenthesis
function calc (a) {
    return ( a + 3 ) * 4;
}

Are the function names to be separated from the parenthesis too? They then become too easily confused with variables instead.

What happens when there are no function parenthesis?

// how to handle empty function parameters
function calc( ) {
    return ( 2 + 3 ) * 4;
}

Should the linter insist on a double space in the middle, one for each parenthesis, or just stick with a single space?

// a double space, one for each parenthesis
function calc(  ) {
    return ( 2 + 3 ) * 4;
}

Does it also mean that immediately invoked function expressions have to be spaced out too?

( function ( ) {
    ...
} ( ) );

Just how are such parenthesis spacing issues to be determined by a static linter, let along a human being?

There is a way around such quandaries, and that is to take the path of least confusion. That being to insist on no space on immediately inside of parenthesis.

function calc(a) {
    return (a + 3) * 4;
}

On a separate note, have you chosen a particular set of coding style standards to stick to? There are quite a number of them, which are nicely compared at https://github.com/Seravo/js-winning-style