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 authored and GitHub committed 2022-12-30 18:44:46 +02:00
1 parent 99add15fc3
commit d1b4b11ff6
67 files changed
+2611 -1735

No files matched your search

+69 -69
View File
@@ -49,10 +49,10 @@ You can create a cart with the following code snippet:
```jsx
medusa.carts.create()
.then(({ cart }) => {
localStorage.setItem('cart_id', cart.id);
//assuming you have a state variable to store the cart
setCart(cart);
});
localStorage.setItem("cart_id", cart.id)
// assuming you have a state variable to store the cart
setCart(cart)
})
```
</TabItem>
@@ -60,15 +60,15 @@ medusa.carts.create()
```jsx
fetch(`<SERVER_URL>/store/carts`, {
method: 'POST',
credentials: 'include',
method: "POST",
credentials: "include",
})
.then((response) => response.json())
.then(({ cart }) => {
localStorage.setItem('cart_id', cart.id);
//assuming you have a state variable to store the cart
localStorage.setItem("cart_id", cart.id)
// assuming you have a state variable to store the cart
setCart(cart)
});
})
```
</TabItem>
@@ -85,13 +85,13 @@ Otherwise, you can assign it a specific region during creation:
```jsx
medusa.carts.create({
region_id
region_id,
})
.then(({ cart }) => {
localStorage.setItem('cart_id', cart.id);
//assuming you have a state variable to store the cart
setCart(cart);
});
localStorage.setItem("cart_id", cart.id)
// assuming you have a state variable to store the cart
setCart(cart)
})
```
</TabItem>
@@ -99,21 +99,21 @@ medusa.carts.create({
```jsx
fetch(`<SERVER_URL>/store/carts`, {
method: 'POST',
credentials: 'include',
method: "POST",
credentials: "include",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json",
},
body: JSON.stringify({
region_id
})
region_id,
}),
})
.then((response) => response.json())
.then(({ cart }) => {
localStorage.setItem('cart_id', cart.id);
//assuming you have a state variable to store the cart
localStorage.setItem("cart_id", cart.id)
// assuming you have a state variable to store the cart
setCart(cart)
});
})
```
</TabItem>
@@ -139,11 +139,11 @@ You can retrieve the cart at any given point using its ID with the following cod
<TabItem value="client" label="Medusa JS Client" default>
```jsx
const id = localStorage.getItem('cart_id');
const id = localStorage.getItem("cart_id")
if (id) {
medusa.carts.retrieve(id)
.then(({ cart }) => setCart(cart));
.then(({ cart }) => setCart(cart))
}
```
@@ -151,14 +151,14 @@ if (id) {
<TabItem value="fetch" label="Fetch API">
```jsx
const id = localStorage.getItem('cart_id');
const id = localStorage.getItem("cart_id")
if (id) {
fetch(`<SERVER_URL>/store/carts/${id}`, {
credentials: 'include',
credentials: "include",
})
.then((response) => response.json())
.then(({ cart }) => setCart(cart));
.then(({ cart }) => setCart(cart))
}
```
@@ -188,9 +188,9 @@ You can use the following snippet to update any of the cart’s data:
```jsx
medusa.carts.update(cartId, {
region_id
region_id,
})
.then(({ cart }) => setCart(cart));
.then(({ cart }) => setCart(cart))
```
</TabItem>
@@ -198,17 +198,17 @@ medusa.carts.update(cartId, {
```jsx
fetch(`<SERVER_URL>/store/carts/${cartId}`, {
method: 'POST',
credentials: 'include',
method: "POST",
credentials: "include",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json",
},
body: JSON.stringify({
region_id
})
region_id,
}),
})
.then((response) => response.json())
.then(({ cart }) => setCart(cart));
.then(({ cart }) => setCart(cart))
```
</TabItem>
@@ -231,9 +231,9 @@ You can do that using the same update operation:
```jsx
medusa.carts.update(cartId, {
customer_id
customer_id,
})
.then(({ cart }) => setCart(cart));
.then(({ cart }) => setCart(cart))
```
</TabItem>
@@ -241,17 +241,17 @@ medusa.carts.update(cartId, {
```jsx
fetch(`<SERVER_URL>/store/carts/${cartId}`, {
method: 'POST',
credentials: 'include',
method: "POST",
credentials: "include",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json",
},
body: JSON.stringify({
customer_id
})
customer_id,
}),
})
.then((response) => response.json())
.then(({ cart }) => setCart(cart));
.then(({ cart }) => setCart(cart))
```
</TabItem>
@@ -270,9 +270,9 @@ You can do that using the same update operation:
```jsx
medusa.carts.update(cartId, {
email: 'user@example.com'
email: "user@example.com",
})
.then(({ cart }) => setCart(cart));
.then(({ cart }) => setCart(cart))
```
</TabItem>
@@ -280,17 +280,17 @@ medusa.carts.update(cartId, {
```jsx
fetch(`<SERVER_URL>/store/carts/${cartId}`, {
method: 'POST',
credentials: 'include',
method: "POST",
credentials: "include",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json",
},
body: JSON.stringify({
email: 'user@example.com'
})
email: "user@example.com",
}),
})
.then((response) => response.json())
.then(({ cart }) => setCart(cart));
.then(({ cart }) => setCart(cart))
```
</TabItem>
@@ -308,9 +308,9 @@ To create a line item of a product and add it to a cart, you can use the followi
```jsx
medusa.carts.lineItems.create(cartId, {
variant_id,
quantity: 1
quantity: 1,
})
.then(({ cart }) => setCart(cart));
.then(({ cart }) => setCart(cart))
```
</TabItem>
@@ -318,18 +318,18 @@ medusa.carts.lineItems.create(cartId, {
```jsx
fetch(`<SERVER_URL>/store/carts/${cartId}/line-items`, {
method: 'POST',
credentials: 'include',
method: "POST",
credentials: "include",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json",
},
body: JSON.stringify({
variant_id,
quantity: 1
})
quantity: 1,
}),
})
.then((response) => response.json())
.then(({ cart }) => setCart(cart));
.then(({ cart }) => setCart(cart))
```
</TabItem>
@@ -358,7 +358,7 @@ To update a line item's quantity in the cart, you can use the following code sni
```jsx
medusa.carts.lineItems.update(cartId, lineItemId, {
quantity: 3
quantity: 3,
})
.then(({ cart }) => setCart(cart))
```
@@ -368,17 +368,17 @@ medusa.carts.lineItems.update(cartId, lineItemId, {
```jsx
fetch(`<SERVER_URL>/store/carts/${cartId}/line-items/${lineItemId}`, {
method: 'POST',
credentials: 'include',
method: "POST",
credentials: "include",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json",
},
body: JSON.stringify({
quantity: 3
})
quantity: 3,
}),
})
.then((response) => response.json())
.then(({ cart }) => setCart(cart));
.then(({ cart }) => setCart(cart))
```
</TabItem>
@@ -407,11 +407,11 @@ medusa.carts.lineItems.delete(cartId, lineItemId)
```jsx
fetch(`<SERVER_URL>/store/carts/${cartId}/line-items/${lineItemId}`, {
method: 'DELETE',
credentials: 'include',
method: "DELETE",
credentials: "include",
})
.then((response) => response.json())
.then(({ cart }) => setCart(cart));
.then(({ cart }) => setCart(cart))
```
</TabItem>