From 89b81ce6a21b88e66cb686a2aa40f2a86834029d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Mon, 15 May 2023 16:02:34 +0200 Subject: [PATCH] fix: check-tag-names crash on module comment --- docs/rules/check-tag-names.md | 6 ++++++ src/rules/checkTagNames.js | 4 ++++ test/rules/assertions/checkTagNames.js | 13 +++++++++++++ 3 files changed, 23 insertions(+) diff --git a/docs/rules/check-tag-names.md b/docs/rules/check-tag-names.md index a38e25a26..d37eb6ba0 100644 --- a/docs/rules/check-tag-names.md +++ b/docs/rules/check-tag-names.md @@ -1122,5 +1122,11 @@ interface WebTwain { * @satisfies */ // Settings: {"jsdoc":{"mode":"typescript"}} + +/** + * @module + * A comment related to the module + */ +// "jsdoc/check-tag-names": ["error"|"warn", {"typed":true}] ```` diff --git a/src/rules/checkTagNames.js b/src/rules/checkTagNames.js index 8aa07bc20..d7adc39a0 100644 --- a/src/rules/checkTagNames.js +++ b/src/rules/checkTagNames.js @@ -143,6 +143,10 @@ export default iterateJsdoc(({ return false; } + if (node === null) { + return false; + } + if (context.getFilename().endsWith('.d.ts') && [ 'Program', null, undefined, ].includes(node?.parent?.type)) { diff --git a/test/rules/assertions/checkTagNames.js b/test/rules/assertions/checkTagNames.js index 955f21cf7..b7d42dbf7 100644 --- a/test/rules/assertions/checkTagNames.js +++ b/test/rules/assertions/checkTagNames.js @@ -1455,5 +1455,18 @@ export default { }, }, }, + { + code: ` + /** + * @module + * A comment related to the module + */ + `, + options: [ + { + typed: true, + }, + ], + }, ], };