Skip to content

Commit 07a9fe3

Browse files
committedJul 29, 2022
fix: avoid erring out with missing function and any context
1 parent 0c0e8ee commit 07a9fe3

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed
 

‎src/jsdocUtils.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,11 @@ const getFunctionParameterNames = (
275275
throw new Error(`Unsupported function signature format: \`${param.type}\`.`);
276276
};
277277

278-
return (functionNode.params || functionNode.value.params).map((param) => {
278+
if (!functionNode) {
279+
return [];
280+
}
281+
282+
return (functionNode.params || functionNode.value?.params || []).map((param) => {
279283
return getParamName(param);
280284
});
281285
};

‎test/rules/assertions/requireParam.js

+32
Original file line numberDiff line numberDiff line change
@@ -3390,5 +3390,37 @@ export default {
33903390
],
33913391
parser: require.resolve('@typescript-eslint/parser'),
33923392
},
3393+
{
3394+
code: `
3395+
/**
3396+
* Test
3397+
*/
3398+
`,
3399+
ignoreReadme: true,
3400+
options: [
3401+
{
3402+
contexts: [
3403+
'any',
3404+
],
3405+
},
3406+
],
3407+
},
3408+
{
3409+
code: `
3410+
/**
3411+
* Helper function to warp to a custom stage/level.
3412+
*/
3413+
export function setCustomStage(): void {}
3414+
`,
3415+
ignoreReadme: true,
3416+
options: [
3417+
{
3418+
contexts: [
3419+
'any',
3420+
],
3421+
},
3422+
],
3423+
parser: require.resolve('@typescript-eslint/parser'),
3424+
},
33933425
],
33943426
};

0 commit comments

Comments
 (0)
Please sign in to comment.