Skip to content

docs: list required JSDoc tags #1397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 29, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,61 @@ For more info checkout [jsdoc.app](https://jsdoc.app/about-getting-started.html)

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.

> We have a small set of JSDoc tags that all methods should have.

- Description
- `@see` - If there are other important methods
- `@param` - If the method has parameters
- `@example` - Example calls without and with parameters, including a sample result each
- `@deprecated` - If the method is deprecated, with additional information about replacements
- `@since` - The version this method was added (or is likely to be added)

<table>
<tr>
<th>Do</th>
<th>Dont</th>
</tr>
<tr>
<td>

```ts
/**
* This is a good JSDoc description for a method that generates foos.
*
* @see faker.helper.fake
*
* @param options The optional options to use.
* @param options.test The parameter to configure test. Defaults to `'bar'`.
*
* @example
* faker.bar.foo() // 'foo'
* faker.bar.foo({ test: 'oof' }) // 'of'
*
* @deprecated Use faker.cat.random() instead.
*/
function foo(options: { test: string } = {}): string {
// implementation
}
```

</td>
<td>

```ts
/**
* This is a bad JSDoc description.
*
* @return foo
*/
function foo(options: { test: string }) {
// implementation
}
```

</td>
</tr>
</table>

> We use eslint-plugin-jsdoc to test for basic styling and sorting of doc-tags.

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.
Expand Down