uber / standard

JavaScript Standard Style — One Style to Rule Them All
MIT License
70 stars 8 forks source link

restrict no-extra-parens to functions only #31

Closed andrewdeandrade closed 9 years ago

andrewdeandrade commented 9 years ago

When this rule was originally proposed, @raynos suggested that it might lead to reduced readability, but lets give it a shot. It appears that @ardok might have a reasonable example of code that should be allowed so maybe this rule should be relaxed to only applying to functions, e.g. [2, "functions"] in the rc file.

https://github.com/eslint/eslint/blob/master/docs/rules/no-extra-parens.md

ardok commented 9 years ago
// `response` is a response object that we get from server

// This should be allowed since it shows the developer's intention clearly
var numPage = (response && response.page) || 1;

// Just by a quick glance, the example below is definitely more "confusing" than the one above
var numPage = response && response.page || 1;
Raynos commented 9 years ago

:+1: for "functions" only.

rtsao commented 9 years ago

I agree, I think redundant parens can be useful for readability such as @ardok's example.

andrewdeandrade commented 9 years ago

Feel free to submit a PR to restrict no-extra-parens to functions only in es6 mode.

rtsao commented 9 years ago

Why only ES6 and not standard mode also?

Raynos commented 9 years ago

lets do it in standard mode too.