-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Inconsistent formatting of Markdown files #40796
Comments
Getting prettier onto the latest remark-parse version is going to be a significant project. There's some discussion in this issue prettier/prettier#6180 about moving to v6 from about a year ago. Can we help by putting some time towards assisting prettier in being able to upgrade? Changing remark-parse to the latest version locally causes a bunch of tests to fail in prettier, at a glance it doesn't look like it's going to be straightforward by any means. In the meantime, do we have a workaround that could unblock us for the time being? It seems like all but the last item in phase 1 won't happen until Prettier's dependency is updated, but if we move forward with spaces for markdown files like you suggested @scinos, will that be okay? |
Thanks for checking. I didn't know prettier was so behind in terms of There is an interesting plot twist worth mentioning: we are not using prettier, but our own fork wp-prettier. The idea was to update prettier to use latest remark, and then update our fork, so they are in sync. But we don't really have to update prettier first, we could just update our fork with latest remark (which means they will start to drift away). I don't think this is a great idea, but it is worth mentioning. I'd go with using spaces in our Markdown for now. |
I tried updating remark in prettier proper and around 80 markdown snapshot tests fail in non-obvious ways 😞 remark 5 -> 6 was a big one, it turns out and the My vote is to just use spaces as well 🙂 |
The PR to update |
This issue is stale because it has been 180 days with no activity. You can keep the issue open by adding a comment. If you do, please provide additional context and explain why you’d like it to remain open. You can also close the issue yourself — if you do, please add a brief explanation and apply one of relevant issue close labels. |
Already fixed in |
Problem
Our Markdown files are inconsistent. Some examples (not an exhaustive list)
apps/o2-blocks/README.md
uses hashes to create H1 tiles, whileapps/notifications/README.md
uses underline marksapps/notifications/README.md
uses-
to create lists, whileCODE-OF-CONDUCT.md
uses*
Code blocks have syntax errors (
docs/data-persistence.md
)Code blocks without language declaration (
docs/icons.md
)Mixture of regular spaces and non-breaking spaces and other typographical utf8 marks (
docs/testing/testing-overview.md
)Mixture of spaces and tabs for indentation (
apps/full-site-editing/full-site-editing-plugin/global-styles/README-DATA.md
)Inconsistent line lengths (
docs/data-persistence.md
vsdocs/development-workflow.md
)Solution
We can treat Markdown files as any other file with code, and use linters to fix the problems described above. We can even use the existing stack of linters (
eslint
+prettier
) to provide a developer experience very similar to linting JS/TS files.eslint
will be the main lint engine for Markdown files. This allows usingestlint
from the command line to lint MD files (eslint --ext .md <file.md>
), re-use the existingestlint
integration for editors (eg: highlight MD errors as we type, fix them on save), and keep custom linting rules together (.eslintrc
will contain rules for JS, TS and MD files).prettier
already has support for Markdown, it provides a set of opinionated defaults for Markdown. As with JS/TS files,prettier
rules will be the main source of formatting rules (i.e. will disableeslint
formatting rules that conflict withprettier
rules)remark
is the internal parser used byeslint
to read and format Markdown files. It incorporate their own set of rules (https://github.com/remarkjs/remark-lint/tree/master/packages/remark-preset-lint-markdown-style-guide#rules). We will not enable them for now. Once all our MD files are linted followingprettier
rules, we'll revisit this.Current status
The current error count is:
Most of them are auto-fixable. Note that this does not include the fix for the tabs vs spaces (see Note 1), so the actual error count may be lower and the ratio of fixable errors may be higher.
The number of affected files is 816. Their distribution is:
Execution status
Phase 1: contention
The goal is to stop introducing new lint errors.
prettier
plugin foreslint
. This will also affect JS files. See Adds prettier plugin to eslint #40118Migrate tabs to spaces in all MD files (see Note 1). This is a pre-requisite for the next step. See Reindent markdon with spaces as a workaround for remarkjs/remark#198 #40798(no needed with the upstream fix)remark
toprettier
to get a new version (likely 2.0.5)remark
update and match prettier's versioneslint
. This will allow developers to lint the MD files they are working on, and cause a CI fail if changed MD files are not linted correctly.Phase 2: reduction
The goal is to reduce the number of existing errors to zero.
The strategy will be to progressively fix existing errors, starting with folders with low number of errors and ramp up once we are confident in the changes that prettier will make and we get more experience with the kind of problems to look for
Phase 3: expansion
Experiment with further rules we may want to apply to our current codebase. For example, enable
remark
rules. This phase will also include create a custom MD rule that developers can use as a starting point to create future rules.Notes
The text was updated successfully, but these errors were encountered: