Skip to content

Commit da65fe9

Browse files
committed
docs(require-param): method example
1 parent 947f642 commit da65fe9

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

docs/rules/require-param.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,22 @@ function foo(a, b, c) {}
11431143
export function myPublicFunction(foo: number, bar: number, baz: number) {}
11441144
// "jsdoc/require-param": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[tag=\"param\"])","context":"FunctionDeclaration"}]}]
11451145
// Message: Missing JSDoc @param "baz" declaration.
1146+
1147+
/**
1148+
* [A description]
1149+
*/
1150+
class A {
1151+
/**
1152+
* openConfirmModal
1153+
* @memberof CreateEditTestWizardComponent
1154+
*/
1155+
public openConfirmModal(btnState: string) {
1156+
this.modalBtnState = btnState;
1157+
this.openModal();
1158+
}
1159+
}
1160+
// "jsdoc/require-param": ["error"|"warn", {"contexts":["MethodDefinition"]}]
1161+
// Message: Missing JSDoc @param "btnState" declaration.
11461162
````
11471163

11481164

test/rules/assertions/requireParam.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2451,6 +2451,52 @@ export default {
24512451
`,
24522452
parser: require.resolve('@typescript-eslint/parser'),
24532453
},
2454+
{
2455+
code: `
2456+
/**
2457+
* [A description]
2458+
*/
2459+
class A {
2460+
/**
2461+
* openConfirmModal
2462+
* @memberof CreateEditTestWizardComponent
2463+
*/
2464+
public openConfirmModal(btnState: string) {
2465+
this.modalBtnState = btnState;
2466+
this.openModal();
2467+
}
2468+
}
2469+
`,
2470+
errors: [
2471+
{
2472+
message: 'Missing JSDoc @param "btnState" declaration.',
2473+
},
2474+
],
2475+
options: [
2476+
{
2477+
contexts: [
2478+
'MethodDefinition',
2479+
],
2480+
},
2481+
],
2482+
output: `
2483+
/**
2484+
* [A description]
2485+
*/
2486+
class A {
2487+
/**
2488+
* openConfirmModal
2489+
* @param btnState
2490+
* @memberof CreateEditTestWizardComponent
2491+
*/
2492+
public openConfirmModal(btnState: string) {
2493+
this.modalBtnState = btnState;
2494+
this.openModal();
2495+
}
2496+
}
2497+
`,
2498+
parser: require.resolve('@typescript-eslint/parser'),
2499+
},
24542500
],
24552501
valid: [
24562502
{

0 commit comments

Comments
 (0)