chore(docs): added eslint to lint documentation code blocks (#2920)

* docs: added rule for code length

* chore: fixes based on vale errors

* changed to use eslint

* fixes using eslint

* added github action for documentation eslint

* changed allowed max-length

* fixed incorrect heading level

* removed comment
This commit is contained in:
Shahed Nasser
2022-12-30 18:44:46 +02:00
committed by GitHub
parent 99add15fc3
commit d1b4b11ff6
67 changed files with 2611 additions and 1735 deletions
+66 -5
View File
@@ -130,10 +130,10 @@ import TabItem from '@theme/TabItem';
<TabItem value="client" label="Medusa JS Client" default>
```jsx
medusa.admin.uploads.create(file) //file is an instance of File
medusa.admin.uploads.create(file) // file is an instance of File
.then(({ uploads }) => {
const key = uploads[0].key;
});
const key = uploads[0].key
})
```
</TabItem>
@@ -157,7 +157,10 @@ If you want to add a title to a code block with tabs, add the `codeTitle` prop t
For example:
```md
<Tabs groupId="request-type" wrapperClassName="code-tabs" codeTitle="/src/services/hello.ts">
<Tabs
groupId="request-type"
wrapperClassName="code-tabs"
codeTitle="/src/services/hello.ts">
```
### Add Title to Code Block without Tabs
@@ -242,7 +245,7 @@ npm install @medusajs/medusa-cli -g
Medusa uses Vale to lint documentation pages and perform checks on incoming PRs into the repository.
### Result of PR Checks
### Result of Vale PR Checks
You can check the result of running the "lint" action on your PR by clicking the Details link next to it. You can find there all errors that you need to fix.
@@ -293,6 +296,64 @@ If you use this in your PR, you must justify its usage.
---
## Linting with ESLint
Medusa uses Eslint to lint code blocks in the documentation and perform checks on incoming PRs into the repository.
### Result of ESLint PR Checks
You can check the result of running the "eslint" action on your PR by clicking the Details link next to it. You can find there all errors that you need to fix.
### Running ESLint locally
If you want to check your work locally, you can do that by:
1. Installing the dependencies in the root directory:
```bash
yarn install
```
2\. Run the lint command:
```bash
yarn lint:docs
```
You can also pass the `--fix` option to automatically fix errors.
### ESLint Exceptions
If some code blocks have errors that can't or shouldn't be fixed, you can add the following command before the code block:
~~~md
<!-- eslint-skip -->
```js
console.log("This block isn't linted")
```
```js
console.log("This block is linted")
```
~~~
You can also disable specific rules. For example:
~~~md
<!-- eslint-disable semi -->
```js
console.log("This block can use semicolons");
```
```js
console.log("This block can't use semi colons")
```
~~~
---
## Need Additional Help
If you need any additional help while contributing, you can join Medusa's [Discord server](https://discord.gg/medusajs) and ask Medusas core team as well as the community any questions.