-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add a project .editorconfig file #7081
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
Conversation
This adds settings based on some common-sense values and the Cirq project's current conventions, such as line length and use of spaces instead of tabs.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7081 +/- ##
==========================================
- Coverage 98.17% 98.17% -0.01%
==========================================
Files 1089 1089
Lines 95217 95217
==========================================
- Hits 93481 93475 -6
- Misses 1736 1742 +6 ☔ View full report in Codecov by Sentry. |
.editorconfig
Outdated
# Important setting: trailing whitspace is meaningful in Markdown. | ||
trim_trailing_whitespace = false |
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.
Can you please comment when is this needed?
My impression was that trailing spaces in md were basically a noise that would be better removed.
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.
It's a little bit bonkers, but the use of 2 trailing spaces is one of the ways that md lets you indicate an explicit line breeak. Here are a couple of places where this is described:
- https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#line-breaks
- https://www.markdownguide.org/basic-syntax/#:~:text=Line%20Breaks,spaces%2C%20and%20then%20type%20return.
I'll try to find a public spec somewhere and add a comment to the .editorconfig file to point to it.
The Google md style recommentation (which I can't find atm) recommends avoiding this construct. However, because it's technically allowed, and because other style guides and formatters pay attention to it, and because there doesn't seem to be a setting in editorconfig for "allow exactly 2 spaces but remove 1 or 3+ spaces", the only safe thing to do for md files seems to be to disable the setting to remove trailing whitespace. (If there's a better way, I'm completely happy to do it!)
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.
Actually, I didn't test this, but I bet 3 or more spaces would also produce a line break.
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.
Ah, markdownlint has a setting to control this: https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md#md009---trailing-spaces
The default is 2 spaces, meaning it will flag single spaces at the ends of lines.
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.
There are only 3 places in our markdown files that have 2 trailing blanks. None of those is necessary; they don't really seem intentional.
$ git grep -n "\s{2,}$" "*.md" "*.mark*"
.github/ISSUE_TEMPLATE/project_health.md:3:about: Issues related to CI, automation infra, clean code, depreca>
docs/dev/nomenclature.md:14:`wave_function`, or `state` for this object (`state` is too overloaded).
docs/dev/style.md:13:with the following guidance.
I think the Google style guide recommendation against trailing double-spaces is reasonable.
They make text behave differently without visible markup, which makes it harder to judge if those spaces are intentional or left over from text editing. It is IMO better to stick to the explicit \
or <br>
syntax for creating manual linebreaks.
Can we disallow trailing blanks in editorconfig and also flag them as errors in markdownlint?
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.
Yes; I'll make the change and push an update. (Actually, I just looked at our .markdownlintrc
again, and it turns out it already disallows trailing spaces.)
Per discussion in the [review comments](quantumlib#7081 (comment)), the feeling is that it's better to avoid trailing spaces because they are bad for several reasons.
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.
Thank you!
* Resolve quantumlib#6998: add a .editorconfig file This adds settings based on some common-sense values and the Cirq project's current conventions, such as line length and use of spaces instead of tabs. * Add explanation for .md setting for trailing spaces * Take out exception to trailing spaces rule for .md files Per discussion in the [review comments](quantumlib#7081 (comment)), the feeling is that it's better to avoid trailing spaces because they are bad for several reasons.
This adds settings based on some common-sense values and the Cirq project's current conventions, such as line length and use of spaces instead of tabs.
This resolves #6998.