Skip to content

Commit e5b608b

Browse files
authored
docs: list required JSDoc tags (#1397)
1 parent 2539e6a commit e5b608b

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

CONTRIBUTING.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,63 @@ For more info checkout [jsdoc.app](https://jsdoc.app/about-getting-started.html)
7878

7979
JSDoc will be read and automatically processed by `generate:api-docs` and therefore need to follow some project conventions. Other standards are in place because we think they increase the code quality.
8080

81+
> We have a small set of JSDoc tags that all methods should have.
82+
83+
- Description
84+
- `@param` - If the method has parameters
85+
- `@see` - If there are other important methods
86+
- `@example` - Example calls without and with parameters, including a sample result of each call
87+
- `@since` - The version this method was added (or is likely to be added)
88+
- `@deprecated` - If the method is deprecated, with additional information about replacements
89+
90+
<table>
91+
<tr>
92+
<th>Do</th>
93+
<th>Dont</th>
94+
</tr>
95+
<tr>
96+
<td>
97+
98+
```ts
99+
/**
100+
* This is a good JSDoc description for a method that generates foos.
101+
*
102+
* @param options The optional options to use.
103+
* @param options.test The parameter to configure test. Defaults to `'bar'`.
104+
*
105+
* @see faker.helper.fake
106+
*
107+
* @example
108+
* faker.bar.foo() // 'foo'
109+
* faker.bar.foo({ test: 'oof' }) // 'of'
110+
*
111+
* @since 7.5.0
112+
*
113+
* @deprecated Use faker.cat.random() instead.
114+
*/
115+
function foo(options: { test: string } = {}): string {
116+
// implementation
117+
}
118+
```
119+
120+
</td>
121+
<td>
122+
123+
```ts
124+
/**
125+
* This is a bad JSDoc description.
126+
*
127+
* @return foo
128+
*/
129+
function foo(options: { test: string }) {
130+
// implementation
131+
}
132+
```
133+
134+
</td>
135+
</tr>
136+
</table>
137+
81138
> We use eslint-plugin-jsdoc to test for basic styling and sorting of doc-tags.
82139
83140
This is in place so all JSDoc tags will get sorted automatically, so you don't have to bother with it. This also means that most rules in this section can get auto fixed by the eslint formatter.

0 commit comments

Comments
 (0)