Skip to content

added editorconfig#27490

Merged
thaJeztah merged 1 commit intomoby:masterfrom
caarlos0:editorconfig
Oct 21, 2016
Merged

added editorconfig#27490
thaJeztah merged 1 commit intomoby:masterfrom
caarlos0:editorconfig

Conversation

@caarlos0
Copy link
Contributor

Added .editorconfig file, so it's easier to avoid mistakes (like spaces vs tabs, etc).

@vdemeester
Copy link
Member

Why not but pretty much all Go editors are "wired" to gofmt (on save) and/or should be (otherwise the build fail here anyway), so it's more a nice-to-have than a requirement.

/cc @thaJeztah @dnephin @justincormack

@caarlos0
Copy link
Contributor Author

caarlos0 commented Oct 18, 2016

@vdemeester yeap, but there are also shell scripts and other kinds of files... I thought it would be useful to have them all under the same kind of format rules...

@vdemeester
Copy link
Member

/cc @tianon too 👼

@dnephin
Copy link
Member

dnephin commented Oct 18, 2016

IMO what is more valuable is a tool to enforce style as a git hook. I use http://pre-commit.com/ with https://gist.github.com/dnephin/c7776ecb5cdcf02eb1a6 to ensure that formatting is correct.

If we're going to add this, it's probably more appropriate under contrib/ somewhere, instead of the root of the repo. We can add .editorconfig to .gitignore so that developers can customize their copy as they want.

@thaJeztah
Copy link
Member

I'm wondering if this falls in the same category as https://github.com/docker/docker/blob/389d5cde7b5474cd33d251aadc96be1f0bdbc711/.gitignore#L2-L3

@dnephin
Copy link
Member

dnephin commented Oct 18, 2016

True, we don't need to add it to .gitignore.

@tianon
Copy link
Member

tianon commented Oct 18, 2016

Yeah, I agree -- this is useful information, and it's nice to see folks trying to standardize the way it's communicated, but I don't think the standard is firm enough yet that committing this at the top-level is warranted (perhaps more prudent once/if more editors start supporting this file out-of-the-box or if it becomes more common). contrib/ seems like a great place for it (contrib/editorconfig, for example, so that it's not hiding and is easy to find and symlink to .editorconfig if folks want to use it via something simple like ln -s contrib/editorconfig .editorconfig).

@caarlos0
Copy link
Contributor Author

@tianon @thaJeztah @justincormack @vdemeester Done, what do you guys think?

.gitignore Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this up, to keep the list in alphabetical order?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, just noticing this; should this be limited to .go files? We use spaces for Markdown (.md)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thaJeztah Just added the missing [*.md] section.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do use tab for shell script though 👼, I think it's good as is. *.md is handled down 😝

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🐸

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do use tab for shell script though 👼, I think it's good as is. *.md is handled down 😝

@tianon
Copy link
Member

tianon commented Oct 21, 2016

LGTM 👍

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@thaJeztah thaJeztah merged commit 0c767f0 into moby:master Oct 21, 2016
@caarlos0 caarlos0 deleted the editorconfig branch October 21, 2016 17:02
@caarlos0
Copy link
Contributor Author

Thanks 👍

@dnephin
Copy link
Member

dnephin commented Oct 21, 2016

I just learned something that changed my opinion on this. github actually supports .editorconfig!
You can see an example of it working here: https://github.com/go-swagger/go-swagger/blob/master/cmd/swagger/commands/initcmd.go

So if we set

[*]
indent_size = 4

Viewing code and diffs will show 4 space tabs instead of 8 space tabs.

I would be in favor of moving this out of contrib and back into the root of the repo so that we can have nicer looking code and diffs on github.

@thaJeztah
Copy link
Member

@dnephin that's nice! Is it only indent size that's taken into account, no other "side effects"?

@dnephin
Copy link
Member

dnephin commented Oct 21, 2016

I'm not sure, there doesn't seem to be much information out there about it. http://stackoverflow.com/a/33899831/444646 suggests that they never officially announced the support.

I suspect it does support any options that make sense from the UI. Maybe they apply to the in-browser editor as well.

@tianon
Copy link
Member

tianon commented Oct 22, 2016

Honestly, I kinda like that GitHub shows tabs at 8 spaces because it makes it much more obvious when someone screws it up in a PR because the 4-real-space-indents don't line up properly. 😇

@thaJeztah
Copy link
Member

Oh, you've got a point, it has helped me as well (if only GitHub had a show whitespace option)

@dnephin
Copy link
Member

dnephin commented Oct 22, 2016

Shouldn't we have automated style checks for that instead of relying on a human to notice it?

http://pre-commit.com/ with https://gist.github.com/dnephin/c7776ecb5cdcf02eb1a6 is a great option.

@thaJeztah
Copy link
Member

That would be good, however, I can imagine there's combinations that are harder to validate strictly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants