Using editorconfig within Git submodules
Asked Answered
M

1

10

I have a Web application which has dependency on an external module for JSON schema validation. The Web app has its Git repository, within which the module is included as a Git submodule.

On the Web project, I have editorconfig for syntax standardisation. For this(as I use Sublime text), I use editorconfig-sublime.

The module is maintained by another team, and they have their own coding style. I occasionally contribute to it though.

The issue I'm having is that when I add code within the Web folder, to the module, my coding style clashes with theirs, as I have my own .editorconfig file. They don't currently use editorconfig.

My question is this:

Is it possible and if yes, advisable to use one .editorconfig in the base Git repository and another .editorconfig in the Git submodule? What is the best practice here?

Marris answered 11/7, 2016 at 7:12 Comment(1)
This is not the answer you're looking for, but if they really care about maintaining their coding style then I think it's not out of line to ask them to add an editorconfig file or some other formatting process to their repo.Daub
G
1

The best practice would be to use an .editorconfig file for the submodule.

Having an .editorconfig file for each repository is good practice even if the main developers don't use it.

It is a good way of communicating the coding style for the module without enforcing a specific IDE on anyone. And if any collaborator uses an .editorconfig compatible tool they may not even know they are using it, yet benefit from it.

However, if the repository is out of your control or they just don't want to add the .editorconfig file, there's a couple of things you can do in your main .editorconfig file.

One option is adding rules for that specific directory:

[/submodule-directory/**/*.js]
charset = utf-8
indent_style = space
indent_size = 2

Another option is ignoring your rules with unset for a specific directory:

[/submodule-directory/**]
charset = unset
indent_style = unset
indent_size = unset
Genna answered 18/7, 2020 at 15:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.