Skip to content

Commit

Permalink
fix(require-jsdoc): ensure ArrowFunctionExpression potentially repo…
Browse files Browse the repository at this point in the history
…rted when part of `AssignmentExpression`; fixes #551
  • Loading branch information
brettz9 committed May 26, 2020
1 parent 7cb179e commit d8c4e87
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -8589,6 +8589,12 @@ export function bar(arg: boolean): boolean {
}
// Options: [{"contexts":["ExportNamedDeclaration[declaration.type=\"TSDeclareFunction\"]:not(ExportNamedDeclaration[declaration.type=\"TSDeclareFunction\"] + ExportNamedDeclaration[declaration.type=\"TSDeclareFunction\"])","ExportNamedDeclaration[declaration.type=\"FunctionDeclaration\"]:not(ExportNamedDeclaration[declaration.type=\"TSDeclareFunction\"] + ExportNamedDeclaration[declaration.type=\"FunctionDeclaration\"])"],"require":{"FunctionDeclaration":false}}]
// Message: Missing JSDoc comment.
module.exports.foo = (bar) => {
return bar + "biz"
}
// Options: [{"publicOnly":false,"require":{"ArrowFunctionExpression":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 @@ -229,7 +229,7 @@ export default {
return;
}

if (!['VariableDeclarator', 'ExportDefaultDeclaration'].includes(node.parent.type)) {
if (!['VariableDeclarator', 'ExportDefaultDeclaration', 'AssignmentExpression'].includes(node.parent.type)) {
return;
}

Expand Down
32 changes: 32 additions & 0 deletions test/rules/assertions/requireJsdoc.js
Expand Up @@ -2155,6 +2155,38 @@ export default {
`,
parser: require.resolve('@typescript-eslint/parser'),
},
{
code: `
module.exports.foo = (bar) => {
return bar + "biz"
}
`,
errors: [
{
line: 2,
message: 'Missing JSDoc comment.',
},
],
options: [
{
publicOnly: false,
require: {
ArrowFunctionExpression: true,
FunctionDeclaration: true,
FunctionExpression: true,
MethodDefinition: true,
},
},
],
output: `
/**
*
*/
module.exports.foo = (bar) => {
return bar + "biz"
}
`,
},
],
valid: [{
code: `
Expand Down

0 comments on commit d8c4e87

Please sign in to comment.