From 4afc8e6fa84ae6f5850402237afd2ce25a2fb7cb Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Mon, 26 Jun 2023 07:18:24 +0800 Subject: [PATCH] test: demo checking for empty name --- docs/rules/match-name.md | 6 ++++++ test/rules/assertions/matchName.js | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/docs/rules/match-name.md b/docs/rules/match-name.md index c5fe1abce..fd25834f5 100644 --- a/docs/rules/match-name.md +++ b/docs/rules/match-name.md @@ -178,6 +178,12 @@ function quux () {} */ // "jsdoc/match-name": ["error"|"warn", {"match":[{"disallowName":"/^opt_/i","replacement":""}]}] // Message: Only allowing names not matching `/^opt_/i` but found "opt_a". + +/** + * @template + */ +// "jsdoc/match-name": ["error"|"warn", {"match":[{"disallowName":"/^$/","tags":["template"]}]}] +// Message: Only allowing names not matching `/^$/u` but found "". ```` diff --git a/test/rules/assertions/matchName.js b/test/rules/assertions/matchName.js index 8c933da70..9cc7eec58 100644 --- a/test/rules/assertions/matchName.js +++ b/test/rules/assertions/matchName.js @@ -357,6 +357,31 @@ export default { */ `, }, + { + code: ` + /** + * @template + */ + `, + errors: [ + { + line: 3, + message: 'Only allowing names not matching `/^$/u` but found "".', + }, + ], + options: [ + { + match: [ + { + disallowName: '/^$/', + tags: [ + 'template', + ], + }, + ], + }, + ], + }, ], valid: [ {