Skip to content

Commit 71f35e2

Browse files
committed
fix(match-description): ensure prop and property matching excludes name
1 parent 9fab87c commit 71f35e2

File tree

3 files changed

+68
-1
lines changed

3 files changed

+68
-1
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2655,6 +2655,17 @@ function quux (foo) {
26552655
// Options: [{"tags":{"param":true}}]
26562656
// Message: JSDoc description does not satisfy the regex pattern.
26572657

2658+
/**
2659+
* Foo.
2660+
*
2661+
* @prop foo foo.
2662+
*/
2663+
function quux (foo) {
2664+
2665+
}
2666+
// Options: [{"tags":{"prop":true}}]
2667+
// Message: JSDoc description does not satisfy the regex pattern.
2668+
26582669
/**
26592670
* Foo.
26602671
*
@@ -3122,6 +3133,16 @@ function quux () {
31223133

31233134
}
31243135
// Options: [{"tags":{"x-tag":".+"}}]
3136+
3137+
/**
3138+
* Foo.
3139+
*
3140+
* @prop foo Foo.
3141+
*/
3142+
function quux (foo) {
3143+
3144+
}
3145+
// Options: [{"tags":{"prop":true}}]
31253146
````
31263147

31273148

src/jsdocUtils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,9 @@ const filterTags = (tags = [], filter) => {
524524
return tags.filter(filter);
525525
};
526526

527-
const tagsWithNamesAndDescriptions = ['param', 'arg', 'argument', 'returns', 'return'];
527+
const tagsWithNamesAndDescriptions = [
528+
'param', 'arg', 'argument', 'property', 'prop', 'returns', 'return'
529+
];
528530

529531
const getTagsByType = (tags, tagPreference) => {
530532
const descName = getPreferredTagName('description', tagPreference);

test/rules/assertions/matchDescription.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,31 @@ export default {
160160
}
161161
]
162162
},
163+
{
164+
code: `
165+
/**
166+
* Foo.
167+
*
168+
* @prop foo foo.
169+
*/
170+
function quux (foo) {
171+
172+
}
173+
`,
174+
errors: [
175+
{
176+
line: 5,
177+
message: 'JSDoc description does not satisfy the regex pattern.'
178+
}
179+
],
180+
options: [
181+
{
182+
tags: {
183+
prop: true
184+
}
185+
}
186+
]
187+
},
163188
{
164189
code: `
165190
/**
@@ -1086,6 +1111,25 @@ export default {
10861111
}
10871112
}
10881113
]
1114+
},
1115+
{
1116+
code: `
1117+
/**
1118+
* Foo.
1119+
*
1120+
* @prop foo Foo.
1121+
*/
1122+
function quux (foo) {
1123+
1124+
}
1125+
`,
1126+
options: [
1127+
{
1128+
tags: {
1129+
prop: true
1130+
}
1131+
}
1132+
]
10891133
}
10901134
]
10911135
};

0 commit comments

Comments
 (0)