????JFIF??x?x????'
Server IP : 79.136.114.73 / Your IP : 3.23.61.129 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 check for "block scoped" variables by binding context * @author Matt DuVall <http://www.mattduvall.com> */ "use strict"; //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ module.exports = { meta: { type: "suggestion", docs: { description: "enforce the use of variables within the scope they are defined", category: "Best Practices", recommended: false, url: "https://eslint.org/docs/rules/block-scoped-var" }, schema: [], messages: { outOfScope: "'{{name}}' used outside of binding context." } }, create(context) { let stack = []; /** * Makes a block scope. * @param {ASTNode} node - A node of a scope. * @returns {void} */ function enterScope(node) { stack.push(node.range); } /** * Pops the last block scope. * @returns {void} */ function exitScope() { stack.pop(); } /** * Reports a given reference. * @param {eslint-scope.Reference} reference - A reference to report. * @returns {void} */ function report(reference) { const identifier = reference.identifier; context.report({ node: identifier, messageId: "outOfScope", data: { name: identifier.name } }); } /** * Finds and reports references which are outside of valid scopes. * @param {ASTNode} node - A node to get variables. * @returns {void} */ function checkForVariables(node) { if (node.kind !== "var") { return; } // Defines a predicate to check whether or not a given reference is outside of valid scope. const scopeRange = stack[stack.length - 1]; /** * Check if a reference is out of scope * @param {ASTNode} reference node to examine * @returns {boolean} True is its outside the scope * @private */ function isOutsideOfScope(reference) { const idRange = reference.identifier.range; return idRange[0] < scopeRange[0] || idRange[1] > scopeRange[1]; } // Gets declared variables, and checks its references. const variables = context.getDeclaredVariables(node); for (let i = 0; i < variables.length; ++i) { // Reports. variables[i] .references .filter(isOutsideOfScope) .forEach(report); } } return { Program(node) { stack = [node.range]; }, // Manages scopes. BlockStatement: enterScope, "BlockStatement:exit": exitScope, ForStatement: enterScope, "ForStatement:exit": exitScope, ForInStatement: enterScope, "ForInStatement:exit": exitScope, ForOfStatement: enterScope, "ForOfStatement:exit": exitScope, SwitchStatement: enterScope, "SwitchStatement:exit": exitScope, CatchClause: enterScope, "CatchClause:exit": exitScope, // Finds and reports references which are outside of valid scope. VariableDeclaration: checkForVariables }; } };