From 7019d287aa84e6919f16ca79bee5b415a4308548 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Mon, 14 Oct 2024 17:49:59 +0800 Subject: [PATCH] feat(`require-hyphen-before-param-description`): ensure template will be properly stringified; fixes #1326 Note that `match-name` will now have to take into account any optional brackets and default in `allowName` --- docs/rules/match-name.md | 2 +- package.json | 2 +- pnpm-lock.yaml | 10 ++++---- test/rules/assertions/matchName.js | 2 +- .../requireHyphenBeforeParamDescription.js | 23 +++++++++++++++++++ 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/docs/rules/match-name.md b/docs/rules/match-name.md index 8c223f7e0..48cd10446 100644 --- a/docs/rules/match-name.md +++ b/docs/rules/match-name.md @@ -251,6 +251,6 @@ class A { * @typedef {object} Test * @property {T} test */ -// "jsdoc/match-name": ["error"|"warn", {"match":[{"allowName":"/^[A-Z]{1}$/","message":"The name should be a single capital letter.","tags":["template"]}]}] +// "jsdoc/match-name": ["error"|"warn", {"match":[{"allowName":"/^\\[?[A-Z]{1}(=.*\\])$/","message":"The name should be a single capital letter.","tags":["template"]}]}] ```` diff --git a/package.json b/package.json index be0a963a3..c5b3e8528 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "url": "http://gajus.com" }, "dependencies": { - "@es-joy/jsdoccomment": "~0.48.0", + "@es-joy/jsdoccomment": "~0.49.0", "are-docs-informative": "^0.0.2", "comment-parser": "1.4.1", "debug": "^4.3.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ec572d128..e0f7cdd39 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: '@es-joy/jsdoccomment': - specifier: ~0.48.0 - version: 0.48.0 + specifier: ~0.49.0 + version: 0.49.0 are-docs-informative: specifier: ^0.0.2 version: 0.0.2 @@ -983,8 +983,8 @@ packages: resolution: {integrity: sha512-C3Axuq1xd/9VqFZpW4YAzOx5O9q/LP46uIQy/iNDpHG3fmPa6TBtvfglMCs3RBiBxAIi0Go97r8+jvTt55XMyQ==} engines: {node: '>=16'} - '@es-joy/jsdoccomment@0.48.0': - resolution: {integrity: sha512-G6QUWIcC+KvSwXNsJyDTHvqUdNoAVJPPgkc3+Uk4WBKqZvoXhlvazOgm9aL0HwihJLQf0l+tOE2UFzXBqCqgDw==} + '@es-joy/jsdoccomment@0.49.0': + resolution: {integrity: sha512-xjZTSFgECpb9Ohuk5yMX5RhUEbfeQcuOp8IF60e+wyzWEF0M5xeSgqsfLtvPEX8BIyOX9saZqzuGPmZ8oWc+5Q==} engines: {node: '>=16'} '@eslint-community/eslint-utils@4.4.0': @@ -6400,7 +6400,7 @@ snapshots: esquery: 1.6.0 jsdoc-type-pratt-parser: 4.0.0 - '@es-joy/jsdoccomment@0.48.0': + '@es-joy/jsdoccomment@0.49.0': dependencies: comment-parser: 1.4.1 esquery: 1.6.0 diff --git a/test/rules/assertions/matchName.js b/test/rules/assertions/matchName.js index a72f15cc2..eb51508ae 100644 --- a/test/rules/assertions/matchName.js +++ b/test/rules/assertions/matchName.js @@ -553,7 +553,7 @@ export default { `, options: [{ match: [{ - allowName: "/^[A-Z]{1}$/", + allowName: "/^\\[?[A-Z]{1}(=.*\\])$/", message: "The name should be a single capital letter.", tags: ["template"], }], diff --git a/test/rules/assertions/requireHyphenBeforeParamDescription.js b/test/rules/assertions/requireHyphenBeforeParamDescription.js index 9b2ab23cc..1748c3555 100644 --- a/test/rules/assertions/requireHyphenBeforeParamDescription.js +++ b/test/rules/assertions/requireHyphenBeforeParamDescription.js @@ -473,6 +473,29 @@ export default { function test(input) {} `, }, + { + code: ` + /** + * @template [O=unknown] + * @param {string} name The name of the thing. + */ + function test(name) {} + `, + errors: [ + { + line: 4, + message: 'There must be a hyphen before @param description.', + }, + ], + ignoreReadme: true, + output: ` + /** + * @template [O=unknown] + * @param {string} name - The name of the thing. + */ + function test(name) {} + `, + }, ], valid: [ {