????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 enforce the position of line comments * @author Alberto RodrÃguez */ "use strict"; const astUtils = require("../util/ast-utils"); //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ module.exports = { meta: { type: "layout", docs: { description: "enforce position of line comments", category: "Stylistic Issues", recommended: false, url: "https://eslint.org/docs/rules/line-comment-position" }, schema: [ { oneOf: [ { enum: ["above", "beside"] }, { type: "object", properties: { position: { enum: ["above", "beside"], default: "above" }, ignorePattern: { type: "string" }, applyDefaultPatterns: { type: "boolean" }, applyDefaultIgnorePatterns: { type: "boolean" } }, additionalProperties: false } ] } ], messages: { above: "Expected comment to be above code.", beside: "Expected comment to be beside code." } }, create(context) { const options = context.options[0]; let above, ignorePattern, applyDefaultIgnorePatterns = true; if (!options || typeof options === "string") { above = !options || options === "above"; } else { above = !options.position || options.position === "above"; ignorePattern = options.ignorePattern; if (Object.prototype.hasOwnProperty.call(options, "applyDefaultIgnorePatterns")) { applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns; } else { applyDefaultIgnorePatterns = options.applyDefaultPatterns !== false; } } const defaultIgnoreRegExp = astUtils.COMMENTS_IGNORE_PATTERN; const fallThroughRegExp = /^\s*falls?\s?through/u; const customIgnoreRegExp = new RegExp(ignorePattern); // eslint-disable-line require-unicode-regexp const sourceCode = context.getSourceCode(); //-------------------------------------------------------------------------- // Public //-------------------------------------------------------------------------- return { Program() { const comments = sourceCode.getAllComments(); comments.filter(token => token.type === "Line").forEach(node => { if (applyDefaultIgnorePatterns && (defaultIgnoreRegExp.test(node.value) || fallThroughRegExp.test(node.value))) { return; } if (ignorePattern && customIgnoreRegExp.test(node.value)) { return; } const previous = sourceCode.getTokenBefore(node, { includeComments: true }); const isOnSameLine = previous && previous.loc.end.line === node.loc.start.line; if (above) { if (isOnSameLine) { context.report({ node, messageId: "above" }); } } else { if (!isOnSameLine) { context.report({ node, messageId: "beside" }); } } }); } }; } };