|
1
|
# Vale and Lint Rules |
|
2
|
|
|
3
|
Rules enforced by Vale (`www/vale/`) and ESLint (`lint:content`) that all documentation must pass. |
|
4
|
|
|
5
|
## First-Person Prohibition |
|
6
|
|
|
7
|
**Rule:** Never use first-person plural. |
|
8
|
|
|
9
|
``` |
|
10
|
❌ We recommend using workflows for all mutations. |
|
11
|
❌ Let's create a workflow. |
|
12
|
❌ Our platform supports... |
|
13
|
❌ Us, we've, we're |
|
14
|
|
|
15
|
✅ Use workflows for all mutations. |
|
16
|
✅ Create a workflow. |
|
17
|
✅ The platform supports... |
|
18
|
✅ You can configure... |
|
19
|
``` |
|
20
|
|
|
21
|
Exceptions: `US` (United States) is allowed. |
|
22
|
|
|
23
|
## Passive Voice |
|
24
|
|
|
25
|
Vale warns on passive voice. Rewrite as active. Pay special attention to "can be + past participle" constructions — rewrite as "you can + verb": |
|
26
|
|
|
27
|
``` |
|
28
|
❌ The workflow is created by calling createWorkflow. |
|
29
|
❌ Products are fetched from the database. |
|
30
|
❌ The configuration has been updated. |
|
31
|
❌ Custom domains can be configured in the settings. |
|
32
|
|
|
33
|
✅ Call createWorkflow to create a workflow. |
|
34
|
✅ The service fetches products from the database. |
|
35
|
✅ Update the configuration. |
|
36
|
✅ You can configure custom domains in the settings. |
|
37
|
``` |
|
38
|
|
|
39
|
## Backend vs API Terminology |
|
40
|
|
|
41
|
**Rule:** Use "backend" when referring to the Medusa server/application. Never use "API" as a synonym for the Medusa backend. |
|
42
|
|
|
43
|
``` |
|
44
|
❌ Serve your Medusa API. |
|
45
|
❌ Connect the storefront to the Medusa API. |
|
46
|
❌ The Medusa API handles the requests. |
|
47
|
|
|
48
|
✅ Serve your Medusa backend. |
|
49
|
✅ Connect the storefront to the Medusa backend. |
|
50
|
✅ The Medusa backend handles the requests. |
|
51
|
``` |
|
52
|
|
|
53
|
Note: "API" is still correct when referring to specific API routes or endpoints (for example, "call the Products API", "the Admin API"). |
|
54
|
|
|
55
|
## Medusa Cloud Naming |
|
56
|
|
|
57
|
**Rule:** Never write "Medusa Cloud" — use the shortened form depending on context. |
|
58
|
|
|
59
|
- When referring to the product/platform as a noun, use **"Medusa"** |
|
60
|
- When referring to the platform as a location or service (e.g., deploying to it), use **"Cloud"** |
|
61
|
|
|
62
|
``` |
|
63
|
❌ Medusa Cloud allows you to deploy your application. |
|
64
|
✅ Medusa allows you to deploy your application. |
|
65
|
|
|
66
|
❌ Deploy your project to Medusa Cloud. |
|
67
|
✅ Deploy your project to Cloud. |
|
68
|
|
|
69
|
❌ The Medusa Cloud dashboard shows your deployments. |
|
70
|
✅ The Cloud dashboard shows your deployments. |
|
71
|
``` |
|
72
|
|
|
73
|
## Latin Abbreviations |
|
74
|
|
|
75
|
**Rule:** Never use `e.g.,` — write `for example` instead. |
|
76
|
|
|
77
|
``` |
|
78
|
❌ Use a workflow step, e.g., to call an external API. |
|
79
|
✅ Use a workflow step, for example, to call an external API. |
|
80
|
``` |
|
81
|
|
|
82
|
## Em Dashes |
|
83
|
|
|
84
|
**Rule:** Never use em dashes (`—`). Rewrite the sentence to avoid them. |
|
85
|
|
|
86
|
``` |
|
87
|
❌ The workflow runs the steps — in order — and compensates on failure. |
|
88
|
✅ The workflow runs the steps in order and compensates on failure. |
|
89
|
|
|
90
|
❌ Use createStep — not direct service calls — for mutations. |
|
91
|
✅ Use createStep, not direct service calls, for mutations. |
|
92
|
``` |
|
93
|
|
|
94
|
## Problematic Words |
|
95
|
|
|
96
|
Vale flags these — avoid them: |
|
97
|
|
|
98
|
| Avoid | Use instead | |
|
99
|
|---|---| |
|
100
|
| simply | (remove it) | |
|
101
|
| just | (remove it) | |
|
102
|
| easy | (remove it) | |
|
103
|
| straightforward | (remove it) | |
|
104
|
| obviously | (remove it) | |
|
105
|
| basically | (remove it) | |
|
106
|
|
|
107
|
## Code Line Length |
|
108
|
|
|
109
|
**Rule:** Code lines must be ≤ 64 characters (enforced by `lint:content`). |
|
110
|
|
|
111
|
This applies to code blocks inside MDX files. Break long lines: |
|
112
|
|
|
113
|
```ts |
|
114
|
// ❌ Too long |
|
115
|
import { createWorkflow, WorkflowResponse, createStep, StepResponse } from "@medusajs/framework/workflows-sdk" |
|
116
|
|
|
117
|
// ✅ Break imports |
|
118
|
import { |
|
119
|
createWorkflow, |
|
120
|
WorkflowResponse, |
|
121
|
createStep, |
|
122
|
StepResponse, |
|
123
|
} from "@medusajs/framework/workflows-sdk" |
|
124
|
``` |
|
125
|
|
|
126
|
## TypeScript Preference |
|
127
|
|
|
128
|
Vale warns if you use `` ```tsx `` for TypeScript files. Use `` ```ts `` instead: |
|
129
|
|
|
130
|
``` |
|
131
|
❌ ```tsx |
|
132
|
✅ ```ts |
|
133
|
``` |
|
134
|
|
|
135
|
Use `` ```tsx `` only for React component files that contain JSX. |
|
136
|
|
|
137
|
## URL Format |
|
138
|
|
|
139
|
Never use bare URLs in prose text — always use the markdown link format: |
|
140
|
|
|
141
|
``` |
|
142
|
❌ Visit https://docs.medusajs.com for more information. |
|
143
|
✅ Visit the [Medusa documentation](https://docs.medusajs.com) for more information. |
|
144
|
``` |
|
145
|
|
|
146
|
## Sentence Length |
|
147
|
|
|
148
|
Keep sentences concise. Vale suggests sentences under ~30 words. Split complex sentences: |
|
149
|
|
|
150
|
``` |
|
151
|
❌ The Product Module is a standalone package that provides product management |
|
152
|
features and integrates with the Cart Module to allow adding products to carts, |
|
153
|
which then connects to the Order Module for order management. |
|
154
|
|
|
155
|
✅ The Product Module is a standalone package that provides product management |
|
156
|
features. It integrates with the Cart Module to allow adding products to carts. |
|
157
|
``` |
|
158
|
|
|
159
|
## Running Validation Mentally |
|
160
|
|
|
161
|
Before writing prose, check: |
|
162
|
- [ ] Any "we", "us", "let's", "our" → replace with "you" or imperative |
|
163
|
- [ ] Any passive voice constructions (including "can be configured", "is created", etc.) → rewrite active ("you can configure", "call X to create") |
|
164
|
- [ ] Any "simply", "just", "easy", etc. → remove |
|
165
|
- [ ] Code lines over 64 characters → break them |
|
166
|
- [ ] Bare URLs → wrap in `[label](url)` |
|
167
|
- [ ] `tsx` language tag for non-JSX TypeScript → change to `ts` |
|
168
|
- [ ] "Medusa API" used to mean the backend → replace with "Medusa backend" |
|
169
|
- [ ] "Medusa Cloud" anywhere → replace with "Medusa" (noun form) or "Cloud" (location/service) |
|
170
|
- [ ] `e.g.,` anywhere → replace with `for example` |
|
171
|
- [ ] Em dashes (`—`) anywhere → rewrite sentence to remove them |