diff --git a/README.md b/README.md index ebfe484e0..4380fcad2 100644 --- a/README.md +++ b/README.md @@ -9904,6 +9904,12 @@ class Foo { constructor() {} } // Options: [{"checkConstructors":false,"require":{"MethodDefinition":true}}] + +class Base { + constructor() { + } +} +// Options: [{"contexts":["MethodDefinition"],"exemptEmptyConstructors":true}] ```` diff --git a/src/jsdocUtils.js b/src/jsdocUtils.js index 0cac1357d..2ba7c95a2 100644 --- a/src/jsdocUtils.js +++ b/src/jsdocUtils.js @@ -177,7 +177,7 @@ const getFunctionParameterNames = (functionNode : Object) : Array => { throw new Error('Unsupported function signature format.'); }; - return functionNode.params.map((param) => { + return (functionNode.params || functionNode.value.params).map((param) => { return getParamName(param); }); }; diff --git a/test/rules/assertions/requireJsdoc.js b/test/rules/assertions/requireJsdoc.js index 51a066fd1..70276498f 100644 --- a/test/rules/assertions/requireJsdoc.js +++ b/test/rules/assertions/requireJsdoc.js @@ -3936,5 +3936,17 @@ export default { }, ], }, + { + code: ` + class Base { + constructor() { + } + } + `, + options: [{ + contexts: ['MethodDefinition'], + exemptEmptyConstructors: true, + }], + }, ], };