Skip to content
This repository has been archived by the owner on Jun 20, 2019. It is now read-only.

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

Open
paulschreiber opened this issue Jan 3, 2018 · 3 comments
Open

Comments

@paulschreiber
Copy link

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
Copy link
Author

Similarly:

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

gets changed to:

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

@swashata
Copy link
Contributor

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

@paulschreiber
Copy link
Author

Still happening with eslint 5.0.1.

paulschreiber pushed a commit to paulschreiber/eslint-config-wordpress that referenced this issue Jul 6, 2018
kasparsd added a commit to kasparsd/contact-form-7-extras that referenced this issue Jul 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants