diff --git a/src/jsdocUtils.js b/src/jsdocUtils.js index e31c2e6f7..179f77122 100644 --- a/src/jsdocUtils.js +++ b/src/jsdocUtils.js @@ -1298,11 +1298,11 @@ const isConstructor = (node) => { }; const isGetter = (node) => { - return node && node.parent.kind === 'get'; + return node && node.parent?.kind === 'get'; }; const isSetter = (node) => { - return node && node.parent.kind === 'set'; + return node && node.parent?.kind === 'set'; }; const hasAccessorPair = (node) => { diff --git a/test/rules/assertions/requireReturns.js b/test/rules/assertions/requireReturns.js index 665185ab5..3e0dfb35d 100644 --- a/test/rules/assertions/requireReturns.js +++ b/test/rules/assertions/requireReturns.js @@ -2472,5 +2472,26 @@ export default { ecmaVersion: 8, }, }, + { + code: ` + /** Enumerates possible genders for a product's target demographic. */ + enum Gender { + Unisex, + Mens, + Women + } + + export default Gender; + `, + ignoreReadme: true, + options: [ + { + contexts: [ + ':not(:matches(VariableDeclarator))', + ], + }, + ], + parser: require.resolve('@typescript-eslint/parser'), + }, ], };