123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var OPTIONS_SCHEMA = {
- additionalProperties: false,
- properties: {
- require: {
- additionalProperties: false,
- default: {},
- properties: {
- ArrowFunctionExpression: {
- default: false,
- type: 'boolean'
- },
- ClassDeclaration: {
- default: false,
- type: 'boolean'
- },
- FunctionDeclaration: {
- default: true,
- type: 'boolean'
- },
- FunctionExpression: {
- default: false,
- type: 'boolean'
- },
- MethodDefinition: {
- default: false,
- type: 'boolean'
- }
- },
- type: 'object'
- }
- },
- type: 'object'
- };
- var getOption = function getOption(context, key) {
- if (!context.options.length) {
- return OPTIONS_SCHEMA.properties.require.properties[key].default;
- }
- if (!context.options[0] || !context.options[0].require) {
- return OPTIONS_SCHEMA.properties.require.properties[key].default;
- }
- if (!context.options[0].require.hasOwnProperty(key)) {
- return OPTIONS_SCHEMA.properties.require.properties[key].default;
- }
- return context.options[0].require[key];
- };
- var getOptions = function getOptions(context) {
- return {
- ArrowFunctionExpression: getOption(context, 'ArrowFunctionExpression'),
- ClassDeclaration: getOption(context, 'ClassDeclaration'),
- FunctionDeclaration: getOption(context, 'FunctionDeclaration'),
- FunctionExpression: getOption(context, 'FunctionExpression'),
- MethodDefinition: getOption(context, 'MethodDefinition')
- };
- };
- var checkJsDoc = function checkJsDoc(context, node) {
- var jsDocNode = context.getSourceCode().getJSDocComment(node);
- if (jsDocNode) {
- return;
- }
- context.report({
- messageId: 'missingJsDoc',
- node
- });
- };
- var _default = {
- /**
- * The entrypoint for the JSDoc rule.
- *
- * @param {*} context
- * a reference to the context which hold all important information
- * like settings and the sourcecode to check.
- * @returns {*}
- * a list with parser callback function.
- */
- create(context) {
- var options = getOptions(context);
- return {
- ArrowFunctionExpression: function ArrowFunctionExpression(node) {
- if (!options.ArrowFunctionExpression) {
- return;
- }
- if (node.parent.type !== 'VariableDeclarator') {
- return;
- }
- checkJsDoc(context, node);
- },
- ClassDeclaration: function ClassDeclaration(node) {
- if (!options.ClassDeclaration) {
- return;
- }
- checkJsDoc(context, node);
- },
- FunctionDeclaration: function FunctionDeclaration(node) {
- if (!options.FunctionDeclaration) {
- return;
- }
- checkJsDoc(context, node);
- },
- FunctionExpression: function FunctionExpression(node) {
- if (options.MethodDefinition && node.parent.type === 'MethodDefinition') {
- checkJsDoc(context, node);
- return;
- }
- if (!options.FunctionExpression) {
- return;
- }
- if (node.parent.type === 'VariableDeclarator') {
- checkJsDoc(context, node);
- }
- if (node.parent.type === 'Property' && node === node.parent.value) {
- checkJsDoc(context, node);
- }
- }
- };
- },
- meta: {
- doc: {
- category: 'Stylistic Issues',
- description: 'Require JSDoc comments',
- recommended: 'true',
- url: 'https://github.com/gajus/eslint-plugin-jsdoc'
- },
- messages: {
- missingJsDoc: 'Missing JSDoc comment.'
- },
- schema: [OPTIONS_SCHEMA],
- type: 'suggestion'
- }
- };
- exports.default = _default;
- module.exports = exports.default;
- //# sourceMappingURL=requireJsdoc.js.map
|