Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 authored Jul 1, 2022
2 parents 56c5cb0 + 3519b34 commit b19b327
Show file tree
Hide file tree
Showing 10 changed files with 447 additions and 250 deletions.
129 changes: 129 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,135 @@ get cat() {
}
```

## JSDocs

JSDoc are comments above any code structure (variable, function, class, etc.) that begin with `/**` and end with `*/`. Multiline comments start (if not being the start or end line) with a `*`.
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 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.

> JSDocs should always be multiline
While single line JSDoc are technically valid, we decided to follow this rule since it makes changes in the git diff much more clear and easier to understand.

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

```ts
/**
* This is a good JSDoc description.
*/
function foo() {
// implementation
}
```

</td>
<td>

```ts
/** This is a bad JSDoc description. */
function foo() {
// implementation
}
```

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

> Everything that can be accessed directly by a user should have JSDoc.
This rule is aimed to target anything that is exported from the faker library. This includes types, interfaces, functions, classes and variables. So if you introduce anything new that is not internal, write JSDoc for it.

> If a `@param` has a default value, it needs to be mentioned at the end of the sentence.
```ts
/**
* This is a good JSDoc description.
*
* @param bar this is a parameter description. Defaults to `0`.
*/
function foo(bar: number = 0) {
// implementation
}
```

> If a function can throw an error (FakerError) you have to include the `@throws` tag with an explanation when an error could be thrown
```ts
/**
* This is a good JSDoc description.
*
* @param bar this is a parameter description. Defaults to `0`.
*
* @throws If bar is negative.
*/
function foo(bar: number = 0) {
// implementation
}
```

> Sentences should always end with a period.
This rule ensures minimal grammatical correctness in the comments and ensures that all comments look the same.

> Different tags have to be separated by an empty line.
This rule improves the comments readability by grouping equivalent tags and making them more distinguishable from others.

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

```ts
/**
* This is a bad JSDoc block, because it has no linebreaks between sections.
* @param bar The first argument.
* @param baz The second argument.
* @example foo(1, 1) // [1, 1]
* @example foo(13, 56) // [13, 56]
*/
function foo(bar: number, baz: number): [number, number] {
// implementation
}
```

</td>
<td>

```ts
/**
* This is a good JSDoc block, because it follows the Faker preferences.
*
* @param bar The first argument.
* @param baz The second argument.
*
* @example foo(1, 1) // [1, 1]
* @example foo(13, 56) // [13, 56]
*/
function foo(bar: number, baz: number): [number, number] {
// implementation
}
```

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

## Developing the docs

Before running the docs, build the Faker dist, it's used inside of certain routes.
Expand Down
11 changes: 11 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from 'cypress';

export default defineConfig({
video: false,
e2e: {
chromeWebSecurity: false,
baseUrl: 'http://localhost:5000',
supportFile: false,
fixturesFolder: false,
},
});
12 changes: 0 additions & 12 deletions cypress.json

This file was deleted.

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,21 @@
"@types/react": "~18.0.14",
"@types/sanitize-html": "~2.6.2",
"@types/validator": "~13.7.3",
"@typescript-eslint/eslint-plugin": "~5.29.0",
"@typescript-eslint/parser": "~5.29.0",
"@vitest/ui": "~0.15.1",
"@typescript-eslint/eslint-plugin": "~5.30.0",
"@typescript-eslint/parser": "~5.30.0",
"@vitest/ui": "~0.16.0",
"c8": "~7.11.3",
"conventional-changelog-cli": "~2.2.2",
"cypress": "~10.2.0",
"esbuild": "~0.14.47",
"cypress": "~10.3.0",
"esbuild": "~0.14.48",
"eslint": "~8.18.0",
"eslint-config-prettier": "~8.5.0",
"eslint-define-config": "~1.5.1",
"eslint-gitignore": "~0.1.0",
"eslint-plugin-jsdoc": "~39.3.3",
"eslint-plugin-prettier": "~4.0.0",
"eslint-plugin-prettier": "~4.2.1",
"glob": "~8.0.3",
"lint-staged": "~13.0.2",
"lint-staged": "~13.0.3",
"mime-db": "~1.52.0",
"npm-run-all": "~4.1.5",
"picocolors": "~1.0.0",
Expand All @@ -126,16 +126,16 @@
"sanitize-html": "~2.7.0",
"simple-git-hooks": "~2.8.0",
"standard-version": "~9.5.0",
"tsx": "~3.5.0",
"typedoc": "~0.22.17",
"typedoc-plugin-missing-exports": "~0.22.6",
"tsx": "~3.6.0",
"typedoc": "~0.23.2",
"typedoc-plugin-missing-exports": "~0.23.0",
"typescript": "~4.7.4",
"validator": "~13.7.0",
"vite": "~2.9.12",
"vite": "~2.9.13",
"vitepress": "~0.22.4",
"vitest": "~0.15.1"
"vitest": "~0.16.0"
},
"packageManager": "pnpm@7.3.0",
"packageManager": "pnpm@7.4.1",
"engines": {
"node": ">=14.0.0",
"npm": ">=6.0.0"
Expand Down
Loading

0 comments on commit b19b327

Please sign in to comment.