Skip to content

Commit

Permalink
fix(match-description): ensure prop and property matching exclude…
Browse files Browse the repository at this point in the history
…s name
  • Loading branch information
brettz9 committed Jul 14, 2019
1 parent 9fab87c commit 71f35e2
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
21 changes: 21 additions & 0 deletions README.md
Expand Up @@ -2655,6 +2655,17 @@ function quux (foo) {
// Options: [{"tags":{"param":true}}]
// Message: JSDoc description does not satisfy the regex pattern.

/**
* Foo.
*
* @prop foo foo.
*/
function quux (foo) {

}
// Options: [{"tags":{"prop":true}}]
// Message: JSDoc description does not satisfy the regex pattern.

/**
* Foo.
*
Expand Down Expand Up @@ -3122,6 +3133,16 @@ function quux () {

}
// Options: [{"tags":{"x-tag":".+"}}]

/**
* Foo.
*
* @prop foo Foo.
*/
function quux (foo) {

}
// Options: [{"tags":{"prop":true}}]
````


Expand Down
4 changes: 3 additions & 1 deletion src/jsdocUtils.js
Expand Up @@ -524,7 +524,9 @@ const filterTags = (tags = [], filter) => {
return tags.filter(filter);
};

const tagsWithNamesAndDescriptions = ['param', 'arg', 'argument', 'returns', 'return'];
const tagsWithNamesAndDescriptions = [
'param', 'arg', 'argument', 'property', 'prop', 'returns', 'return'
];

const getTagsByType = (tags, tagPreference) => {
const descName = getPreferredTagName('description', tagPreference);
Expand Down
44 changes: 44 additions & 0 deletions test/rules/assertions/matchDescription.js
Expand Up @@ -160,6 +160,31 @@ export default {
}
]
},
{
code: `
/**
* Foo.
*
* @prop foo foo.
*/
function quux (foo) {
}
`,
errors: [
{
line: 5,
message: 'JSDoc description does not satisfy the regex pattern.'
}
],
options: [
{
tags: {
prop: true
}
}
]
},
{
code: `
/**
Expand Down Expand Up @@ -1086,6 +1111,25 @@ export default {
}
}
]
},
{
code: `
/**
* Foo.
*
* @prop foo Foo.
*/
function quux (foo) {
}
`,
options: [
{
tags: {
prop: true
}
}
]
}
]
};

0 comments on commit 71f35e2

Please sign in to comment.