From 0cfdfd7f6a2352787a0ff0d13fa15721c42c62bc Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Thu, 17 Feb 2022 17:05:37 +0800 Subject: [PATCH] fix(`valid-types`): ensure `requires` checking works without `module:`; fixes #840 --- src/getDefaultTagStructureForMode.js | 4 ++++ src/rules/validTypes.js | 1 + test/rules/assertions/validTypes.js | 9 +++++++++ 3 files changed, 14 insertions(+) diff --git a/src/getDefaultTagStructureForMode.js b/src/getDefaultTagStructureForMode.js index a0c700a5c..f4cff97be 100644 --- a/src/getDefaultTagStructureForMode.js +++ b/src/getDefaultTagStructureForMode.js @@ -712,6 +712,10 @@ const getDefaultTagStructureForMode = (mode) => { [ 'requires', new Map([ // + [ + 'nameContents', 'namepath-referencing', + ], + [ 'nameRequired', true, ], diff --git a/src/rules/validTypes.js b/src/rules/validTypes.js index 22fcd8568..b3c77889c 100644 --- a/src/rules/validTypes.js +++ b/src/rules/validTypes.js @@ -102,6 +102,7 @@ export default iterateJsdoc(({ if (tagName) { // eslint-disable-next-line default-case switch (tagName) { + case 'requires': case 'module': { if (!namepath.startsWith('module:')) { handled = tryParsePathIgnoreError(`module:${namepath}`); diff --git a/test/rules/assertions/validTypes.js b/test/rules/assertions/validTypes.js index 292d090ca..072d4fef5 100644 --- a/test/rules/assertions/validTypes.js +++ b/test/rules/assertions/validTypes.js @@ -1610,5 +1610,14 @@ export default { ecmaVersion: 2_017, }, }, + { + code: ` + /** + * @module module:scenarios/scenarios + * @requires scenarios/effects + */ + `, + ignoreReadme: true, + }, ], };