google / eslint-config-google

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

Destructuring variable declarations: continuation cannot be more than +2 spaces #55

Open jcao219 opened 5 years ago

jcao219 commented 5 years ago
const {fieldFoo, fieldBar, fieldBaz,
       fieldLast} = myObject;

Raises an error, but since this a continuation, I believe this syntax should be allowed?

philipwalton commented 5 years ago

What is the error you're getting?

I believe the preferred indentation for this would be four spaces:

const {fieldFoo, fieldBar, fieldBaz,
    fieldLast} = myObject;

I believe technically Google style allows (but discourages) more than 4 spaces, though I don't think there's any way to configure ESLint to allow that (without writing a custom plugin).

jcao219 commented 5 years ago

For your example, I'm getting:

error Expected indentation of 2 spaces but found 4 indent

By the way, I tend to like to write line continuations like this for my personal visual preference, but I'm not sure if it's best:


doStuffWithThese(longArgumentName, quiteAFewArguments, probablyCodeSmell
                 longArgumentNameAgain);
nextLine();
someMoreWork();
philipwalton commented 5 years ago

I think, unfortunately, ESLint is not able to detect the difference between a line continuation in an object block and normal block indentation.