-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Added linter/formatter for markdown files; Formatted documentation #18942
Added linter/formatter for markdown files; Formatted documentation #18942
Conversation
Does |
@gatsbyjs/gatsby-deploy @gatsbyjs/core friendly ping |
What sort of rules do you want to enforce with Remark that Prettier doesn't already auto-format? I feel like configuring Prettier to work in the translation repos (as done here) would be the better option. |
which setting changes an list from 1 space to 3 spaces? My List:
- - word
- - word
+ - word
+ - word |
@tesseralis I explained in a long description one case related to ordered list. Here is a full list that I noted
With prettier we haven't any control and strict rules about how markdown should look |
can it changed to have only one space after the |
Prettier will always format lists, emphasis/bold symbols, ... the same (see Markdown Playground) |
I tried the playground and it changes all lists there to a one space list even if there are 3 space lists are in the source + List 3 spaces
+ List 1 space
+ List 2 spaces Becomes: - List 3 spaces
- List 1 space
- List 2 spaces But most of your diffs are going from one space to 3 spaces - that is the question: why? |
@muescha Sorry for long response. It seems like remark autofix from b6a5488 commit. I'll check the remark config @MichaelDeBoey take a look on this example |
@alexandrtovmach The zero-started one is a bug in Prettier I think |
@MichaelDeBoey prettier based on remark, where this issue is coming from remarkjs/remark-lint#219 but if you check the prettier codebase you can find their custom realization: which are not allowed "zero" start value at all |
@MichaelDeBoey Another thing is forcing one style: 1. list
1. list
1. list or 1. list
2. list
3. list prettier cannot do that |
Prettier only has 1 Markdown parser, so if they're using
Maybe this can be added as a feature to prettier? 🤔 |
@MichaelDeBoey Can you open issue in prettier? |
@MichaelDeBoey I already did that prettier/prettier#6625 but it's rejected in reasons of their philosophy |
Maybe you can use |
We could indeed use Issue for broken zero-based links : prettier/prettier#6813 If those 2 issues are fixed, I think we really have everything (except for the ascending list numbers) in place what you're trying to do here @alexandrtovmach. |
it looks like it uses some default 4 spaces tab. But can be adjusted in the plugin options - see readme: https://github.com/remarkjs/remark-lint/blob/master/packages/remark-lint-list-item-indent/readme.md |
is it possible to add bad words for better language like in #18702 |
@muescha Yes it's possible to add this plugin https://github.com/zerok/remark-lint-write-good |
You can try eslint-mdx and remark-preset-prettier. |
Short story
This PR contain configured remark-lint with remark-preset-lint-gatsby and formatted documentation.
Long story
After translation process initiated, I started looking for some linter for docs. We already have a
prettier
, so I thought:I made a big research, and find few good linters:
Then I started playing with configaration, but faced with blocker just in a few hours. This blocker is "formatting ordered list marker values to one stardard". That's awful, but just a first document in Gatsby tutorial can't be formatted in a good way:
Example: docs/tutorial/index.md
The problem is first ol(ordered list) starting with
0
, and next values is1
, but for a second ol start value is4
. That mess of styles, and by good approach should be standartized to one style...I asked Google ― "how to configure prettier for ordered list". But no response...
Okay, I cloned
prettier
reviewed codebase, discovered that it's based on https://github.com/remarkjs/remark, mentioned above, but didn't find solution for my question. Then I spend a bit more time and implemented functionality that I needed, made PR...It's rejected by their philosophy
What's next?
After changing my mental model, understanding that's prettier won't help me, and I need to looking for something else, I decided to use
remark
.Why remark?
Because it can lint, format, has CLI and sponsored by GatsbyFirstly I created preset of rules for Gatsby:
https://github.com/alexandrtovmach/remark-preset-lint-gatsby
Then installed and configured remark into https://github.com/gatsbyjs/gatsby project
And fixed all linter warnings (400 files changed)
For what we need this linter?
standard markdown format in original repo -> autotests for new content -> reducing count of problems with translation merges
Does it final version?
Of course, it's not!
I just initialized the process and hope to have feedback and help from community to complete this part.