Server IP : 150.95.80.236 / Your IP : 18.227.21.70 Web Server : Apache System : Linux host-150-95-80-236 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64 User : social-telecare ( 10000) PHP Version : 7.4.33 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/pcu.in.th/api-uat.pcu.in.th/node_modules/eslint/lib/rules/ |
Upload File : |
/** * @fileoverview Rule to enforce description with the `Symbol` object * @author Jarek Rencz */ "use strict"; //------------------------------------------------------------------------------ // Requirements //------------------------------------------------------------------------------ const astUtils = require("./utils/ast-utils"); //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ /** @type {import('../shared/types').Rule} */ module.exports = { meta: { type: "suggestion", docs: { description: "Require symbol descriptions", recommended: false, url: "https://eslint.org/docs/latest/rules/symbol-description" }, fixable: null, schema: [], messages: { expected: "Expected Symbol to have a description." } }, create(context) { const sourceCode = context.sourceCode; /** * Reports if node does not conform the rule in case rule is set to * report missing description * @param {ASTNode} node A CallExpression node to check. * @returns {void} */ function checkArgument(node) { if (node.arguments.length === 0) { context.report({ node, messageId: "expected" }); } } return { "Program:exit"(node) { const scope = sourceCode.getScope(node); const variable = astUtils.getVariableByName(scope, "Symbol"); if (variable && variable.defs.length === 0) { variable.references.forEach(reference => { const idNode = reference.identifier; if (astUtils.isCallee(idNode)) { checkArgument(idNode.parent); } }); } } }; } };