????JFIF??x?x????'
Server IP : 79.136.114.73 / Your IP : 216.73.216.238 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/appsrv.astacus.se/forge/node_modules/eslint/lib/rules/ |
Upload File : |
/** * @fileoverview Rule to flag use of console object * @author Nicholas C. Zakas */ "use strict"; //------------------------------------------------------------------------------ // Requirements //------------------------------------------------------------------------------ const astUtils = require("../util/ast-utils"); //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ module.exports = { meta: { type: "suggestion", docs: { description: "disallow the use of `console`", category: "Possible Errors", recommended: true, url: "https://eslint.org/docs/rules/no-console" }, schema: [ { type: "object", properties: { allow: { type: "array", items: { type: "string" }, minItems: 1, uniqueItems: true } }, additionalProperties: false } ], messages: { unexpected: "Unexpected console statement." } }, create(context) { const options = context.options[0] || {}; const allowed = options.allow || []; /** * Checks whether the given reference is 'console' or not. * * @param {eslint-scope.Reference} reference - The reference to check. * @returns {boolean} `true` if the reference is 'console'. */ function isConsole(reference) { const id = reference.identifier; return id && id.name === "console"; } /** * Checks whether the property name of the given MemberExpression node * is allowed by options or not. * * @param {ASTNode} node - The MemberExpression node to check. * @returns {boolean} `true` if the property name of the node is allowed. */ function isAllowed(node) { const propertyName = astUtils.getStaticPropertyName(node); return propertyName && allowed.indexOf(propertyName) !== -1; } /** * Checks whether the given reference is a member access which is not * allowed by options or not. * * @param {eslint-scope.Reference} reference - The reference to check. * @returns {boolean} `true` if the reference is a member access which * is not allowed by options. */ function isMemberAccessExceptAllowed(reference) { const node = reference.identifier; const parent = node.parent; return ( parent.type === "MemberExpression" && parent.object === node && !isAllowed(parent) ); } /** * Reports the given reference as a violation. * * @param {eslint-scope.Reference} reference - The reference to report. * @returns {void} */ function report(reference) { const node = reference.identifier.parent; context.report({ node, loc: node.loc, messageId: "unexpected" }); } return { "Program:exit"() { const scope = context.getScope(); const consoleVar = astUtils.getVariableByName(scope, "console"); const shadowed = consoleVar && consoleVar.defs.length > 0; /* * 'scope.through' includes all references to undefined * variables. If the variable 'console' is not defined, it uses * 'scope.through'. */ const references = consoleVar ? consoleVar.references : scope.through.filter(isConsole); if (!shadowed) { references .filter(isMemberAccessExceptAllowed) .forEach(report); } } }; } };