From da65fe99101430eee55765067757d4a8c00e822b Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Mon, 30 Oct 2023 06:59:56 -0700 Subject: [PATCH] docs(`require-param`): method example --- docs/rules/require-param.md | 16 ++++++++++ test/rules/assertions/requireParam.js | 46 +++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/docs/rules/require-param.md b/docs/rules/require-param.md index eb3f75b49..eeb88e5d8 100644 --- a/docs/rules/require-param.md +++ b/docs/rules/require-param.md @@ -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. ```` diff --git a/test/rules/assertions/requireParam.js b/test/rules/assertions/requireParam.js index 402ac73d2..ee72c5644 100644 --- a/test/rules/assertions/requireParam.js +++ b/test/rules/assertions/requireParam.js @@ -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: [ {