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

@@ -35,28 +35,29 @@ If you use a `.env` file to load environment variables on your server, you need
You can add the following code snippet at the top of the file which uses the [dotenv](https://www.npmjs.com/package/dotenv) package to load the environment variables based on the current Node environment:
```jsx
const dotenv = require('dotenv')
const dotenv = require("dotenv")
let ENV_FILE_NAME = '';
let ENV_FILE_NAME = ""
switch (process.env.NODE_ENV) {
case 'production':
ENV_FILE_NAME = '.env.production';
break;
case 'staging':
ENV_FILE_NAME = '.env.staging';
break;
case 'test':
ENV_FILE_NAME = '.env.test';
break;
case 'development':
case "production":
ENV_FILE_NAME = ".env.production"
break
case "staging":
ENV_FILE_NAME = ".env.staging"
break
case "test":
ENV_FILE_NAME = ".env.test"
break
case "development":
default:
ENV_FILE_NAME = '.env';
break;
ENV_FILE_NAME = ".env"
break
}
try {
dotenv.config({ path: process.cwd() + '/' + ENV_FILE_NAME });
dotenv.config({ path: process.cwd() + "/" + ENV_FILE_NAME })
} catch (e) {
// handle error
}
```
@@ -31,19 +31,19 @@ Instead of using `customerService.retrieveByEmail`, you should now use the metho
The `customerService.retrieveRegisteredByEmail` method allows you to retrieve a registered customer by email:
```ts
customerService.retrieveRegisteredByEmail("example@gmail.com");
customerService.retrieveRegisteredByEmail("example@gmail.com")
```
On the other hand, the `retrieveUnregisteredByEmail` method allows to retrieve guest customers by email:
```jsx
customerService.retrieveUnregisteredByEmail("example@gmail.com");
customerService.retrieveUnregisteredByEmail("example@gmail.com")
```
To retrieve a customer by email regardless of whether they are registered or not, you can use the `customerService.list` method instead:
```ts
customerService.list({
email: "example@gmail.com"
email: "example@gmail.com",
})
```
@@ -56,13 +56,13 @@ In your loader file that creates a cron job, replace the use of `eventBus` to `j
```ts
const myJob = async (container, options) => {
const jobSchedulerService = container.resolve("jobSchedulerService");
const jobSchedulerService = container.resolve("jobSchedulerService")
jobSchedulerService.create("my-job", {}, "0 0 * * *", async () => {
//...
});
// ...
})
}
export default myJob;
export default myJob
```
You can learn more in the [How to Create a Scheduled Job](../scheduled-jobs/create.md) documentation.
@@ -73,15 +73,26 @@ This version of Medusa introduces a change in how payment providers are implemen
Although this change is currently backwards compatible, it is recommended to change the signature of these methods to the following:
<!-- eslint-disable max-len -->
```ts
import { PaymentContext, PaymentSessionResponse } from '@medusajs/medusa'
import { PaymentContext, PaymentSessionResponse } from "@medusajs/medusa"
// ...
async createPayment(context: PaymentContext): Promise<PaymentSessionResponse> {
//...
}
class MyPaymentService extends AbstractPaymentService<TransactionBaseService> {
// ...
async createPayment(
context: PaymentContext
): Promise<PaymentSessionResponse> {
// ...
}
async updatePayment(paymentSessionData: PaymentSessionData, context: PaymentContext): Promise<PaymentSessionResponse> {
//...
async updatePayment(
paymentSessionData: PaymentSessionData,
context: PaymentContext
): Promise<PaymentSessionResponse> {
// ...
}
}
```