Skip to content

Commit d8c4e87

Browse files
committedMay 26, 2020
fix(require-jsdoc): ensure ArrowFunctionExpression potentially reported when part of AssignmentExpression; fixes #551
1 parent 7cb179e commit d8c4e87

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed
 

‎README.md

+6
Original file line numberDiff line numberDiff line change
@@ -8589,6 +8589,12 @@ export function bar(arg: boolean): boolean {
85898589
}
85908590
// 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}}]
85918591
// Message: Missing JSDoc comment.
8592+
8593+
module.exports.foo = (bar) => {
8594+
return bar + "biz"
8595+
}
8596+
// Options: [{"publicOnly":false,"require":{"ArrowFunctionExpression":true,"FunctionDeclaration":true,"FunctionExpression":true,"MethodDefinition":true}}]
8597+
// Message: Missing JSDoc comment.
85928598
````
85938599
85948600
The following patterns are not considered problems:

‎src/rules/requireJsdoc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export default {
229229
return;
230230
}
231231

232-
if (!['VariableDeclarator', 'ExportDefaultDeclaration'].includes(node.parent.type)) {
232+
if (!['VariableDeclarator', 'ExportDefaultDeclaration', 'AssignmentExpression'].includes(node.parent.type)) {
233233
return;
234234
}
235235

‎test/rules/assertions/requireJsdoc.js

+32
Original file line numberDiff line numberDiff line change
@@ -2155,6 +2155,38 @@ export default {
21552155
`,
21562156
parser: require.resolve('@typescript-eslint/parser'),
21572157
},
2158+
{
2159+
code: `
2160+
module.exports.foo = (bar) => {
2161+
return bar + "biz"
2162+
}
2163+
`,
2164+
errors: [
2165+
{
2166+
line: 2,
2167+
message: 'Missing JSDoc comment.',
2168+
},
2169+
],
2170+
options: [
2171+
{
2172+
publicOnly: false,
2173+
require: {
2174+
ArrowFunctionExpression: true,
2175+
FunctionDeclaration: true,
2176+
FunctionExpression: true,
2177+
MethodDefinition: true,
2178+
},
2179+
},
2180+
],
2181+
output: `
2182+
/**
2183+
*
2184+
*/
2185+
module.exports.foo = (bar) => {
2186+
return bar + "biz"
2187+
}
2188+
`,
2189+
},
21582190
],
21592191
valid: [{
21602192
code: `

0 commit comments

Comments
 (0)
Please sign in to comment.