google / eslint-config-google

ESLint shareable config for the Google JavaScript style guide
Apache License 2.0
1.75k stars 139 forks source link

Config is not consistent with style guide #36

Closed makbol closed 7 years ago

makbol commented 7 years ago

Example: disabled keyword-spacing vs. 4.6.2 Horizontal whitespace

philipwalton commented 7 years ago

Can you please elaborate, and be specific?

makbol commented 7 years ago

Hello @philipwalton. I wanted to point out there's disabled rule keyword-spacing which

enforce consistent spacing before and after keywords

in line 202 whereas, in style guide we read

Use of horizontal whitespace depends on location, and falls into three broad categories: leading (at the start of a line), trailing (at the end of a line), and internal. Leading whitespace (i.e., indentation) is addressed elsewhere. Trailing whitespace is forbidden.

Beyond where required by the language or other style rules, and apart from literals, comments, and JSDoc, a single internal ASCII space also appears in the following places only.

  1. Separating any reserved word (such as if, for, or catch) from an open parenthesis (() that follows it on that line
  2. ...

Therefore I could write like:

if(condition){
  // ...
}

it won't be pointed by linter but according to style guide it's not correct. I catch this particular case but I think there might be more.

philipwalton commented 7 years ago

Thanks, I actually don't remember now why that rule wasn't set.

On initial read, it seems like it should be set to:

'keyword-spacing': 2, // defaults to {before: true, after: true}

Does that look right to you?

philipwalton commented 7 years ago

Sorry, I forgot to do this. Fixed via e24704c7df378d35aeaeb49dad1a29ebd06c1d6c. I'll cut a new version shortly.