From 93a94158585802b1ef92bb703b06599cf19c507b Mon Sep 17 00:00:00 2001 From: Will Harney Date: Thu, 23 May 2024 12:33:04 -0400 Subject: [PATCH] fix(`require-yields`): avoid error when `ExportNamedDeclaration` has no `declaration` prop --- src/iterateJsdoc.js | 2 +- test/rules/assertions/requireYields.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/iterateJsdoc.js b/src/iterateJsdoc.js index ff9a2761c..9eeddf9b0 100644 --- a/src/iterateJsdoc.js +++ b/src/iterateJsdoc.js @@ -1353,7 +1353,7 @@ const getUtils = ( * @type {import('estree').ExportNamedDeclaration| * import('estree').ExportDefaultDeclaration} */ (node).declaration - ).generator, + )?.generator, ); }; diff --git a/test/rules/assertions/requireYields.js b/test/rules/assertions/requireYields.js index 5e5721837..0d915397f 100644 --- a/test/rules/assertions/requireYields.js +++ b/test/rules/assertions/requireYields.js @@ -1884,5 +1884,18 @@ export default { } `, }, + { + code: ` + /** + * + */ + export { foo } from "bar" + `, + options: [ + { + contexts: ['ExportNamedDeclaration'] + } + ] + } ], };