Navigation Menu

Skip to content

Commit

Permalink
fix(require-jsdoc): handle MethodDefinition context without errin…
Browse files Browse the repository at this point in the history
…g when using `exemptEmptyFunctions` and `exemptEmptyConstructors`; fixes #613

Also impacts `check-params`, `require-params` when using `MethodDefinition` context.
  • Loading branch information
brettz9 committed Jul 20, 2020
1 parent eac8357 commit 08b5820
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -9904,6 +9904,12 @@ class Foo {
constructor() {}
}
// Options: [{"checkConstructors":false,"require":{"MethodDefinition":true}}]

class Base {
constructor() {
}
}
// Options: [{"contexts":["MethodDefinition"],"exemptEmptyConstructors":true}]
````


Expand Down
2 changes: 1 addition & 1 deletion src/jsdocUtils.js
Expand Up @@ -177,7 +177,7 @@ const getFunctionParameterNames = (functionNode : Object) : Array<T> => {
throw new Error('Unsupported function signature format.');
};

return functionNode.params.map((param) => {
return (functionNode.params || functionNode.value.params).map((param) => {
return getParamName(param);
});
};
Expand Down
12 changes: 12 additions & 0 deletions test/rules/assertions/requireJsdoc.js
Expand Up @@ -3936,5 +3936,17 @@ export default {
},
],
},
{
code: `
class Base {
constructor() {
}
}
`,
options: [{
contexts: ['MethodDefinition'],
exemptEmptyConstructors: true,
}],
},
],
};

0 comments on commit 08b5820

Please sign in to comment.