Skip to content

Commit

Permalink
fix: avoid erring out with missing function and any context
Browse files Browse the repository at this point in the history
  • Loading branch information
brettz9 committed Jul 29, 2022
1 parent 0c0e8ee commit 07a9fe3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/jsdocUtils.js
Expand Up @@ -275,7 +275,11 @@ const getFunctionParameterNames = (
throw new Error(`Unsupported function signature format: \`${param.type}\`.`);
};

return (functionNode.params || functionNode.value.params).map((param) => {
if (!functionNode) {
return [];
}

return (functionNode.params || functionNode.value?.params || []).map((param) => {
return getParamName(param);
});
};
Expand Down
32 changes: 32 additions & 0 deletions test/rules/assertions/requireParam.js
Expand Up @@ -3390,5 +3390,37 @@ export default {
],
parser: require.resolve('@typescript-eslint/parser'),
},
{
code: `
/**
* Test
*/
`,
ignoreReadme: true,
options: [
{
contexts: [
'any',
],
},
],
},
{
code: `
/**
* Helper function to warp to a custom stage/level.
*/
export function setCustomStage(): void {}
`,
ignoreReadme: true,
options: [
{
contexts: [
'any',
],
},
],
parser: require.resolve('@typescript-eslint/parser'),
},
],
};

0 comments on commit 07a9fe3

Please sign in to comment.