EditorConfig

EditorConfig to standardize Code Styles

We should use EditorConfig to define formatting conventions for textual files in a project. Without consistency, the code can appear untidy and be a pain to read, depending on a user's development environment. A common solution is to share editor settings as part of the project, but this assumes all committers are using the same editor.

The Benefit of using common EditorConfig

  • EditorConfig makes code more readable

  • EditorConfig makes Code Reviews Easier

  • EditorConfig makes development easier

.editorconfig
# Declares that this is the top-level configuration

root = true

# Applies to all files
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
curly_bracket_next_line = false
spaces_around_operators = true

[*.{js,py}]
charset = utf-8


# 4 space indentation
[*.py]
indent_style = space
indent_size = 4


# Tab indentation (no size specified)
[Makefile]
indent_style = tab

# Applies to all Markdown files
[*.md]
trim_trailing_whitespace = false

[*.cs]
curly_bracket_next_line = true

# Applies to all C# and Java files, overriding rules declared before
[*.{cs,java}]
indent_size = 4

[*.{js,ts}]
quote_type = single

[*.tsv]
indent_style = tab


# Indentation override for all JS under lib directory
[lib/**.js]
indent_style = space
indent_size = 2

# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
indent_style = space
indent_size = 2

Django Editor Config

Last updated

Was this helpful?