eslint-config-wordpress icon indicating copy to clipboard operation
eslint-config-wordpress copied to clipboard

space-in-parens exception allows for no space before closing paren

Open paulschreiber opened this issue 8 years ago • 3 comments

The current space-in-parens rule is:

'space-in-parens': ['error', 'always', {exceptions: ['{}', '[]']}],

gives you code like

if ( ! m[12]) {

instead of the expected

if ( ! m[12] ) {

I'm not sure if this is an eslint bug, or a ruleset bug. What do you think?

paulschreiber avatar Jan 03 '18 18:01 paulschreiber

Similarly:

this.progressBar.addEventListener( 'touchstart', _.bind( this.seek, this ), { passive: true }) ;

gets changed to:

this.progressBar.addEventListener( 'touchstart', _.bind( this.seek, this ), { passive: true });

paulschreiber avatar Feb 01 '18 16:02 paulschreiber

I checked the rule in eslint docs. It says,

// Examples of correct code for this rule with the "always", { "exceptions": ["{}", "[]"] }] option:
/*eslint space-in-parens: ["error", "always", { "exceptions": ["{}", "[]"] }]*/

bar({bar:'baz'});
baz( 1, [1,2]); // <-- Notice the space here
foo({bar: 'baz'}, [1, 2]);

I guess the rule simply means, there should be space inside parens, until it is followed or preceded by any of these combinations {}, [].

IMO for the ^4.18 version of ESLint, what we need is,

"space-in-parens": ["error", "always", { "exceptions": ["empty"] }]

To disallow space for empty parens.

Thoughts @ntwb

swashata avatar Mar 16 '18 05:03 swashata

Still happening with eslint 5.0.1.

paulschreiber avatar Jul 06 '18 16:07 paulschreiber