Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(require-jsdoc): avoid error with checkConstructors: false whe…
…n attempting to check tags; fixes #611

In this rule, jsdocNode is empty by the time we check for `exemptSpecialMethods`, so ensure there is a no-op for its tags
  • Loading branch information
brettz9 committed Jul 20, 2020
1 parent 842381a commit 854fb24
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -9212,6 +9212,12 @@ function quux() {
}
// Settings: {"jsdoc":{"structuredTags":{"see":{"name":false,"required":["name"]}}}}
// Message: Cannot add "name" to `require` with the tag's `name` set to `false`

class Test {
aFunc() {}
}
// Options: [{"checkConstructors":false,"require":{"ArrowFunctionExpression":true,"ClassDeclaration":false,"ClassExpression":true,"FunctionDeclaration":true,"FunctionExpression":true,"MethodDefinition":true}}]
// Message: Missing JSDoc comment.
````

The following patterns are not considered problems:
Expand Down
2 changes: 1 addition & 1 deletion src/rules/requireJsdoc.js
Expand Up @@ -185,7 +185,7 @@ export default {

// For those who have options configured against ANY constructors (or setters or getters) being reported
if (jsdocUtils.exemptSpeciaMethods(
jsDocNode, node, context, [OPTIONS_SCHEMA],
{tags: []}, node, context, [OPTIONS_SCHEMA],
)) {
return;
}
Expand Down
30 changes: 30 additions & 0 deletions test/rules/assertions/requireJsdoc.js
Expand Up @@ -2428,6 +2428,36 @@ export default {
},
},
},
{
code: `
class Test {
aFunc() {}
}
`,
errors: [{
line: 3,
message: 'Missing JSDoc comment.',
}],
options: [{
checkConstructors: false,
require: {
ArrowFunctionExpression: true,
ClassDeclaration: false,
ClassExpression: true,
FunctionDeclaration: true,
FunctionExpression: true,
MethodDefinition: true,
},
}],
output: `
class Test {
/**
*
*/
aFunc() {}
}
`,
},
],
valid: [{
code: `
Expand Down

0 comments on commit 854fb24

Please sign in to comment.