-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: script to lint mdx files by parsing it To implement auto translation, we need to create a script to separate some nodes such as import statement and code block using `remark` package. For that script to work, the mdx files need to be parseable by `remark`. Therefore, we need to check before commit whether all mdx files are parseable. * fix: fix mdx syntax errors There are 4 common errors: 1. Passing a JSX element as prop without curly braces. 2. `<a>` tag not started in new line 3. Whitespace expression `{" "}` right after `</a>` on the same line. 4. Whitespaces before JSX component, import statement, paragraph, etc. It can be fixed by using prettier. Also, I remove unused `alt` prop that's passed to `IfcImage` component. * chore: run yarn lint before every commit * add prettier * chore: format using prettier By formatting `.mdx` files with prettier, it will minimize mdx parsing error that being caught by the linter. This commit also fix: 1. Syntax error after being formatted 2. Non-syntax error that make the formatting unstable (previous to next formatting have different result when there is no change). TODO: 1. Create MDX authoring guidelines to prevent and fix syntax errors and formatting unstability. * chore: runt format linter before every commit * Provide common solutions for MDX parsing errors and volatile formatting * format with prettier * format staged files instead of --list-different Turns out `prettier --list-different` will always erroring out in Windows if the end of line character is converted from Linux style to Windows style by git when executing git checkout, pull, etc. So, I think it's better to automatically format staged files before every commit. * remove formatting first guideline in MDX.md * change prettier printWidth for .md and .mdx files. The whitespace `{" "}` JavaScript expression will be treated as text by Deepl. Sometimes, it will be relocated (e.g. in Japanese) from the end of line to the middle of line which is not desired. By setting the printWidth to Infinity, the text will not be wrapped to next line, so there is no need for the whitespace `{" "}` expression.
- Loading branch information
Showing
140 changed files
with
6,340 additions
and
4,927 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
yarn pretty-quick --staged && yarn lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Dependencies | ||
/node_modules | ||
|
||
# Production | ||
/build | ||
|
||
# Generated files | ||
i18n | ||
.docusaurus | ||
.cache-loader | ||
|
||
# Misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
deepl/deepl.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# MDX Common Errors | ||
|
||
The MDX compiler is not that smart. So, we need to make sure that we write MDX in a way that compiler can understand. | ||
|
||
Few things you have to keep in mind: | ||
|
||
1. `<a>` opening tag must be placed on the start of a line without any character before it except whitespaces. | ||
|
||
```jsx | ||
β | ||
|
||
Click this <a href="https://ifcjs.github.io/info">link{" "}</a> | ||
to IFC.js website. | ||
|
||
β | ||
|
||
Click this{" "} | ||
<a href="https://ifcjs.github.io/info">link </a> | ||
to IFC.js website. | ||
``` | ||
|
||
2. `</a>` closing tag must not be followed by Javascript expression (encapsulated by `{}` such as `{" "}`). | ||
|
||
```jsx | ||
β | ||
|
||
<a href="https://ifcjs.github.io/info">Link</a>{" "} | ||
to IFC.js website. | ||
|
||
β | ||
|
||
<a href="https://ifcjs.github.io/info">Link{" "}</a> | ||
to IFC.js website. | ||
``` | ||
|
||
3. JSX element is a Javascript expression. Therefore, if you want to pass a JSX element as a prop of another JSX component, you must wrap it with `{}`. | ||
|
||
```jsx | ||
β | ||
|
||
<IfcImage image=<img src="..." alt=".."></img>></IfcImage> | ||
|
||
β | ||
|
||
<IfcImage image={<img src="..." alt=".."></img>}></IfcImage> | ||
``` | ||
|
||
4. Unnecessary whitespaces at the beginning of a line. Try formatting the documents to solve this. Run: | ||
|
||
```bash | ||
yarn format | ||
``` | ||
|
||
The MDX formatter is also not that smart. Some characters that are not necessary but acceptable could make the formatting result volatile. | ||
|
||
Few things you have to keep in mind: | ||
|
||
1. Do not wrap a prop of JSX component or element with `{}` if it does not need to be a Javascript expression. Example: | ||
|
||
```jsx | ||
β | ||
|
||
<a href={"https://ifcjs.github.io/info"}>Link</a> | ||
|
||
β | ||
|
||
<a href="https://ifcjs.github.io/info">Link</a> | ||
``` | ||
|
||
After applying above solutions, format your MDX documents. Run: | ||
|
||
```bash | ||
yarn format | ||
``` | ||
|
||
Then check the stability. Run: | ||
|
||
```bash | ||
yarn lint:format | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module.exports = { | ||
presets: [require.resolve('@docusaurus/core/lib/babel/preset')], | ||
presets: [require.resolve("@docusaurus/core/lib/babel/preset")], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.