Skip to content
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

(docs) Switch to remark-lint/remark-stringify for linting/formatting markdown #21468

Closed
tesseralis opened this issue Feb 14, 2020 · 2 comments · Fixed by #21919
Closed

(docs) Switch to remark-lint/remark-stringify for linting/formatting markdown #21468

tesseralis opened this issue Feb 14, 2020 · 2 comments · Fixed by #21919
Assignees
Labels
type: documentation An issue or pull request for improving or updating Gatsby's documentation type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@tesseralis
Copy link
Contributor

tesseralis commented Feb 14, 2020

Description

Switch to remark-lint for the docs' Markdown linter and remark-stringify for formatting.

Motivation

The most pressing need for remark-lint is the ongoing effort to translate the Gatsby docs. There are specific style rules that need to be enforced in order for our translation process to work correctly:

In addition to localization of the docs, remark-lint would be beneficial for enforcing many of the rules found in the Gatsby Style Guide, through the use of existing rules and possibly creating our own. We can prohibit certain strings and suggest alternatives, prevent non-descriptive-link-text or even limit the number of emoji used on a page!

Implementation

  1. Install remark-lint and remark-stringify along with recommended rules and run them on the docs.
  2. Add docs/ directory to .prettierignore and set lint-staged to run remark instead of prettier on markdown files.

Issues

remark-stringify is, to my knowledge, incompatible with Prettier and will format some things differently without any config option to change them. For example, prettier automatically escapes dollar signs ($ becomes \$) but remark-stringify does not, unless remark-math is installed. Prettier deletes lines in between link definitions, while remark adds newlines in between them. If we want to add remark-lint, we need to completely switch it out with prettier for the docs. We may need to add instructions to contributors, e.g. installing a remark-lint plugin for VS Code.

Alternative Solutions

The primary thing we want to enforce for localization is the explicit heading IDs. For this, the alternate solution is to just create a custom script to add the heading IDs. This was our initial plan, since it would be faster and need a lot less buy-in from the rest of Gatsby. But soon I realized that there were even more rules that would need to be enforced for translation, and it didn't make sense to create multiple one-off scripts for each of them, rather than relying on an existing framework with existing rules and plugins built in.

Related

Previous implementation: #18942 - This PR should be used as a reference, but it's pretty old and now has a lot of merge conflicts

@gatsbot gatsbot bot added the type: documentation An issue or pull request for improving or updating Gatsby's documentation label Feb 14, 2020
@tesseralis tesseralis added the help wanted Issue with a clear description that the community can help with. label Feb 14, 2020
@nik72619c
Copy link

@tesseralis can I work on this one ?

@tesseralis
Copy link
Contributor Author

@nik72619c sure, go ahead!

@tesseralis tesseralis added status: community assigned and removed help wanted Issue with a clear description that the community can help with. labels Feb 17, 2020
@tesseralis tesseralis assigned tesseralis and unassigned nik72619c Mar 3, 2020
@tesseralis tesseralis changed the title Add remark-lint to docs Switch to remark-lint/remark-stringify for linting/formatting markdown Apr 20, 2020
@tesseralis tesseralis changed the title Switch to remark-lint/remark-stringify for linting/formatting markdown (docs) Switch to remark-lint/remark-stringify for linting/formatting markdown Apr 20, 2020
@tesseralis tesseralis added topic: i18n type: question or discussion Issue discussing or asking a question about Gatsby labels Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation An issue or pull request for improving or updating Gatsby's documentation type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants