eslint-config-wordpress
eslint-config-wordpress copied to clipboard
space-in-parens exception allows for no space before closing paren
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?
Similarly:
this.progressBar.addEventListener( 'touchstart', _.bind( this.seek, this ), { passive: true }) ;
gets changed to:
this.progressBar.addEventListener( 'touchstart', _.bind( this.seek, this ), { passive: true });
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
Still happening with eslint 5.0.1.