Skip to content

Conversation

@johnlettman
Copy link
Contributor

This follows from the suggestion here: #87 (comment)

editorconfig is a simple, project-level configuration file (located in .editorconfig) that defines basic editor settings (indentation, character set, line endings, trailing whitespace, final newline, etc.) per file type so that editors and IDEs can automatically enforce consistent formatting across a codebase.

It is transparently supported by most major editors/IDEs.
Most often, nothing new is required on the developer's part -- no installing tools, no changing settings.

While pre-commit is in use for checking that certain style guidelines are followed, editorconfig can automatically configure the user's editor or IDE to use those style parameters when they are editing -- potentially saving the headache of noticing that they've written something outside of those style requirements later on.

This commit also adds a checker to pre-commit to double-check that the editor/IDE followed those guidelines.

The guiding principle for this submission was to follow the repository's apparent style choices, covering only the files that exist therein.

Note

Coincidentally, the .pre-commit-config.yaml had CRLF line endings, unlike any other file. This was also fixed.

This will appear in the changes as the file being entirely deleted and re-added (to change CRLF -> LF line endings). A close review will show that nothing was changed except the addition of the editorconfig checker. 😅

As always, I am open to changing this in any way to accommodate preferred style choices.

@johnlettman
Copy link
Contributor Author

Hmm, did not trip locally on the Python files.

I will leave this as a question regarding line length. It seems ruff is broken on the configuration here:

line-length = 512

I used the pre-commit hook manually:
https://github.com/astral-sh/ruff-pre-commit/blob/488940d9de1b658fac229e34c521d75a6ea476f2/.pre-commit-hooks.yaml#L15

$ ruff format --force-exclude

ruff failed
  Cause: Failed to parse /home/jlettman/repos/pr-prusa3d-openprinttag/pyproject.toml
  Cause: TOML parse error at line 2, column 15
  |
2 | line-length = 512
  |               ^^^
line-length must be between 1 and 320 (got 512)

@johnlettman
Copy link
Contributor Author

Matched line length to changes in #96.

@CZDanol
Copy link
Collaborator

CZDanol commented Nov 21, 2025

Hmm, there seems to be some formatting change in the pre-commit-config, causing the whole file to be diffed - any idea why is that?

Also, CI fails

@johnlettman
Copy link
Contributor Author

Hmm, there seems to be some formatting change in the pre-commit-config, causing the whole file to be diffed - any idea why is that?

Yes, that's a part of the note in the OP. The file contains CR-LF (Microsoft Windows) line endings while the rest of the repository is a mixture of CR-LF and LF (Unix) 😭

This is a bit why the following happens:

Also, CI fails

That mix of CR-LF and LF was picked up on the new CI/CD for .editorconfig. Further, a few files have a mix of [TAB] and [SPACE] for their indentation.

I will need to rebase on the recent pre-commit change that was merged and fix the other issues. I will, for the time being, keep the actual file fixes as a separate commit just in case something stands out to you as not in line with your expectations, so we can easily adjust.

editorconfig is a simple, project-level configuration file (located in `.editorconfig`) that defines basic editor settings (indentation, character set, line endings, trailing whitespace, final newline, etc.) per file type so that editors and IDEs can automatically enforce consistent formatting across a codebase.

It is transparently supported by most major editors/IDEs.

While `pre-commit` is in use for checking that certain style guidelines are followed, editorconfig can automatically configure the user's editor or IDE to use those style parameters when they are editing -- potentially saving the headache of noticing that they've written something outside of those style requirements later on.

This commit also adds a checker to `pre-commit` to doublecheck that those guidelines were followed by the editor/IDE.

The guiding principle for this submission was to follow the existing apparent style choices used in the repository, covering only those files which exist therein.

Coincidentally, the `.pre-commit-config.yaml` had CRLF line endings, unlike any other file. This was also fixed.

feat(editorconfig): add `.editorconfig`

editorconfig is a simple, project-level configuration file (located in `.editorconfig`) that defines basic editor settings (indentation, character set, line endings, trailing whitespace, final newline, etc.) per file type so that editors and IDEs can automatically enforce consistent formatting across a codebase.

It is transparently supported by most major editors/IDEs.

While `pre-commit` is in use for checking that certain style guidelines are followed, editorconfig can automatically configure the user's editor or IDE to use those style parameters when they are editing -- potentially saving the headache of noticing that they've written something outside of those style requirements later on.

This commit also adds a checker to `pre-commit` to doublecheck that those guidelines were followed by the editor/IDE.

The guiding principle for this submission was to follow the existing apparent style choices used in the repository, covering only those files which exist therein.

Coincidentally, the `.pre-commit-config.yaml` had CRLF line endings, unlike any other file. This was also fixed.

diff --git a/.editorconfig b/.editorconfig
index 06b892a..279e5aa 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -15,7 +15,7 @@ indent_size = 1
 [*.py]
 indent_style = space
 indent_size = 4
-max_line_length = 79  # PEP 8 recommendation
+max_line_length = 320 # matches `ruff` configuration

 [*.{yml,yaml}]
 indent_style = space
…ing issues

nit(repo): renormalize line endings `CR-LF` -> `LF`, fix file formatting issues
@johnlettman
Copy link
Contributor Author

johnlettman commented Nov 21, 2025

Okay, all updated.

Of course, I am in no rush. This technically touches quite a few files, but most of them will look like identical content diffs. This is because their line endings were normalized to Unix-style (LF) over Windows-style (CRLF).

I am aware that's an invisible change, but it seems a lot of files got checked in with a mixture of endings. I'm not sure how that happens, but it does slip by sometimes. As a means of preventing that in the future, there is a new .gitattributes file that tells git transparently convert those line endings before committing:
https://github.com/johnlettman/pr-prusa3d-openprinttag/blob/c3cb16971ef73d90b97c3de40cf91c8badb42a39/.gitattributes

Summary of Changes

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants