From 142513043629dc38f61722acecb6d4f330d1d434 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Tue, 25 Jun 2019 11:51:47 +0300 Subject: [PATCH] Update eslint and eslint-plugin-vue, fix rules --- .eslintrc.yml | 1 + client/components/ChatInput.vue | 2 +- client/js/socket-events/configuration.js | 2 +- package.json | 4 +- src/client.js | 2 +- src/command-line/uninstall.js | 2 +- src/command-line/upgrade.js | 2 +- src/helper.js | 2 +- src/models/network.js | 2 +- src/plugins/changelog.js | 80 +++++++++++++----------- src/server.js | 8 +-- yarn.lock | 49 ++++++++------- 12 files changed, 83 insertions(+), 73 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index f3cb69df..8710ad9e 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -35,6 +35,7 @@ rules: no-catch-shadow: error no-confusing-arrow: [error, {allowParens: true}] no-control-regex: off + no-console: error no-duplicate-imports: error no-else-return: error no-implicit-globals: error diff --git a/client/components/ChatInput.vue b/client/components/ChatInput.vue index 812bc21c..6e72b8bf 100644 --- a/client/components/ChatInput.vue +++ b/client/components/ChatInput.vue @@ -219,7 +219,7 @@ export default { const args = text.substr(1).split(" "); const cmd = args.shift().toLowerCase(); - if (commands.hasOwnProperty(cmd) && commands[cmd].input(args)) { + if (Object.prototype.hasOwnProperty.call(commands, cmd) && commands[cmd].input(args)) { return false; } } diff --git a/client/js/socket-events/configuration.js b/client/js/socket-events/configuration.js index 9d6021fd..58b980bd 100644 --- a/client/js/socket-events/configuration.js +++ b/client/js/socket-events/configuration.js @@ -182,7 +182,7 @@ function parseOverrideParams(params, data) { key = "join"; } - if (!data.defaults.hasOwnProperty(key)) { + if (!Object.prototype.hasOwnProperty.call(data.defaults, key)) { continue; } diff --git a/package.json b/package.json index 1f252850..a90a5a03 100644 --- a/package.json +++ b/package.json @@ -81,8 +81,8 @@ "css-loader": "0.28.11", "css.escape": "1.5.1", "emoji-regex": "8.0.0", - "eslint": "5.16.0", - "eslint-plugin-vue": "5.2.2", + "eslint": "6.0.1", + "eslint-plugin-vue": "5.2.3", "fuzzy": "0.1.3", "graphql-request": "1.8.2", "handlebars": "4.1.2", diff --git a/src/client.js b/src/client.js index f794b3b2..6dde4079 100644 --- a/src/client.js +++ b/src/client.js @@ -362,7 +362,7 @@ Client.prototype.inputLine = function(data) { const irc = target.network.irc; let connected = irc && irc.connection && irc.connection.connected; - if (inputs.hasOwnProperty(cmd) && typeof inputs[cmd].input === "function") { + if (Object.prototype.hasOwnProperty.call(inputs, cmd) && typeof inputs[cmd].input === "function") { const plugin = inputs[cmd]; if (connected || plugin.allowDisconnected) { diff --git a/src/command-line/uninstall.js b/src/command-line/uninstall.js index 9b3fdc60..68a01272 100644 --- a/src/command-line/uninstall.js +++ b/src/command-line/uninstall.js @@ -32,7 +32,7 @@ program const packages = JSON.parse(fs.readFileSync(packagesConfig, "utf-8")); - if (!packages.dependencies || !packages.dependencies.hasOwnProperty(packageName)) { + if (!packages.dependencies || !Object.prototype.hasOwnProperty.call(packages.dependencies, packageName)) { log.warn(packageWasNotInstalled); process.exit(1); } diff --git a/src/command-line/upgrade.js b/src/command-line/upgrade.js index 2c82e2fa..80556276 100644 --- a/src/command-line/upgrade.js +++ b/src/command-line/upgrade.js @@ -38,7 +38,7 @@ program packages.forEach((p) => { log.info(`- ${colors.green(p)}`); - if (packagesList.hasOwnProperty(p)) { + if (Object.prototype.hasOwnProperty.call(packagesList, p)) { argsList.push(p); count++; } else { diff --git a/src/helper.js b/src/helper.js index e34922f7..6b4d4cd3 100644 --- a/src/helper.js +++ b/src/helper.js @@ -239,7 +239,7 @@ function getDefaultNick() { function mergeConfig(oldConfig, newConfig) { return _.mergeWith(oldConfig, newConfig, (objValue, srcValue, key, object) => { - if (!object.hasOwnProperty(key)) { + if (!Object.prototype.hasOwnProperty.call(object, key)) { log.warn(`Unknown key "${colors.bold(key)}", please verify your config.`); } diff --git a/src/models/network.js b/src/models/network.js index e30c866c..11dee094 100644 --- a/src/models/network.js +++ b/src/models/network.js @@ -152,7 +152,7 @@ Network.prototype.createIrcFramework = function(client) { }; Network.prototype.createWebIrc = function(client) { - if (!Helper.config.webirc || !Helper.config.webirc.hasOwnProperty(this.host)) { + if (!Helper.config.webirc || !Object.prototype.hasOwnProperty.call(Helper.config.webirc, this.host)) { return null; } diff --git a/src/plugins/changelog.js b/src/plugins/changelog.js index 8f91cd85..d755fc5d 100644 --- a/src/plugins/changelog.js +++ b/src/plugins/changelog.js @@ -34,44 +34,7 @@ async function fetch() { return versions; } - let i; - let release; - let prerelease = false; - - const body = JSON.parse(response.body); - - // Find the current release among releases on GitHub - for (i = 0; i < body.length; i++) { - release = body[i]; - - if (release.tag_name === versions.current.version) { - versions.current.changelog = release.body_html; - prerelease = release.prerelease; - - break; - } - } - - // Find the latest release made after the current one if there is one - if (i > 0) { - for (let j = 0; j < i; j++) { - release = body[j]; - - // Find latest release or pre-release if current version is also a pre-release - if (!release.prerelease || release.prerelease === prerelease) { - versions.latest = { - prerelease: release.prerelease, - version: release.tag_name, - url: release.html_url, - }; - - break; - } - } - } - - // Add expiration date to the data to send to the client for later refresh - versions.expiresAt = Date.now() + TIME_TO_LIVE; + updateVersions(response); // Emptying cached information after reaching said expiration date setTimeout(() => { @@ -84,3 +47,44 @@ async function fetch() { return versions; } + +function updateVersions(response) { + let i; + let release; + let prerelease = false; + + const body = JSON.parse(response.body); + + // Find the current release among releases on GitHub + for (i = 0; i < body.length; i++) { + release = body[i]; + + if (release.tag_name === versions.current.version) { + versions.current.changelog = release.body_html; + prerelease = release.prerelease; + + break; + } + } + + // Find the latest release made after the current one if there is one + if (i > 0) { + for (let j = 0; j < i; j++) { + release = body[j]; + + // Find latest release or pre-release if current version is also a pre-release + if (!release.prerelease || release.prerelease === prerelease) { + versions.latest = { + prerelease: release.prerelease, + version: release.tag_name, + url: release.html_url, + }; + + break; + } + } + } + + // Add expiration date to the data to send to the client for later refresh + versions.expiresAt = Date.now() + TIME_TO_LIVE; +} diff --git a/src/server.js b/src/server.js index 39203041..c43d3093 100644 --- a/src/server.js +++ b/src/server.js @@ -464,7 +464,7 @@ function initializeClient(socket, client, token, lastMessage) { if (!Helper.config.public) { socket.on("push:register", (subscription) => { - if (!client.config.sessions.hasOwnProperty(token)) { + if (!Object.prototype.hasOwnProperty.call(client.config.sessions, token)) { return; } @@ -529,7 +529,7 @@ function initializeClient(socket, client, token, lastMessage) { }); socket.on("setting:get", () => { - if (!client.config.hasOwnProperty("clientSettings")) { + if (!Object.prototype.hasOwnProperty.call(client.config, "clientSettings")) { socket.emit("setting:all", {}); return; } @@ -545,7 +545,7 @@ function initializeClient(socket, client, token, lastMessage) { tokenToSignOut = token; } - if (!client.config.sessions.hasOwnProperty(tokenToSignOut)) { + if (!Object.prototype.hasOwnProperty.call(client.config.sessions, tokenToSignOut)) { return; } @@ -717,7 +717,7 @@ function performAuthentication(data) { if (client && data.token) { const providedToken = client.calculateTokenHash(data.token); - if (client.config.sessions.hasOwnProperty(providedToken)) { + if (Object.prototype.hasOwnProperty.call(client.config.sessions, providedToken)) { token = providedToken; client.updateSession(providedToken, getClientIp(socket), socket.request); diff --git a/yarn.lock b/yarn.lock index 8ebbd6f2..e72e927c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1187,6 +1187,16 @@ ajv@^6.1.0, ajv@^6.5.5, ajv@^6.9.1: json-schema-traverse "^0.4.1" uri-js "^4.2.2" +ajv@^6.10.0: + version "6.10.0" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.0.tgz#90d0d54439da587cd7e843bfb7045f50bd22bdf1" + integrity sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg== + dependencies: + fast-deep-equal "^2.0.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + alphanum-sort@^1.0.1, alphanum-sort@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/alphanum-sort/-/alphanum-sort-1.0.2.tgz#97a1119649b211ad33691d9f9f486a8ec9fbe0a3" @@ -3110,10 +3120,10 @@ escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1 resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= -eslint-plugin-vue@5.2.2: - version "5.2.2" - resolved "https://registry.yarnpkg.com/eslint-plugin-vue/-/eslint-plugin-vue-5.2.2.tgz#86601823b7721b70bc92d54f1728cfc03b36283c" - integrity sha512-CtGWH7IB0DA6BZOwcV9w9q3Ri6Yuo8qMjx05SmOGJ6X6E0Yo3y9E/gQ5tuNxg2dEt30tRnBoFTbvtmW9iEoyHA== +eslint-plugin-vue@5.2.3: + version "5.2.3" + resolved "https://registry.yarnpkg.com/eslint-plugin-vue/-/eslint-plugin-vue-5.2.3.tgz#3ee7597d823b5478804b2feba9863b1b74273961" + integrity sha512-mGwMqbbJf0+VvpGR5Lllq0PMxvTdrZ/ZPjmhkacrCHbubJeJOt+T6E3HUzAifa2Mxi7RSdJfC9HFpOeSYVMMIw== dependencies: vue-eslint-parser "^5.0.0" @@ -3143,13 +3153,13 @@ eslint-visitor-keys@^1.0.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d" integrity sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ== -eslint@5.16.0: - version "5.16.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-5.16.0.tgz#a1e3ac1aae4a3fbd8296fcf8f7ab7314cbb6abea" - integrity sha512-S3Rz11i7c8AA5JPv7xAH+dOyq/Cu/VXHiHXBPOU1k/JAM5dXqQPt3qcrhpHSorXmrpu2g0gkIBVXAqCpzfoZIg== +eslint@6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-6.0.1.tgz#4a32181d72cb999d6f54151df7d337131f81cda7" + integrity sha512-DyQRaMmORQ+JsWShYsSg4OPTjY56u1nCjAmICrE8vLWqyLKxhFXOthwMj1SA8xwfrv0CofLNVnqbfyhwCkaO0w== dependencies: "@babel/code-frame" "^7.0.0" - ajv "^6.9.1" + ajv "^6.10.0" chalk "^2.1.0" cross-spawn "^6.0.5" debug "^4.0.1" @@ -3157,18 +3167,19 @@ eslint@5.16.0: eslint-scope "^4.0.3" eslint-utils "^1.3.1" eslint-visitor-keys "^1.0.0" - espree "^5.0.1" + espree "^6.0.0" esquery "^1.0.1" esutils "^2.0.2" file-entry-cache "^5.0.1" functional-red-black-tree "^1.0.1" - glob "^7.1.2" + glob-parent "^3.1.0" globals "^11.7.0" ignore "^4.0.6" import-fresh "^3.0.0" imurmurhash "^0.1.4" inquirer "^6.2.2" - js-yaml "^3.13.0" + is-glob "^4.0.0" + js-yaml "^3.13.1" json-stable-stringify-without-jsonify "^1.0.1" levn "^0.3.0" lodash "^4.17.11" @@ -3176,7 +3187,6 @@ eslint@5.16.0: mkdirp "^0.5.1" natural-compare "^1.4.0" optionator "^0.8.2" - path-is-inside "^1.0.2" progress "^2.0.0" regexpp "^2.0.1" semver "^5.5.1" @@ -3194,10 +3204,10 @@ espree@^4.1.0: acorn-jsx "^5.0.0" eslint-visitor-keys "^1.0.0" -espree@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/espree/-/espree-5.0.1.tgz#5d6526fa4fc7f0788a5cf75b15f30323e2f81f7a" - integrity sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A== +espree@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/espree/-/espree-6.0.0.tgz#716fc1f5a245ef5b9a7fdb1d7b0d3f02322e75f6" + integrity sha512-lJvCS6YbCn3ImT3yKkPe0+tJ+mH6ljhGNjHQH9mRtiO6gjhVAOhVXW1yjnwqGwTkK3bGbye+hb00nFNmu0l/1Q== dependencies: acorn "^6.0.7" acorn-jsx "^5.0.0" @@ -6240,11 +6250,6 @@ path-is-absolute@^1.0.0: resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= -path-is-inside@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" - integrity sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM= - path-key@^2.0.0, path-key@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"