-
Notifications
You must be signed in to change notification settings - Fork 5
feat: add .editorconfig for consistent formatting across editors #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mohdfarhanakram
wants to merge
2
commits into
camaraproject:main
Choose a base branch
from
mohdfarhanakram:add-editorconfig
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # EditorConfig - https://editorconfig.org | ||
|
|
||
| root = true | ||
|
|
||
| [*] | ||
| charset = utf-8 | ||
| end_of_line = lf | ||
| insert_final_newline = true | ||
| trim_trailing_whitespace = true | ||
|
|
||
| [*.md] | ||
| indent_style = space | ||
| indent_size = 2 | ||
| trim_trailing_whitespace = false | ||
|
|
||
| [*.{yaml,yml}] | ||
| indent_style = space | ||
| indent_size = 2 | ||
|
|
||
| [*.feature] | ||
| indent_style = space | ||
| indent_size = 2 | ||
|
|
||
| [Makefile] | ||
| indent_style = tab |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Normalize all text files to LF line endings on commit. | ||
| # Contributors on Windows will still see CRLF in their working tree | ||
| # (if core.autocrlf is set), but the repository always stores LF. | ||
| * text=auto eol=lf | ||
|
|
||
| # Explicitly mark binary formats so Git never attempts EOL conversion. | ||
| *.png binary | ||
| *.jpg binary | ||
| *.jpeg binary | ||
| *.gif binary | ||
| *.ico binary | ||
| *.pdf binary | ||
| *.zip binary | ||
| *.tar.gz binary | ||
| *.pptx binary | ||
| *.docx binary | ||
| *.xlsx binary | ||
|
|
||
| # Slim down release artifacts by excluding meeting minutes. | ||
| /documentation/MeetingMinutes export-ignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # OS-generated files | ||
| .DS_Store | ||
| Thumbs.db | ||
| Desktop.ini | ||
|
|
||
| # Editor / IDE files | ||
| .idea/ | ||
| .vscode/ | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
|
|
||
| # Node (used by some linting/tooling setups) | ||
| node_modules/ | ||
|
|
||
| # Python | ||
| __pycache__/ | ||
| *.pyc | ||
| .venv/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,40 @@ | ||||||
| # Workspace Configuration | ||||||
|
|
||||||
| Shared configuration files that should be placed in the **root** of each CAMARA API repository. | ||||||
|
|
||||||
| These files standardize editor behavior, line-ending enforcement, and ignored-file patterns across all contributors, regardless of OS or IDE. | ||||||
|
|
||||||
| ## Files | ||||||
|
|
||||||
| | File | Purpose | Placement in API repo | | ||||||
| |------|---------|----------------------| | ||||||
| | `.editorconfig` | Consistent indentation, charset, and line endings across editors ([spec](https://editorconfig.org)) | Copy as-is to repo root | | ||||||
| | `.gitattributes` | Enforces LF line endings at the Git layer and marks binary formats | Copy as-is to repo root | | ||||||
| | `.gitignore-template` | Common ignore patterns for OS, editor, and tooling artifacts | Copy to repo root **and rename** to `.gitignore` | | ||||||
|
|
||||||
| > `.gitignore-template` is named with a `-template` suffix so that Git does not pick it up inside this tooling repository itself. | ||||||
|
|
||||||
| ## Adoption | ||||||
|
|
||||||
| To adopt these configurations in an API repository: | ||||||
|
|
||||||
| 1. Copy `.editorconfig` and `.gitattributes` into the repository root. | ||||||
| 2. Copy `.gitignore-template` to the repository root and rename it to `.gitignore`. Merge with any existing `.gitignore` entries the repo already has. | ||||||
| 3. Commit and push. | ||||||
|
|
||||||
| If the repository already contains files with CRLF line endings, a separate normalization PR should be created after `.gitattributes` is in place — see [#113](https://github.com/camaraproject/tooling/issues/113) for the migration approach. | ||||||
|
|
||||||
| ## How the files work together | ||||||
|
|
||||||
| - `.editorconfig` guides editors to use the correct settings **while editing**, so contributors produce correctly formatted files from the start. | ||||||
| - `.gitattributes` acts as a **safety net at the Git layer** — even if an editor writes CRLF, Git normalizes to LF on commit. | ||||||
| - `.gitignore` keeps OS junk and editor artifacts out of version control. | ||||||
|
|
||||||
| ## Alignment with linting rules | ||||||
|
|
||||||
| The `.editorconfig` settings are derived from the existing linting configurations in [`linting/config/`](../linting/config/): | ||||||
|
|
||||||
| - **YAML** indent/whitespace rules match [`.yamllint.yaml`](../linting/config/.yamllint.yaml) | ||||||
| - **Gherkin** indent rules match [`.gherkin-lintrc`](../linting/config/.gherkin-lintrc) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| This keeps editor formatting and CI linting in sync, so contributors get feedback while editing rather than failing in CI. | ||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.