Description
Our coding guidelines for JSDocs state that a faker function that is able throw should that that in their JSDocs.
|
> If a function can throw an error (FakerError) you have to include the `@throws` tag with an explanation when an error could be thrown |
While reviewing #3857 I noticed that faker.helpers.weightedArrayElement does not have any throw comments, while clearly having possible errors being thrown during runtime:
|
if (array.length === 0) { |
|
throw new FakerError( |
|
'weightedArrayElement expects an array with at least one element' |
|
); |
|
} |
|
|
|
if (array.some((elt) => elt.weight <= 0)) { |
|
throw new FakerError( |
|
'weightedArrayElement expects an array of { weight, value } objects where weight is a positive number' |
|
); |
|
} |
Task
Add JSDocs stating that the function can throw as described in our guidelines.
Description
Our coding guidelines for JSDocs state that a faker function that is able throw should that that in their JSDocs.
faker/CONTRIBUTING.md
Line 362 in bbd1693
While reviewing #3857 I noticed that
faker.helpers.weightedArrayElementdoes not have anythrowcomments, while clearly having possible errors being thrown during runtime:faker/src/modules/helpers/module.ts
Lines 984 to 994 in bbd1693
Task
Add JSDocs stating that the function can throw as described in our guidelines.