Skip to content

Commit

Permalink
docs(require-param): method example
Browse files Browse the repository at this point in the history
  • Loading branch information
brettz9 committed Nov 10, 2023
1 parent 947f642 commit da65fe9
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/rules/require-param.md
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,22 @@ function foo(a, b, c) {}
export function myPublicFunction(foo: number, bar: number, baz: number) {}
// "jsdoc/require-param": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[tag=\"param\"])","context":"FunctionDeclaration"}]}]
// Message: Missing JSDoc @param "baz" declaration.

/**
* [A description]
*/
class A {
/**
* openConfirmModal
* @memberof CreateEditTestWizardComponent
*/
public openConfirmModal(btnState: string) {
this.modalBtnState = btnState;
this.openModal();
}
}
// "jsdoc/require-param": ["error"|"warn", {"contexts":["MethodDefinition"]}]
// Message: Missing JSDoc @param "btnState" declaration.
````


Expand Down
46 changes: 46 additions & 0 deletions test/rules/assertions/requireParam.js
Original file line number Diff line number Diff line change
Expand Up @@ -2451,6 +2451,52 @@ export default {
`,
parser: require.resolve('@typescript-eslint/parser'),
},
{
code: `
/**
* [A description]
*/
class A {
/**
* openConfirmModal
* @memberof CreateEditTestWizardComponent
*/
public openConfirmModal(btnState: string) {
this.modalBtnState = btnState;
this.openModal();
}
}
`,
errors: [
{
message: 'Missing JSDoc @param "btnState" declaration.',
},
],
options: [
{
contexts: [
'MethodDefinition',
],
},
],
output: `
/**
* [A description]
*/
class A {
/**
* openConfirmModal
* @param btnState
* @memberof CreateEditTestWizardComponent
*/
public openConfirmModal(btnState: string) {
this.modalBtnState = btnState;
this.openModal();
}
}
`,
parser: require.resolve('@typescript-eslint/parser'),
},
],
valid: [
{
Expand Down

0 comments on commit da65fe9

Please sign in to comment.