Skip to content

Commit

Permalink
feat(require-hyphen-before-param-description): ensure template will…
Browse files Browse the repository at this point in the history
… be properly stringified; fixes gajus#1326

Note that `match-name` will now have to take into account any optional brackets and default in `allowName`
  • Loading branch information
brettz9 committed Oct 14, 2024
1 parent 8b5b7f7 commit 7019d28
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/rules/match-name.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}]}]
````

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/rules/assertions/matchName.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
}],
Expand Down
23 changes: 23 additions & 0 deletions test/rules/assertions/requireHyphenBeforeParamDescription.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down

0 comments on commit 7019d28

Please sign in to comment.