summaryrefslogtreecommitdiff
path: root/tools/eslint/lib/rules/require-jsdoc.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/eslint/lib/rules/require-jsdoc.js')
-rw-r--r--tools/eslint/lib/rules/require-jsdoc.js29
1 files changed, 11 insertions, 18 deletions
diff --git a/tools/eslint/lib/rules/require-jsdoc.js b/tools/eslint/lib/rules/require-jsdoc.js
index f1ecde81f9..a02ee3659c 100644
--- a/tools/eslint/lib/rules/require-jsdoc.js
+++ b/tools/eslint/lib/rules/require-jsdoc.js
@@ -30,6 +30,9 @@ module.exports = {
},
ArrowFunctionExpression: {
type: "boolean"
+ },
+ FunctionExpression: {
+ type: "boolean"
}
},
additionalProperties: false
@@ -45,7 +48,9 @@ module.exports = {
const DEFAULT_OPTIONS = {
FunctionDeclaration: true,
MethodDefinition: false,
- ClassDeclaration: false
+ ClassDeclaration: false,
+ ArrowFunctionExpression: false,
+ FunctionExpression: false
};
const options = Object.assign(DEFAULT_OPTIONS, context.options[0] && context.options[0].require || {});
@@ -59,21 +64,6 @@ module.exports = {
}
/**
- * Check if the jsdoc comment is present for class methods
- * @param {ASTNode} node node to examine
- * @returns {void}
- */
- function checkClassMethodJsDoc(node) {
- if (node.parent.type === "MethodDefinition") {
- const jsdocComment = source.getJSDocComment(node);
-
- if (!jsdocComment) {
- report(node);
- }
- }
- }
-
- /**
* Check if the jsdoc comment is present or not.
* @param {ASTNode} node node to examine
* @returns {void}
@@ -93,8 +83,11 @@ module.exports = {
}
},
FunctionExpression(node) {
- if (options.MethodDefinition) {
- checkClassMethodJsDoc(node);
+ if (
+ (options.MethodDefinition && node.parent.type === "MethodDefinition") ||
+ (options.FunctionExpression && (node.parent.type === "VariableDeclarator" || (node.parent.type === "Property" && node === node.parent.value)))
+ ) {
+ checkJsDoc(node);
}
},
ClassDeclaration(node) {