Skip to content

Commit

Permalink
fix(require-jsdoc): avoid exported functions possessing jsdoc blocks …
Browse files Browse the repository at this point in the history
…causing other non-public functions to be treated as exported; fixes #358
  • Loading branch information
brettz9 committed Aug 30, 2019
1 parent 5bb9182 commit 874adab
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
9 changes: 9 additions & 0 deletions README.md
Expand Up @@ -5638,6 +5638,15 @@ const myObject = {
myProp: true
};
// Options: [{"contexts":[]}]

function bear() {}
/**
*
*/
function quux () {
}
export default quux;
// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
````


Expand Down
4 changes: 1 addition & 3 deletions src/exportParser.js
Expand Up @@ -340,9 +340,7 @@ const findExportedNode = function (block, node, cache) {
if (Object.prototype.hasOwnProperty.call(props, key)) {
blockCache.push(props[key]);
if (props[key].exported) {
// If not always true, we need a test
/* istanbul ignore next */
if (findNode(node, block)) {
if (node === props[key].value || findNode(node, props[key].value)) {
return true;
}
}
Expand Down
19 changes: 19 additions & 0 deletions test/rules/assertions/requireJsdoc.js
Expand Up @@ -2163,5 +2163,24 @@ export default {
contexts: [],
},
],
}, {
code: `
function bear() {}
/**
*
*/
function quux () {
}
export default quux;
`,
options: [{
publicOnly: true,
require: {
FunctionExpression: true,
},
}],
parserOptions: {
sourceType: 'module',
},
}],
};

0 comments on commit 874adab

Please sign in to comment.