]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/lib/rules/require-jsdoc.js
2 * @fileoverview Rule to check for jsdoc presence.
3 * @author Gyandeep Singh
4 * @deprecated in ESLint v5.10.0
8 /** @type {import('../shared/types').Rule} */
14 description
: "Require JSDoc comments",
16 url
: "https://eslint.org/docs/latest/rules/require-jsdoc"
34 FunctionDeclaration
: {
38 ArrowFunctionExpression
: {
47 additionalProperties
: false,
51 additionalProperties
: false
59 missingJSDocComment
: "Missing JSDoc comment."
64 const source
= context
.sourceCode
;
65 const DEFAULT_OPTIONS
= {
66 FunctionDeclaration
: true,
67 MethodDefinition
: false,
68 ClassDeclaration
: false,
69 ArrowFunctionExpression
: false,
70 FunctionExpression
: false
72 const options
= Object
.assign(DEFAULT_OPTIONS
, context
.options
[0] && context
.options
[0].require
);
75 * Report the error message
76 * @param {ASTNode} node node to report
79 function report(node
) {
80 context
.report({ node
, messageId
: "missingJSDocComment" });
84 * Check if the jsdoc comment is present or not.
85 * @param {ASTNode} node node to examine
88 function checkJsDoc(node
) {
89 const jsdocComment
= source
.getJSDocComment(node
);
97 FunctionDeclaration(node
) {
98 if (options
.FunctionDeclaration
) {
102 FunctionExpression(node
) {
104 (options
.MethodDefinition
&& node
.parent
.type
=== "MethodDefinition") ||
105 (options
.FunctionExpression
&& (node
.parent
.type
=== "VariableDeclarator" || (node
.parent
.type
=== "Property" && node
=== node
.parent
.value
)))
110 ClassDeclaration(node
) {
111 if (options
.ClassDeclaration
) {
115 ArrowFunctionExpression(node
) {
116 if (options
.ArrowFunctionExpression
&& node
.parent
.type
=== "VariableDeclarator") {