????JFIF??x?x????'
Server IP : 79.136.114.73 / Your IP : 3.148.211.202 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 disallow unused labels. * @author Toru Nagashima */ "use strict"; //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ module.exports = { meta: { type: "suggestion", docs: { description: "disallow unused labels", category: "Best Practices", recommended: true, url: "https://eslint.org/docs/rules/no-unused-labels" }, schema: [], fixable: "code", messages: { unused: "'{{name}}:' is defined but never used." } }, create(context) { const sourceCode = context.getSourceCode(); let scopeInfo = null; /** * Adds a scope info to the stack. * * @param {ASTNode} node - A node to add. This is a LabeledStatement. * @returns {void} */ function enterLabeledScope(node) { scopeInfo = { label: node.label.name, used: false, upper: scopeInfo }; } /** * Removes the top of the stack. * At the same time, this reports the label if it's never used. * * @param {ASTNode} node - A node to report. This is a LabeledStatement. * @returns {void} */ function exitLabeledScope(node) { if (!scopeInfo.used) { context.report({ node: node.label, messageId: "unused", data: node.label, fix(fixer) { /* * Only perform a fix if there are no comments between the label and the body. This will be the case * when there is exactly one token/comment (the ":") between the label and the body. */ if (sourceCode.getTokenAfter(node.label, { includeComments: true }) === sourceCode.getTokenBefore(node.body, { includeComments: true })) { return fixer.removeRange([node.range[0], node.body.range[0]]); } return null; } }); } scopeInfo = scopeInfo.upper; } /** * Marks the label of a given node as used. * * @param {ASTNode} node - A node to mark. This is a BreakStatement or * ContinueStatement. * @returns {void} */ function markAsUsed(node) { if (!node.label) { return; } const label = node.label.name; let info = scopeInfo; while (info) { if (info.label === label) { info.used = true; break; } info = info.upper; } } return { LabeledStatement: enterLabeledScope, "LabeledStatement:exit": exitLabeledScope, BreakStatement: markAsUsed, ContinueStatement: markAsUsed }; } };