From 752557e813dd73b762d10af94f1ec048d606a17b Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 4 Aug 2018 11:27:10 -0500 Subject: [PATCH 1/2] Add eslint support. Run with `yarn run lint` or `bin/webpack`. --- .eslintrc.yml | 88 +++++++ config/webpack/development.js | 3 + config/webpack/loaders/eslint.js | 10 + package.json | 7 + yarn.lock | 382 ++++++++++++++++++++++++++++++- 5 files changed, 479 insertions(+), 11 deletions(-) create mode 100644 .eslintrc.yml create mode 100644 config/webpack/loaders/eslint.js diff --git a/.eslintrc.yml b/.eslintrc.yml new file mode 100644 index 000000000..acf33ef17 --- /dev/null +++ b/.eslintrc.yml @@ -0,0 +1,88 @@ +env: + browser: true + es6: true +extends: 'eslint:recommended' +parserOptions: + sourceType: module +globals: + $: false + require: false +rules: + # https://eslint.org/docs/rules/ + array-callback-return: error + block-scoped-var: error + consistent-return: error + default-case: error + dot-notation: error + eqeqeq: error + init-declarations: error + no-caller: error + no-empty-function: error + no-eval: error + no-extend-native: error + no-implicit-coercion: error + no-lone-blocks: error + no-lonely-if: error + no-mixed-operators: error + no-new: error + no-new-wrappers: error + no-return-assign: error + no-self-compare: error + no-sequences: error + no-shadow: error + no-shadow-restricted-names: error + no-unused-expressions: error + no-unused-vars: + - error + - argsIgnorePattern: "^_" + args: none + no-use-before-define: error + no-useless-call: error + no-useless-concat: error + no-useless-return: error + + # formatting issues + array-bracket-spacing: warn + brace-style: [warn, 1tbs, allowSingleLine: true] + comma-spacing: warn + curly: warn + dot-location: [warn, property] + eol-last: warn + func-call-spacing: warn + indent: [warn, 2] + linebreak-style: [warn, unix] + key-spacing: warn + keyword-spacing: warn + no-multiple-empty-lines: warn + no-tabs: warn + no-trailing-spaces: warn + no-whitespace-before-property: warn + space-before-blocks: warn + space-in-parens: warn + space-infix-ops: warn + space-unary-ops: warn + spaced-comment: warn + +# These rules are potentially useful, but are currently too noisy to enable. + +# block-spacing: warn +# no-alert: warn +# no-extra-parens: warn +# no-magic-numbers: +# - warn +# - ignore: [-1, 0, 1] +# ignoreArrayIndexes: true +# enforceConst: true +# no-multi-spaces: warn +# no-negated-condition: warn +# no-param-reassign: warn +# no-var: warn +# object-curly-spacing: warn +# prefer-arrow-callback: warn +# prefer-const: warn +# prefer-template: warn +# quote-props: [warn, consistent-as-needed] +# radix: warn +# semi: warn +# space-before-function-paren: warn +# vars-on-top: warn diff --git a/config/webpack/development.js b/config/webpack/development.js index c5edff94a..41b16a460 100644 --- a/config/webpack/development.js +++ b/config/webpack/development.js @@ -1,5 +1,8 @@ process.env.NODE_ENV = process.env.NODE_ENV || 'development' const environment = require('./environment') +const eslint = require('./loaders/eslint') + +environment.loaders.append('eslint', eslint); module.exports = environment.toWebpackConfig() diff --git a/config/webpack/loaders/eslint.js b/config/webpack/loaders/eslint.js new file mode 100644 index 000000000..7e6fb412d --- /dev/null +++ b/config/webpack/loaders/eslint.js @@ -0,0 +1,10 @@ +module.exports = { + enforce: 'pre', + test: /\.(js)$/i, + exclude: /node_modules|vendor/, + loader: 'eslint-loader', + options: { + cache: true, + emitWarning: true, + } +} diff --git a/package.json b/package.json index 88d91a9e3..4643ea0e6 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,5 @@ { + "license": "MIT", "dependencies": { "@rails/webpacker": "^3.5.3", "debug-loader": "^0.0.1", @@ -12,6 +13,12 @@ "webpack-cli": "^3.0.8" }, "devDependencies": { + "eslint": "^5.3.0", + "eslint-loader": "^2.1.0", + "eslint-plugin-ignore-erb": "^0.1.1", "webpack-dev-server": "^2.11.1" + }, + "scripts": { + "lint": "yarn run eslint --plugin eslint-plugin-ignore-erb --ext .js,.js.erb app/javascript/src/javascripts" } } diff --git a/yarn.lock b/yarn.lock index 422a81b1a..510610837 100644 --- a/yarn.lock +++ b/yarn.lock @@ -48,15 +48,21 @@ acorn-dynamic-import@^2.0.0: dependencies: acorn "^4.0.3" +acorn-jsx@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-4.1.1.tgz#e8e41e48ea2fe0c896740610ab6a4ffd8add225e" + dependencies: + acorn "^5.0.3" + acorn@^4.0.3: version "4.0.13" resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.13.tgz#105495ae5361d697bd195c825192e1ad7f253787" -acorn@^5.0.0: +acorn@^5.0.0, acorn@^5.0.3, acorn@^5.6.0: version "5.7.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.1.tgz#f095829297706a7c9776958c0afc8930a9b9d9d8" -ajv-keywords@^3.1.0: +ajv-keywords@^3.0.0, ajv-keywords@^3.1.0: version "3.2.0" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.2.0.tgz#e86b819c602cf8821ad637413698f1dec021847a" @@ -76,7 +82,7 @@ ajv@^5.0.0, ajv@^5.1.0: fast-json-stable-stringify "^2.0.0" json-schema-traverse "^0.3.0" -ajv@^6.1.0: +ajv@^6.0.1, ajv@^6.1.0, ajv@^6.5.0: version "6.5.2" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.5.2.tgz#678495f9b82f7cca6be248dd92f59bff5e1f4360" dependencies: @@ -206,6 +212,10 @@ array-unique@^0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" +arrify@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" + asn1.js@^4.0.0: version "4.10.1" resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.10.1.tgz#b9c2bf5805f1e64aadeed6df3a2bfafb5a73f5a0" @@ -1061,6 +1071,16 @@ cache-base@^1.0.1: union-value "^1.0.0" unset-value "^1.0.0" +caller-path@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-0.1.0.tgz#94085ef63581ecd3daa92444a8fe94e82577751f" + dependencies: + callsites "^0.2.0" + +callsites@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/callsites/-/callsites-0.2.0.tgz#afab96262910a7f33c19a5775825c69f34e350ca" + camelcase-keys@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7" @@ -1135,7 +1155,7 @@ chalk@^1.1.1, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.0.0, chalk@^2.0.1, chalk@^2.4.1: +chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.4.1: version "2.4.1" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e" dependencies: @@ -1143,6 +1163,10 @@ chalk@^2.0.0, chalk@^2.0.1, chalk@^2.4.1: escape-string-regexp "^1.0.5" supports-color "^5.3.0" +chardet@^0.4.0: + version "0.4.2" + resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2" + chardet@^0.5.0: version "0.5.0" resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.5.0.tgz#fe3ac73c00c3d865ffcc02a0682e2c20b6a06029" @@ -1177,6 +1201,10 @@ cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: inherits "^2.0.1" safe-buffer "^5.0.1" +circular-json@^0.3.1: + version "0.3.3" + resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.3.tgz#815c99ea84f6809529d2f45791bdf82711352d66" + clap@^1.0.9: version "1.2.3" resolved "https://registry.yarnpkg.com/clap/-/clap-1.2.3.tgz#4f36745b32008492557f46412d66d50cb99bce51" @@ -1680,6 +1708,10 @@ deep-extend@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" +deep-is@~0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" + define-properties@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94" @@ -1710,6 +1742,18 @@ defined@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693" +del@^2.0.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8" + dependencies: + globby "^5.0.0" + is-path-cwd "^1.0.0" + is-path-in-cwd "^1.0.0" + object-assign "^4.0.1" + pify "^2.0.0" + pinkie-promise "^2.0.0" + rimraf "^2.2.8" + del@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/del/-/del-3.0.0.tgz#53ecf699ffcbcb39637691ab13baf160819766e5" @@ -1787,6 +1831,12 @@ dns-txt@^2.0.2: dependencies: buffer-indexof "^1.0.0" +doctrine@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d" + dependencies: + esutils "^2.0.2" + domain-browser@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.2.0.tgz#3d31f50191a6749dd1375a7f522e823d42e54eda" @@ -1869,7 +1919,7 @@ error-ex@^1.2.0: dependencies: is-arrayish "^0.2.1" -es-abstract@^1.7.0: +es-abstract@^1.10.0, es-abstract@^1.7.0: version "1.12.0" resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.12.0.tgz#9dbbdd27c6856f0001421ca18782d786bf8a6165" dependencies: @@ -1957,6 +2007,88 @@ escope@^3.6.0: esrecurse "^4.1.0" estraverse "^4.1.1" +eslint-loader@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/eslint-loader/-/eslint-loader-2.1.0.tgz#61334c548aeb0b8e20ec3a552fb7a88c47261c6a" + dependencies: + loader-fs-cache "^1.0.0" + loader-utils "^1.0.2" + object-assign "^4.0.1" + object-hash "^1.1.4" + rimraf "^2.6.1" + +eslint-plugin-ignore-erb@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-ignore-erb/-/eslint-plugin-ignore-erb-0.1.1.tgz#951497d935c7d8a713a67f6bbbaa92e29bf0826d" + dependencies: + requireindex "~1.1.0" + +eslint-scope@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.0.tgz#50bf3071e9338bcdc43331794a0cb533f0136172" + dependencies: + esrecurse "^4.1.0" + estraverse "^4.1.1" + +eslint-utils@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.3.1.tgz#9a851ba89ee7c460346f97cf8939c7298827e512" + +eslint-visitor-keys@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d" + +eslint@^5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-5.3.0.tgz#53695aca5213968aacdf970ccb231e42a2b285f8" + dependencies: + ajv "^6.5.0" + babel-code-frame "^6.26.0" + chalk "^2.1.0" + cross-spawn "^6.0.5" + debug "^3.1.0" + doctrine "^2.1.0" + eslint-scope "^4.0.0" + eslint-utils "^1.3.1" + eslint-visitor-keys "^1.0.0" + espree "^4.0.0" + esquery "^1.0.1" + esutils "^2.0.2" + file-entry-cache "^2.0.0" + functional-red-black-tree "^1.0.1" + glob "^7.1.2" + globals "^11.7.0" + ignore "^4.0.2" + imurmurhash "^0.1.4" + inquirer "^5.2.0" + is-resolvable "^1.1.0" + js-yaml "^3.11.0" + json-stable-stringify-without-jsonify "^1.0.1" + levn "^0.3.0" + lodash "^4.17.5" + minimatch "^3.0.4" + mkdirp "^0.5.1" + natural-compare "^1.4.0" + optionator "^0.8.2" + path-is-inside "^1.0.2" + pluralize "^7.0.0" + progress "^2.0.0" + regexpp "^2.0.0" + require-uncached "^1.0.3" + semver "^5.5.0" + string.prototype.matchall "^2.0.0" + strip-ansi "^4.0.0" + strip-json-comments "^2.0.1" + table "^4.0.3" + text-table "^0.2.0" + +espree@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/espree/-/espree-4.0.0.tgz#253998f20a0f82db5d866385799d912a83a36634" + dependencies: + acorn "^5.6.0" + acorn-jsx "^4.1.1" + esprima@^2.6.0: version "2.7.3" resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" @@ -1965,13 +2097,19 @@ esprima@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.0.tgz#4499eddcd1110e0b218bacf2fa7f7f59f55ca804" +esquery@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.1.tgz#406c51658b1f5991a5f9b62b1dc25b00e3e5c708" + dependencies: + estraverse "^4.0.0" + esrecurse@^4.1.0: version "4.2.1" resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.1.tgz#007a3b9fdbc2b3bb87e4879ea19c92fdbd3942cf" dependencies: estraverse "^4.1.0" -estraverse@^4.1.0, estraverse@^4.1.1: +estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1: version "4.2.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" @@ -2107,6 +2245,14 @@ extend@~3.0.0, extend@~3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" +external-editor@^2.1.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.2.0.tgz#045511cfd8d133f3846673d1047c154e214ad3d5" + dependencies: + chardet "^0.4.0" + iconv-lite "^0.4.17" + tmp "^0.0.33" + external-editor@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.0.0.tgz#dc35c48c6f98a30ca27a20e9687d7f3c77704bb6" @@ -2163,6 +2309,10 @@ fast-json-stable-stringify@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" +fast-levenshtein@~2.0.4: + version "2.0.6" + resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" + fastparse@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/fastparse/-/fastparse-1.1.1.tgz#d1e2643b38a94d7583b479060e6c4affc94071f8" @@ -2185,6 +2335,13 @@ figures@^2.0.0: dependencies: escape-string-regexp "^1.0.5" +file-entry-cache@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-2.0.0.tgz#c392990c3e684783d838b8c84a45d8a048458361" + dependencies: + flat-cache "^1.2.1" + object-assign "^4.0.1" + file-loader@^1.1.11: version "1.1.11" resolved "https://registry.yarnpkg.com/file-loader/-/file-loader-1.1.11.tgz#6fe886449b0f2a936e43cabaac0cdbfb369506f8" @@ -2227,6 +2384,14 @@ finalhandler@1.1.1: statuses "~1.4.0" unpipe "~1.0.0" +find-cache-dir@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-0.1.1.tgz#c8defae57c8a52a8a784f9e31c57c742e993a0b9" + dependencies: + commondir "^1.0.1" + mkdirp "^0.5.1" + pkg-dir "^1.0.0" + find-cache-dir@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-1.0.0.tgz#9288e3e9e3cc3748717d39eade17cf71fc30ee6f" @@ -2248,6 +2413,15 @@ find-up@^2.0.0, find-up@^2.1.0: dependencies: locate-path "^2.0.0" +flat-cache@^1.2.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.3.0.tgz#d3030b32b38154f4e3b7e9c709f490f7ef97c481" + dependencies: + circular-json "^0.3.1" + del "^2.0.2" + graceful-fs "^4.1.2" + write "^0.2.1" + flatten@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782" @@ -2379,6 +2553,10 @@ function-bind@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" +functional-red-black-tree@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" + gauge@~2.7.3: version "2.7.4" resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" @@ -2465,10 +2643,25 @@ global-modules-path@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/global-modules-path/-/global-modules-path-2.1.0.tgz#923ec524e8726bb0c1a4ed4b8e21e1ff80c88bbb" +globals@^11.7.0: + version "11.7.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-11.7.0.tgz#a583faa43055b1aca771914bf68258e2fc125673" + globals@^9.18.0: version "9.18.0" resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" +globby@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-5.0.0.tgz#ebd84667ca0dbb330b99bcfc68eac2bc54370e0d" + dependencies: + array-union "^1.0.1" + arrify "^1.0.0" + glob "^7.0.3" + object-assign "^4.0.1" + pify "^2.0.0" + pinkie-promise "^2.0.0" + globby@^6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c" @@ -2539,6 +2732,10 @@ has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" +has-symbols@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.0.tgz#ba1a8f1af2a0fc39650f5c850367704122063b44" + has-unicode@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" @@ -2706,7 +2903,7 @@ iconv-lite@0.4.19: version "0.4.19" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" -iconv-lite@^0.4.22, iconv-lite@^0.4.4: +iconv-lite@^0.4.17, iconv-lite@^0.4.22, iconv-lite@^0.4.4: version "0.4.23" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.23.tgz#297871f63be507adcfbfca715d0cd0eed84e9a63" dependencies: @@ -2736,6 +2933,10 @@ ignore-walk@^3.0.1: dependencies: minimatch "^3.0.4" +ignore@^4.0.2: + version "4.0.3" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.3.tgz#e2d58c9654d75b542529fa28d80ac95b29e4f467" + imagesloaded@>=3.0.0: version "4.1.4" resolved "https://registry.yarnpkg.com/imagesloaded/-/imagesloaded-4.1.4.tgz#1376efcd162bb768c34c3727ac89cc04051f3cc7" @@ -2790,6 +2991,24 @@ ini@~1.3.0: version "1.3.5" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" +inquirer@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-5.2.0.tgz#db350c2b73daca77ff1243962e9f22f099685726" + dependencies: + ansi-escapes "^3.0.0" + chalk "^2.0.0" + cli-cursor "^2.1.0" + cli-width "^2.0.0" + external-editor "^2.1.0" + figures "^2.0.0" + lodash "^4.3.0" + mute-stream "0.0.7" + run-async "^2.2.0" + rxjs "^5.5.2" + string-width "^2.1.0" + strip-ansi "^4.0.0" + through "^2.3.6" + inquirer@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-6.0.0.tgz#e8c20303ddc15bbfc2c12a6213710ccd9e1413d8" @@ -3038,6 +3257,10 @@ is-regex@^1.0.4: dependencies: has "^1.0.1" +is-resolvable@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.1.0.tgz#fb18f87ce1feb925169c9a407c19318a3206ed88" + is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" @@ -3158,6 +3381,10 @@ json-schema@0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" +json-stable-stringify-without-jsonify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" + json-stable-stringify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" @@ -3235,6 +3462,13 @@ lcid@^1.0.0: dependencies: invert-kv "^1.0.0" +levn@^0.3.0, levn@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" + dependencies: + prelude-ls "~1.1.2" + type-check "~0.3.2" + load-json-file@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" @@ -3254,6 +3488,13 @@ load-json-file@^2.0.0: pify "^2.0.0" strip-bom "^3.0.0" +loader-fs-cache@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/loader-fs-cache/-/loader-fs-cache-1.0.1.tgz#56e0bf08bd9708b26a765b68509840c8dec9fdbc" + dependencies: + find-cache-dir "^0.1.1" + mkdirp "0.5.1" + loader-runner@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.3.0.tgz#f482aea82d543e07921700d5a46ef26fdac6b8a2" @@ -3335,7 +3576,7 @@ lodash.uniq@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" -"lodash@>=3.5 <5", lodash@^4.0.0, lodash@^4.17.10, lodash@^4.17.2, lodash@^4.17.4, lodash@^4.3.0, lodash@~4.17.10: +"lodash@>=3.5 <5", lodash@^4.0.0, lodash@^4.17.10, lodash@^4.17.2, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0, lodash@~4.17.10: version "4.17.10" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" @@ -3575,7 +3816,7 @@ mixin-object@^2.0.1: for-in "^0.1.3" is-extendable "^0.1.1" -mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1: +mkdirp@0.5.1, mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" dependencies: @@ -3631,6 +3872,10 @@ nanomatch@^1.2.9: snapdragon "^0.8.1" to-regex "^3.0.1" +natural-compare@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" + needle@^2.2.0: version "2.2.1" resolved "https://registry.yarnpkg.com/needle/-/needle-2.2.1.tgz#b5e325bd3aae8c2678902fa296f729455d1d3a7d" @@ -3834,6 +4079,10 @@ object-copy@^0.1.0: define-property "^0.2.5" kind-of "^3.0.3" +object-hash@^1.1.4: + version "1.3.0" + resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-1.3.0.tgz#76d9ba6ff113cf8efc0d996102851fe6723963e2" + object-keys@^1.0.8: version "1.0.12" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.12.tgz#09c53855377575310cca62f55bb334abff7b3ed2" @@ -3893,6 +4142,17 @@ opn@^5.1.0: dependencies: is-wsl "^1.1.0" +optionator@^0.8.2: + version "0.8.2" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" + dependencies: + deep-is "~0.1.3" + fast-levenshtein "~2.0.4" + levn "~0.3.0" + prelude-ls "~1.1.2" + type-check "~0.3.2" + wordwrap "~1.0.0" + original@>=0.0.5: version "1.0.1" resolved "https://registry.yarnpkg.com/original/-/original-1.0.1.tgz#b0a53ff42ba997a8c9cd1fb5daaeb42b9d693190" @@ -4027,7 +4287,7 @@ path-is-absolute@^1.0.0, path-is-absolute@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" -path-is-inside@^1.0.1: +path-is-inside@^1.0.1, 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" @@ -4101,6 +4361,12 @@ pixrem@^4.0.0: postcss "^6.0.0" reduce-css-calc "^1.2.7" +pkg-dir@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-1.0.0.tgz#7a4b508a8d5bb2d629d447056ff4e9c9314cf3d4" + dependencies: + find-up "^1.0.0" + pkg-dir@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-2.0.0.tgz#f6d5d1109e19d63edf428e0bd57e12777615334b" @@ -4114,6 +4380,10 @@ pleeease-filters@^4.0.0: onecolor "^3.0.4" postcss "^6.0.1" +pluralize@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-7.0.0.tgz#298b89df8b93b0221dbf421ad2b1b1ea23fc6777" + portfinder@^1.0.9: version "1.0.13" resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.13.tgz#bb32ecd87c27104ae6ee44b5a3ccbf0ebb1aede9" @@ -4640,6 +4910,10 @@ postcss@^6.0, postcss@^6.0.0, postcss@^6.0.1, postcss@^6.0.11, postcss@^6.0.14, source-map "^0.6.1" supports-color "^5.4.0" +prelude-ls@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" + prepend-http@^1.0.0: version "1.0.4" resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" @@ -4660,6 +4934,10 @@ process@^0.11.10: version "0.11.10" resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" +progress@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f" + promise-inflight@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3" @@ -4930,6 +5208,16 @@ regex-not@^1.0.0, regex-not@^1.0.2: extend-shallow "^3.0.2" safe-regex "^1.1.0" +regexp.prototype.flags@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.2.0.tgz#6b30724e306a27833eeb171b66ac8890ba37e41c" + dependencies: + define-properties "^1.1.2" + +regexpp@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.0.tgz#b2a7534a85ca1b033bcf5ce9ff8e56d4e0755365" + regexpu-core@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-1.0.0.tgz#86a763f58ee4d7c2f6b102e4764050de7ed90c6b" @@ -5038,6 +5326,17 @@ require-main-filename@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" +require-uncached@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3" + dependencies: + caller-path "^0.1.0" + resolve-from "^1.0.0" + +requireindex@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/requireindex/-/requireindex-1.1.0.tgz#e5404b81557ef75db6e49c5a72004893fe03e162" + requires-port@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" @@ -5048,6 +5347,10 @@ resolve-cwd@^2.0.0: dependencies: resolve-from "^3.0.0" +resolve-from@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" + resolve-from@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-3.0.0.tgz#b22c7af7d9d6881bc8b6e653335eebcb0a188748" @@ -5112,6 +5415,12 @@ run-queue@^1.0.0, run-queue@^1.0.3: dependencies: aproba "^1.1.1" +rxjs@^5.5.2: + version "5.5.11" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.5.11.tgz#f733027ca43e3bec6b994473be4ab98ad43ced87" + dependencies: + symbol-observable "1.0.1" + rxjs@^6.1.0: version "6.2.1" resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.2.1.tgz#246cebec189a6cbc143a3ef9f62d6f4c91813ca1" @@ -5323,6 +5632,12 @@ slash@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" +slice-ansi@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-1.0.0.tgz#044f1a49d8842ff307aad6b505ed178bd950134d" + dependencies: + is-fullwidth-code-point "^2.0.0" + snapdragon-node@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" @@ -5562,6 +5877,16 @@ string-width@^1.0.1, string-width@^1.0.2: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" +string.prototype.matchall@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/string.prototype.matchall/-/string.prototype.matchall-2.0.0.tgz#2af8fe3d2d6dc53ca2a59bd376b089c3c152b3c8" + dependencies: + define-properties "^1.1.2" + es-abstract "^1.10.0" + function-bind "^1.1.1" + has-symbols "^1.0.0" + regexp.prototype.flags "^1.2.0" + string_decoder@^1.0.0, string_decoder@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" @@ -5604,7 +5929,7 @@ strip-indent@^1.0.1: dependencies: get-stdin "^4.0.1" -strip-json-comments@~2.0.1: +strip-json-comments@^2.0.1, strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" @@ -5649,6 +5974,21 @@ svgo@^0.7.0: sax "~1.2.1" whet.extend "~0.9.9" +symbol-observable@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.1.tgz#8340fc4702c3122df5d22288f88283f513d3fdd4" + +table@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/table/-/table-4.0.3.tgz#00b5e2b602f1794b9acaf9ca908a76386a7813bc" + dependencies: + ajv "^6.0.1" + ajv-keywords "^3.0.0" + chalk "^2.1.0" + lodash "^4.17.4" + slice-ansi "1.0.0" + string-width "^2.1.1" + tapable@^0.2.7: version "0.2.8" resolved "https://registry.yarnpkg.com/tapable/-/tapable-0.2.8.tgz#99372a5c999bf2df160afc0d74bed4f47948cd22" @@ -5677,6 +6017,10 @@ tar@^4: safe-buffer "^5.1.2" yallist "^3.0.2" +text-table@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" + through2@^2.0.0: version "2.0.3" resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be" @@ -5776,6 +6120,12 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" +type-check@~0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" + dependencies: + prelude-ls "~1.1.2" + type-is@~1.6.15, type-is@~1.6.16: version "1.6.16" resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.16.tgz#f89ce341541c672b25ee7ae3c73dee3b2be50194" @@ -6126,6 +6476,10 @@ wordwrap@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" +wordwrap@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" + worker-farm@^1.5.2: version "1.6.0" resolved "https://registry.yarnpkg.com/worker-farm/-/worker-farm-1.6.0.tgz#aecc405976fab5a95526180846f0dba288f3a4a0" @@ -6143,6 +6497,12 @@ wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" +write@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/write/-/write-0.2.1.tgz#5fc03828e264cea3fe91455476f7a3c566cb0757" + dependencies: + mkdirp "^0.5.1" + xtend@^4.0.0, xtend@~4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" From f72b32b27b93b69e99330c1dfefebae9280dff00 Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 4 Aug 2018 14:36:39 -0500 Subject: [PATCH 2/2] Fix eslint warnings. --- app/javascript/packs/application.js | 3 +- .../src/javascripts/artist_commentaries.js | 9 +-- app/javascript/src/javascripts/artists.js | 8 +-- .../src/javascripts/autocomplete.js.erb | 61 +++++++++-------- app/javascript/src/javascripts/blacklists.js | 4 +- app/javascript/src/javascripts/comments.js | 2 +- app/javascript/src/javascripts/common.js | 2 +- app/javascript/src/javascripts/cookie.js | 10 +-- .../src/javascripts/favorite_groups.js | 2 +- app/javascript/src/javascripts/favorites.js | 4 +- app/javascript/src/javascripts/forum_posts.js | 4 +- .../src/javascripts/janitor_trials.js | 2 +- app/javascript/src/javascripts/mod_queue.js | 2 +- .../src/javascripts/news_updates.js | 4 +- app/javascript/src/javascripts/notes.js | 43 ++++++------ app/javascript/src/javascripts/pools.js | 4 +- .../src/javascripts/post_mode_menu.js | 11 ++-- .../src/javascripts/post_popular.js | 2 +- .../src/javascripts/post_tooltips.js.erb | 2 +- app/javascript/src/javascripts/posts.js.erb | 66 ++++++++++--------- .../src/javascripts/related_tag.js.erb | 29 ++++---- .../src/javascripts/saved_searches.js | 2 +- app/javascript/src/javascripts/shortcuts.js | 4 +- app/javascript/src/javascripts/tag_script.js | 8 +-- app/javascript/src/javascripts/ugoira.js | 2 +- app/javascript/src/javascripts/uploads.js | 7 +- app/javascript/src/javascripts/utility.js | 7 +- 27 files changed, 149 insertions(+), 155 deletions(-) diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 24201afe5..37ff9664b 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -1,4 +1,5 @@ /* eslint no-console:0 */ +/* global require */ function importAll(r) { r.keys().forEach(r); @@ -36,4 +37,4 @@ export { default as Dtext } from '../src/javascripts/dtext.js'; export { default as Note } from '../src/javascripts/notes.js'; export { default as PostModeMenu } from '../src/javascripts/post_mode_menu.js'; export { default as Utility } from '../src/javascripts/utility.js'; -export { default as Ugoira } from '../src/javascripts/ugoira.js'; \ No newline at end of file +export { default as Ugoira } from '../src/javascripts/ugoira.js'; diff --git a/app/javascript/src/javascripts/artist_commentaries.js b/app/javascript/src/javascripts/artist_commentaries.js index e111dba67..70f20af86 100644 --- a/app/javascript/src/javascripts/artist_commentaries.js +++ b/app/javascript/src/javascripts/artist_commentaries.js @@ -63,15 +63,16 @@ ArtistCommentary.initialize_edit_commentary_dialog = function() { } ArtistCommentary.fetch_commentary = function() { + var commentary = ""; Utility.notice("Fetching artist commentary..."); var type = $('#fetch-commentary select[name="commentary_source_type"]').val(); if (type === "Source") { var source = $('#fetch-commentary input[name="commentary_source"]').val(); - var commentary = ArtistCommentary.from_source(source); + commentary = ArtistCommentary.from_source(source); } else if (type === "Post") { var id = $('#fetch-commentary input[name="commentary_post_id"]').val(); - var commentary = ArtistCommentary.from_post_id(id); + commentary = ArtistCommentary.from_post_id(id); } commentary.then(ArtistCommentary.fill_commentary).then(function (success) { @@ -120,13 +121,13 @@ ArtistCommentary.merge_commentaries = function(description, commentary) { var normalized_source = $("#image-container").data().normalizedSource; if ((commentary.original_description && description) && - (commentary.original_description != description)) { + (commentary.original_description !== description)) { return description + "\n\n[tn]\nSource: " + normalized_source + "\n[/tn]" + "\n\nh6. " + (commentary.original_title || "Untitled") + "\n\n" + commentary.original_description + "\n\n[tn]\nSource: " + commentary.source + "\n[/tn]"; - } else if (commentary.source != post_source) { + } else if (commentary.source !== post_source) { return commentary.original_description + "\n\n[tn]\nSource: " + commentary.source + "\n[/tn]"; } else { return commentary.original_description || description; diff --git a/app/javascript/src/javascripts/artists.js b/app/javascript/src/javascripts/artists.js index 88dd0068e..83a8784df 100644 --- a/app/javascript/src/javascripts/artists.js +++ b/app/javascript/src/javascripts/artists.js @@ -14,10 +14,10 @@ Artist.initialize_check_name = function() { if ($("#artist_name").val().length > 0) { $("#check-name-result").html(""); - $.getJSON("/artists?search[name]=" + escape($("#artist_name").val()), function(data) { - if (data.length === 0) { - $.getJSON("/wiki_pages/" + escape($("#artist_name").val()), function(data) { - if (data !== null) { + $.getJSON("/artists?search[name]=" + escape($("#artist_name").val()), function(artists) { + if (artists.length === 0) { + $.getJSON("/wiki_pages/" + escape($("#artist_name").val()), function(wiki_pages) { + if (wiki_pages !== null) { $("#check-name-result").html("A wiki page with this name already exists. You must either move the wiki page or pick another artist name.") } }); diff --git a/app/javascript/src/javascripts/autocomplete.js.erb b/app/javascript/src/javascripts/autocomplete.js.erb index 11a0fcb33..bd67ac744 100644 --- a/app/javascript/src/javascripts/autocomplete.js.erb +++ b/app/javascript/src/javascripts/autocomplete.js.erb @@ -3,9 +3,12 @@ import SavedSearch from './saved_searches' let Autocomplete = {}; -Autocomplete.AUTOCOMPLETE_VERSION = 1; -Autocomplete.PREFIXES = /^(-|~|<%= TagCategory.mapping.keys.map {|category| category + ':'}.join('|') %>)(.*)$/i; -Autocomplete.METATAGS = /^(<%= Tag::METATAGS %>):(.*)$/i; +Autocomplete.METATAGS = <%= Tag::METATAGS.to_json.html_safe %>; +Autocomplete.TAG_CATEGORIES = <%= TagCategory.mapping.to_json.html_safe %>; + +Autocomplete.TAG_PREFIXES = "-|~|" + Object.keys(Autocomplete.TAG_CATEGORIES).map(category => category + ":").join("|"); +Autocomplete.TAG_PREFIXES_REGEX = new RegExp("^(" + Autocomplete.TAG_PREFIXES + ")(.*)$", "i"); +Autocomplete.METATAGS_REGEX = new RegExp("^(" + Autocomplete.METATAGS + "):(.*)$", "i"); Autocomplete.initialize_all = function() { if (Utility.meta("enable-auto-complete") === "true") { @@ -42,16 +45,15 @@ Autocomplete.initialize_mention_autocomplete = function($fields) { }, source: function(req, resp) { var cursor = this.element.get(0).selectionStart; - var i; var name = null; - for (i=cursor; i>=1; --i) { - if (req.term[i-1] === " ") { + for (var i = cursor; i >= 1; --i) { + if (req.term[i - 1] === " ") { return; } - if (req.term[i-1] === "@") { - if (i == 1 || /[ \r\n]/.test(req.term[i-2])) { + if (req.term[i - 1] === "@") { + if (i === 1 || /[ \r\n]/.test(req.term[i - 2])) { name = req.term.substring(i, cursor); break; } else { @@ -63,8 +65,6 @@ Autocomplete.initialize_mention_autocomplete = function($fields) { if (name) { Autocomplete.user_source(name, resp, "@"); } - - return; } }); } @@ -99,7 +99,7 @@ Autocomplete.initialize_tag_autocomplete = function() { return; } - switch(metatag) { + switch (metatag) { case "md5": case "width": case "height": @@ -117,7 +117,7 @@ Autocomplete.initialize_tag_autocomplete = function() { case "pixiv_id": case "pixiv": <% TagCategory.short_name_list.each do |category| %> - case "<%= category %>tags": + case "<%= category %>tags": // eslint-disable-line <% end %> resp([]); return; @@ -194,7 +194,7 @@ Autocomplete.initialize_artist_autocomplete = function($fields) { type: "tag", label: artist.name.replace(/_/g, " "), value: artist.name, - category: <%= Tag.categories.artist %>, + category: Autocomplete.TAG_CATEGORIES.artist, }; })); } @@ -250,9 +250,7 @@ Autocomplete.normal_source = function(term, resp) { return window.Danbooru.Autocomplete.normal_source(term, resp); } - var key = "ac-" + term.replace(/\./g,'\uFFFF'); - - $.ajax({ + return $.ajax({ url: "/tags/autocomplete.json", data: { "search[name_matches]": term, @@ -288,12 +286,14 @@ Autocomplete.parse_query = function(text, caret) { return {}; } - if (match = term.match(Autocomplete.PREFIXES)) { + match = term.match(Autocomplete.TAG_PREFIXES_REGEX); + if (match) { metatag = match[1].toLowerCase(); term = match[2]; } - - if (match = term.match(Autocomplete.METATAGS)) { + + match = term.match(Autocomplete.METATAGS_REGEX); + if (match) { metatag = match[1].toLowerCase(); term = match[2]; } @@ -307,8 +307,7 @@ Autocomplete.insert_completion = function(input, completion) { var before_caret_text = input.value.substring(0, input.selectionStart).trim(); var after_caret_text = input.value.substring(input.selectionStart).trim(); - var prefixes = "-|~|" + "<%= TagCategory.mapping.keys.map {|category| category + ':'}.join('|') %>"; - var regexp = new RegExp("(" + prefixes + ")?\\S+$", "g"); + var regexp = new RegExp("(" + Autocomplete.TAG_PREFIXES + ")?\\S+$", "g"); before_caret_text = before_caret_text.replace(regexp, "$1") + completion + " "; input.value = before_caret_text + after_caret_text; @@ -357,12 +356,12 @@ Autocomplete.render_item = function(list, item) { } if (item.post_count !== undefined) { - var count; - if (item.post_count >= 1000) { - count = Math.floor(item.post_count / 1000) + "k"; - } else { - count = item.post_count; + var count = item.post_count; + + if (count >= 1000) { + count = Math.floor(count / 1000) + "k"; } + var $post_count = $("").addClass("post-count").css("float", "right").text(count); $link.append($post_count); } @@ -440,7 +439,7 @@ Autocomplete.user_source = function(term, resp, metatag) { return window.Danbooru.Autocomplete.user_source(term, resp, metatag); } - $.ajax({ + return $.ajax({ url: "/users.json", data: { "search[order]": "post_upload_count", @@ -450,8 +449,8 @@ Autocomplete.user_source = function(term, resp, metatag) { }, method: "get", success: function(data) { - var prefix; - var display_name; + var prefix = ""; + var display_name = null; if (metatag === "@") { prefix = "@"; @@ -478,7 +477,7 @@ Autocomplete.pool_source = function(term, resp, metatag) { return window.Danbooru.Autocomplete.pool_source(term, resp, metatag); } - $.ajax({ + return $.ajax({ url: "/pools.json", data: { "search[order]": "post_count", @@ -505,7 +504,7 @@ Autocomplete.favorite_group_source = function(term, resp, metatag) { return window.Danbooru.Autocomplete.favorite_group_source(term, resp, metatag); } - $.ajax({ + return $.ajax({ url: "/favorite_groups.json", data: { "search[name_matches]": term, diff --git a/app/javascript/src/javascripts/blacklists.js b/app/javascript/src/javascripts/blacklists.js index a834e0cdc..9fbd08727 100644 --- a/app/javascript/src/javascripts/blacklists.js +++ b/app/javascript/src/javascripts/blacklists.js @@ -112,7 +112,7 @@ Blacklist.apply = function() { $.each(this.posts(), function(i, post) { var post_count = 0; - $.each(Blacklist.entries, function(i, entry) { + $.each(Blacklist.entries, function(j, entry) { if (Blacklist.post_match(post, entry)) { entry.hits += 1; count += 1; @@ -192,7 +192,7 @@ Blacklist.initialize_all = function() { } $(document).ready(function() { - if ($("#blacklist-box").length == 0) { + if ($("#blacklist-box").length === 0) { return; } diff --git a/app/javascript/src/javascripts/comments.js b/app/javascript/src/javascripts/comments.js index 5cb4327d7..544eaad91 100644 --- a/app/javascript/src/javascripts/comments.js +++ b/app/javascript/src/javascripts/comments.js @@ -39,7 +39,7 @@ Comment.quote = function(e) { var $link = $(e.target); var $div = $link.closest("div.comments-for-post").find(".new-comment"); var $textarea = $div.find("textarea"); - var msg = data["quoted_response"]; + var msg = data.quoted_response; if ($textarea.val().length > 0) { msg = $textarea.val() + "\n\n" + msg; } diff --git a/app/javascript/src/javascripts/common.js b/app/javascript/src/javascripts/common.js index 38c8dc252..c6428f0e4 100644 --- a/app/javascript/src/javascripts/common.js +++ b/app/javascript/src/javascripts/common.js @@ -45,6 +45,6 @@ $(function() { }); }); -global.submitInvisibleRecaptchaForm = function () { +window.submitInvisibleRecaptchaForm = function () { document.getElementById("signup-form").submit(); } diff --git a/app/javascript/src/javascripts/cookie.js b/app/javascript/src/javascripts/cookie.js index 3018d4112..20a5e4b0b 100644 --- a/app/javascript/src/javascripts/cookie.js +++ b/app/javascript/src/javascripts/cookie.js @@ -31,11 +31,11 @@ Cookie.raw_get = function(name) { for (var i = 0; i < ca.length; ++i) { var c = ca[i]; - while (c.charAt(0) == " ") { + while (c.charAt(0) === " ") { c = c.substring(1, c.length); } - if (c.indexOf(nameEq) == 0) { + if (c.indexOf(nameEq) === 0) { return c.substring(nameEq.length, c.length); } } @@ -56,9 +56,9 @@ Cookie.unescape = function(val) { } Cookie.initialize = function() { - if (this.get("hide-upgrade-account") != "1") { - $("#upgrade-account").show(); - } + if (this.get("hide-upgrade-account") !== "1") { + $("#upgrade-account").show(); + } } $(function() { diff --git a/app/javascript/src/javascripts/favorite_groups.js b/app/javascript/src/javascripts/favorite_groups.js index 16c0b06ee..5445ed1e8 100644 --- a/app/javascript/src/javascripts/favorite_groups.js +++ b/app/javascript/src/javascripts/favorite_groups.js @@ -21,7 +21,7 @@ FavoriteGroup.initialize_add_to_favgroup_dialog = function() { }); var open_favgroup_dialog = function(e) { - if (Utility.meta("current-user-id") == "") { // anonymous + if (Utility.meta("current-user-id") === "") { // anonymous return; } diff --git a/app/javascript/src/javascripts/favorites.js b/app/javascript/src/javascripts/favorites.js index 96f23d8eb..ef6d2d44a 100644 --- a/app/javascript/src/javascripts/favorites.js +++ b/app/javascript/src/javascripts/favorites.js @@ -11,14 +11,14 @@ Favorite.initialize_all = function() { Favorite.hide_or_show_add_to_favorites_link = function() { var current_user_id = Utility.meta("current-user-id"); - if (current_user_id == "") { + if (current_user_id === "") { $("#add-to-favorites").hide(); $("#remove-from-favorites").hide(); $("#add-fav-button").hide(); $("#remove-fav-button").hide(); return; } - if ($("#image-container").length && $("#image-container").data("is-favorited") == true) { + if ($("#image-container").length && $("#image-container").data("is-favorited") === true) { $("#add-to-favorites").hide(); $("#add-fav-button").hide(); } else { diff --git a/app/javascript/src/javascripts/forum_posts.js b/app/javascript/src/javascripts/forum_posts.js index f33b75aed..ec855934d 100644 --- a/app/javascript/src/javascripts/forum_posts.js +++ b/app/javascript/src/javascripts/forum_posts.js @@ -3,7 +3,7 @@ import Utility from './utility' let ForumPost = {}; ForumPost.initialize_all = function() { - if ($("#c-forum-topics #a-show,#c-forum-posts #a-show").length) {; + if ($("#c-forum-topics #a-show,#c-forum-posts #a-show").length) { this.initialize_edit_links(); Utility.keydown("e", "edit", function(e) { @@ -44,4 +44,4 @@ $(document).ready(function() { ForumPost.initialize_all(); }); -export default ForumPost \ No newline at end of file +export default ForumPost diff --git a/app/javascript/src/javascripts/janitor_trials.js b/app/javascript/src/javascripts/janitor_trials.js index 1208dc3df..96186ecc0 100644 --- a/app/javascript/src/javascripts/janitor_trials.js +++ b/app/javascript/src/javascripts/janitor_trials.js @@ -26,4 +26,4 @@ $(document).ready(function() { JanitorTrials.initialize_all(); }); -export default JanitorTrials \ No newline at end of file +export default JanitorTrials diff --git a/app/javascript/src/javascripts/mod_queue.js b/app/javascript/src/javascripts/mod_queue.js index ad3bf6b37..3752b806c 100644 --- a/app/javascript/src/javascripts/mod_queue.js +++ b/app/javascript/src/javascripts/mod_queue.js @@ -66,4 +66,4 @@ $(function() { } }); -export default ModQueue \ No newline at end of file +export default ModQueue diff --git a/app/javascript/src/javascripts/news_updates.js b/app/javascript/src/javascripts/news_updates.js index e601a43b4..950db3684 100644 --- a/app/javascript/src/javascripts/news_updates.js +++ b/app/javascript/src/javascripts/news_updates.js @@ -5,7 +5,7 @@ let NewsUpdate = {}; NewsUpdate.initialize = function() { var key = $("#news-updates").data("id"); - if (Cookie.get("news-ticker") == key) { + if (Cookie.get("news-ticker") === key) { $("#news-updates").hide(); } else { $("#news-updates").show(); @@ -27,4 +27,4 @@ $(function() { NewsUpdate.initialize(); }); -export default NewsUpdate \ No newline at end of file +export default NewsUpdate diff --git a/app/javascript/src/javascripts/notes.js b/app/javascript/src/javascripts/notes.js index 3a2d5b190..f4ce1d95d 100644 --- a/app/javascript/src/javascripts/notes.js +++ b/app/javascript/src/javascripts/notes.js @@ -113,18 +113,18 @@ let Note = { return; } + var $this = $(this); var $note_box_inner = $(e.currentTarget); + if (e.type === "mouseover") { Note.Body.show($note_box_inner.data("id")); if (Note.editing) { - var $this = $(this); $this.resizable("enable"); $this.draggable("enable"); } } else if (e.type === "mouseout") { Note.Body.hide($note_box_inner.data("id")); if (Note.editing) { - var $this = $(this); $this.resizable("disable"); $this.draggable("disable"); } @@ -191,7 +191,7 @@ let Note = { return; } // Hide notes while rescaling, to prevent unnecessary reflowing - var was_visible = container.style.display != 'none'; + var was_visible = container.style.display !== 'none'; if (was_visible) { container.style.display = 'none'; } @@ -239,14 +239,6 @@ let Note = { var $image = $("#image"); var doc_width = $image.offset().left + $image.width(); - /*while ($note_body[0].clientHeight < $note_body[0].scrollHeight) { - $note_body.css({height: $note_body.height() + 5}); - } - - while ($note_body[0].clientWidth < $note_body[0].scrollWidth) { - $note_body.css({width: $note_body.width() + 5}); - }*/ - if ($note_body.offset().left + $note_body.width() > doc_width) { $note_body.css({ left: $note_body.position().left - 10 - ($note_body.offset().left + $note_body.width() - doc_width) @@ -286,10 +278,13 @@ let Note = { var golden_ratio = 1.6180339887; var last = 0; var x = 0; + var lo = 0; + var hi = 0; if ((w / h) < golden_ratio) { - var lo = 140; - var hi = 400; + lo = 140; + hi = 400; + do { last = w; x = (lo + hi) / 2; @@ -304,8 +299,8 @@ let Note = { } } while ((lo < hi) && (w > last)); } else if ($note_body[0].scrollWidth <= $note_body.width()) { - var lo = 20; - var hi = w; + lo = 20; + hi = w; do { x = (lo + hi) / 2; @@ -466,14 +461,16 @@ let Note = { }, success_handler: function(data, status, xhr) { + var $note_box = null; + if (data.html_id) { // new note var $note_body = Note.Body.find(data.html_id); - var $note_box = Note.Box.find(data.html_id); + $note_box = Note.Box.find(data.html_id); $note_body.data("id", String(data.id)).attr("data-id", data.id); $note_box.data("id", String(data.id)).attr("data-id", data.id); $note_box.find(".note-box-inner-border").removeClass("unsaved"); } else { - var $note_box = Note.Box.find(data.id); + $note_box = Note.Box.find(data.id); $note_box.find(".note-box-inner-border").removeClass("unsaved"); } }, @@ -574,7 +571,7 @@ let Note = { start: function(e) { e.preventDefault(); - if (Utility.meta("current-user-id") == "") { + if (Utility.meta("current-user-id") === "") { Utility.notice("You must be logged in to edit notes"); return; } @@ -654,7 +651,7 @@ let Note = { var offset = $image.offset(); var limitX1 = $image.width() - Note.TranslationMode.Drag.dragStartX + offset.left - 1; var limitX2 = offset.left - Note.TranslationMode.Drag.dragStartX; - var limitY1 = $image.height()- Note.TranslationMode.Drag.dragStartY + offset.top - 1; + var limitY1 = $image.height() - Note.TranslationMode.Drag.dragStartY + offset.top - 1; var limitY2 = offset.top - Note.TranslationMode.Drag.dragStartY; if (Note.TranslationMode.Drag.dragDistanceX > limitX1) { @@ -709,8 +706,8 @@ let Note = { $(window).off("mousemove"); if (Note.TranslationMode.Drag.dragging) { - $('#note-preview').css({display:'none'}); - Note.TranslationMode.create_note(e, Note.TranslationMode.Drag.x, Note.TranslationMode.Drag.y, Note.TranslationMode.Drag.w-1, Note.TranslationMode.Drag.h-1); + $('#note-preview').css({ display: 'none' }); + Note.TranslationMode.create_note(e, Note.TranslationMode.Drag.x, Note.TranslationMode.Drag.y, Note.TranslationMode.Drag.w - 1, Note.TranslationMode.Drag.h - 1); Note.TranslationMode.Drag.dragging = false; /* border of the note is pixel-perfect on the preview border */ } else { /* no dragging -> toggle display of notes */ Note.Box.toggle_all(); @@ -796,7 +793,7 @@ let Note = { }, initialize_all: function() { - if ($("#c-posts #a-show #image").length == 0 || $("video#image").length) { + if ($("#c-posts #a-show #image").length === 0 || $("video#image").length) { return; } @@ -809,7 +806,7 @@ let Note = { }, initialize_shortcuts: function() { - if ($("#note-locked-notice").length == 0) { + if ($("#note-locked-notice").length === 0) { $("#translate").click(Note.TranslationMode.toggle); Utility.keydown("n", "translation_mode", Note.TranslationMode.toggle); } diff --git a/app/javascript/src/javascripts/pools.js b/app/javascript/src/javascripts/pools.js index 521682b9a..67fe3986a 100644 --- a/app/javascript/src/javascripts/pools.js +++ b/app/javascript/src/javascripts/pools.js @@ -52,7 +52,7 @@ Pool.initialize_simple_edit = function() { $.ajax({ type: "put", url: e.target.action, - data: $("#sortable").sortable("serialize") + "&" + $(e.target).serialize() + data: $("#sortable").sortable("serialize") + "&" + $(e.target).serialize() }); e.preventDefault(); }); @@ -62,4 +62,4 @@ $(document).ready(function() { Pool.initialize_all(); }); -export default Pool \ No newline at end of file +export default Pool diff --git a/app/javascript/src/javascripts/post_mode_menu.js b/app/javascript/src/javascripts/post_mode_menu.js index 22501f230..85b6c8c4f 100644 --- a/app/javascript/src/javascripts/post_mode_menu.js +++ b/app/javascript/src/javascripts/post_mode_menu.js @@ -22,20 +22,19 @@ PostModeMenu.initialize_shortcuts = function() { } PostModeMenu.show_notice = function(i) { - Utility.notice("Switched to tag script #" + i + ". To switch tag scripts, use the number keys."); + Utility.notice("Switched to tag script #" + i + ". To switch tag scripts, use the number keys."); } PostModeMenu.change_tag_script = function(e) { if ($("#mode-box select").val() === "tag-script") { var old_tag_script_id = Cookie.get("current_tag_script_id") || "1"; - var old_tag_script = $("#tag-script-field").val(); - + var new_tag_script_id = String.fromCharCode(e.which); var new_tag_script = Cookie.get("tag-script-" + new_tag_script_id); - + $("#tag-script-field").val(new_tag_script); Cookie.put("current_tag_script_id", new_tag_script_id); - if (old_tag_script_id != new_tag_script_id) { + if (old_tag_script_id !== new_tag_script_id) { PostModeMenu.show_notice(new_tag_script_id); } @@ -145,7 +144,7 @@ PostModeMenu.open_edit = function(post_id) { $("#post_tag_string").val($post.data("tags") + " ").focus().selectEnd(); /* Set height of tag edit box to fit content. */ - $("#post_tag_string").height(80); // min height: 80px. + $("#post_tag_string").height(80); // min height: 80px. var padding = $("#post_tag_string").innerHeight() - $("#post_tag_string").height(); var height = $("#post_tag_string").prop("scrollHeight") - padding; $("#post_tag_string").height(height); diff --git a/app/javascript/src/javascripts/post_popular.js b/app/javascript/src/javascripts/post_popular.js index 3225195f4..a783adb3b 100644 --- a/app/javascript/src/javascripts/post_popular.js +++ b/app/javascript/src/javascripts/post_popular.js @@ -35,4 +35,4 @@ $(document).ready(function() { PostPopular.initialize_all(); }); -export default PostPopular \ No newline at end of file +export default PostPopular diff --git a/app/javascript/src/javascripts/post_tooltips.js.erb b/app/javascript/src/javascripts/post_tooltips.js.erb index 513d75085..01da70720 100644 --- a/app/javascript/src/javascripts/post_tooltips.js.erb +++ b/app/javascript/src/javascripts/post_tooltips.js.erb @@ -133,4 +133,4 @@ PostTooltip.on_disable_tooltips = function (event) { $(document).ready(PostTooltip.initialize); -export default PostTooltip \ No newline at end of file +export default PostTooltip diff --git a/app/javascript/src/javascripts/posts.js.erb b/app/javascript/src/javascripts/posts.js.erb index 3c506747a..8c8f409f8 100644 --- a/app/javascript/src/javascripts/posts.js.erb +++ b/app/javascript/src/javascripts/posts.js.erb @@ -1,3 +1,5 @@ +/* global addthis */ + import Utility from './utility' import Hammer from 'hammerjs' import RelatedTag from './related_tag.js.erb' @@ -79,7 +81,7 @@ Post.initialize_gestures = function() { } } -Post.initialize_edit_dialog = function(e) { +Post.initialize_edit_dialog = function() { $("#open-edit-dialog").button().show().click(function(e) { $(window).scrollTop($("#image").offset().top); Post.open_edit_dialog(); @@ -104,11 +106,11 @@ Post.open_edit_dialog = function() { dialog.dialog({ title: "Edit tags", width: $(window).width() * 0.6, - position: { - my: "right", - at: "right-20", - of: window - }, + position: { + my: "right", + at: "right-20", + of: window + }, drag: function(e, ui) { if (Utility.meta("enable-auto-complete") === "true") { $tag_string.data("uiAutocomplete").close(); @@ -128,15 +130,15 @@ Post.open_edit_dialog = function() { if (dialog_widget.css("position") === "absolute") { pos.left -= $(window).scrollLeft(); pos.top -= $(window).scrollTop(); - dialog_widget.offset(pos).css({position:"fixed"}); - dialog.dialog("option", "resize", function() { dialog_widget.css({position:"fixed"}); }); + dialog_widget.offset(pos).css({ position: "fixed" }); + dialog.dialog("option", "resize", function() { dialog_widget.css({ position: "fixed" }); }); pin_button.button("option", "icons", {primary: "ui-icon-pin-s"}); } else { pos.left += $(window).scrollLeft(); pos.top += $(window).scrollTop(); - dialog_widget.offset(pos).css({position:"absolute"}); - dialog.dialog("option", "resize", function() {}); + dialog_widget.offset(pos).css({ position: "absolute" }); + dialog.dialog("option", "resize", function() { /* do nothing */ }); pin_button.button("option", "icons", {primary: "ui-icon-pin-w"}); } @@ -144,8 +146,7 @@ Post.open_edit_dialog = function() { dialog.parent().mouseout(function(e) { dialog.parent().css({"opacity": 0.6, "transition": "opacity .2s ease"}); - }) - .mouseover(function(e) { + }).mouseover(function(e) { dialog.parent().css({"opacity": 1}); }); @@ -182,15 +183,17 @@ Post.swipe_prev = function(e) { } Post.nav_prev = function(e) { + var href = ""; + if ($("#search-seq-nav").length) { - var href = $("#search-seq-nav a[rel~=prev]").attr("href"); + href = $("#search-seq-nav a[rel~=prev]").attr("href"); if (href) { location.href = href; } } else if ($(".paginator a[rel~=prev]").length) { location.href = $("a[rel~=prev]").attr("href"); } else { - var href = $("#pool-nav a.active[rel~=prev], #favgroup-nav a.active[rel~=prev]").attr("href"); + href = $("#pool-nav a.active[rel~=prev], #favgroup-nav a.active[rel~=prev]").attr("href"); if (href) { location.href = href; } @@ -200,13 +203,15 @@ Post.nav_prev = function(e) { } Post.nav_next = function(e) { + var href = ""; + if ($("#search-seq-nav").length) { - var href = $("#search-seq-nav a[rel~=next]").attr("href"); + href = $("#search-seq-nav a[rel~=next]").attr("href"); location.href = href; } else if ($(".paginator a[rel~=next]").length) { location.href = $(".paginator a[rel~=next]").attr("href"); } else { - var href = $("#pool-nav a.active[rel~=next], #favgroup-nav a.active[rel~=next]").attr("href"); + href = $("#pool-nav a.active[rel~=next], #favgroup-nav a.active[rel~=next]").attr("href"); if (href) { location.href = href; } @@ -301,8 +306,7 @@ Post.toggle_relationship_preview = function(preview, preview_link) { if (preview.is(":visible")) { preview_link.html("« hide"); Cookie.put("show-relationship-previews", "1"); - } - else { + } else { preview_link.html("show »"); Cookie.put("show-relationship-previews", "0"); } @@ -343,7 +347,7 @@ Post.expand_image = function(e) { $image.attr("src", $link.attr("href")); $image.css("opacity", "0.25"); $image.width($image.data("original-width")); - $image.height($image.data("original-height")); + $image.height($image.data("original-height")); $image.on("load", function() { $image.css("opacity", "1"); $notice.hide(); @@ -384,14 +388,16 @@ Post.initialize_post_image_resize_links = function() { } Post.resize_image_to_window = function($img) { + var sidebar_width = 0; + var client_width = 0; + if (($img.data("scale-factor") === 1) || ($img.data("scale-factor") === undefined)) { if ($(window).width() > 660) { - var sidebar_width = $("#sidebar").width() || 0; - var client_width = $(window).width() - sidebar_width - 75; + sidebar_width = $("#sidebar").width() || 0; + client_width = $(window).width() - sidebar_width - 75; } else { - var client_width = $(window).width() - 2; + client_width = $(window).width() - 2; } - var client_height = $(window).height(); if ($img.width() > client_width) { var ratio = client_width / $img.data("original-width"); @@ -473,7 +479,7 @@ Post.initialize_post_sections = function() { $("#share").show(); addthis.init(); $("#recommended").hide(); - } + } $("#post-sections li").removeClass("active"); $(e.target).parent("li").addClass("active"); @@ -525,7 +531,7 @@ Post.vote = function(score, id) { $(window).trigger("danbooru:notice", "Voting..."); $.post("/posts/" + id + "/votes.js", { - score: score + score: score }); } @@ -583,12 +589,10 @@ Post.approve = function(post_id) { Post.favorite = function (e) { if ($("#add-to-favorites").is(":visible")) { $("#add-to-favorites")[0].click(); + } else if (Utility.meta("current-user-id") === "") { + $(window).trigger("danbooru:notice", "You must be logged in to favorite posts"); } else { - if (Utility.meta("current-user-id") == "") { - $(window).trigger("danbooru:notice", "You must be logged in to favorite posts"); - } else { - $(window).trigger("danbooru:notice", "You have already favorited this post"); - } + $(window).trigger("danbooru:notice", "You have already favorited this post"); } }; @@ -690,4 +694,4 @@ $(document).ready(function() { Post.initialize_all(); }); -export default Post \ No newline at end of file +export default Post diff --git a/app/javascript/src/javascripts/related_tag.js.erb b/app/javascript/src/javascripts/related_tag.js.erb index d627881a3..af37bd629 100644 --- a/app/javascript/src/javascripts/related_tag.js.erb +++ b/app/javascript/src/javascripts/related_tag.js.erb @@ -15,18 +15,14 @@ RelatedTag.initialize_all = function() { RelatedTag.initialize_buttons = function() { this.common_bind("#related-tags-button", ""); <% TagCategory.related_button_list.each do |category| %> - RelatedTag.common_bind("#related-<%= category %>-button", "<%= category %>"); + RelatedTag.common_bind("#related-<%= category %>-button", "<%= category %>"); // eslint-disable-line indent <% end %> $("#find-artist-button").click(RelatedTag.find_artist); } RelatedTag.tags_include = function(name) { var current = $("#upload_tag_string,#post_tag_string").val().toLowerCase().match(/\S+/g) || []; - if ($.inArray(name.toLowerCase(), current) > -1) { - return true; - } else { - return false; - } + return $.inArray(name.toLowerCase(), current) > -1; } RelatedTag.common_bind = function(button_name, category) { @@ -89,7 +85,7 @@ RelatedTag.current_tag = function() { } b++; - return string.slice(a, b); + return string.slice(a, b); } RelatedTag.process_response = function(data) { @@ -130,7 +126,7 @@ RelatedTag.build_all = function() { if (wiki_page_tags.length) { $dest.append(RelatedTag.build_html("wiki:" + query, wiki_page_tags, "wiki")); } - $.each(other_wikis, function(i,wiki) { + $.each(other_wikis, function(i, wiki) { $dest.append(RelatedTag.build_html("wiki:" + wiki.title, wiki.wiki_page_tags, "otherwiki" + i.toString())); }); if (RelatedTag.recent_artists) { @@ -156,7 +152,7 @@ RelatedTag.build_all = function() { tags.push([artist.name, 1]); }); } - $dest.append(RelatedTag.build_html("artist", tags, "artist", true)); + $dest.append(RelatedTag.build_html("artist", tags, "artist", true)); } } @@ -231,9 +227,10 @@ RelatedTag.build_html = function(query, related_tags, name, is_wide_column) { ); } else { var text = tag[0]; + var desc = ""; if (text.match(/^ -http/)) { text = text.substring(1, 1000); - var desc = text.replace(/^-https?:\/\//, ""); + desc = text.replace(/^-https?:\/\//, ""); if (desc.length > 30) { desc = desc.substring(0, 30) + "..."; } @@ -244,7 +241,7 @@ RelatedTag.build_html = function(query, related_tags, name, is_wide_column) { ); } else if (text.match(/^ http/)) { text = text.substring(1, 1000); - var desc = text.replace(/^https?:\/\//, ""); + desc = text.replace(/^https?:\/\//, ""); if (desc.length > 30) { desc = desc.substring(0, 30) + "..."; } @@ -284,7 +281,7 @@ RelatedTag.toggle_tag = function(e) { RelatedTag.process_artist(RelatedTag.recent_artist); } - //The timeout is needed on Chrome since it will clobber the field attribute otherwise + // The timeout is needed on Chrome since it will clobber the field attribute otherwise setTimeout(function () { $field.prop('selectionStart', $field.val().length);}, 100); e.preventDefault(); } @@ -295,7 +292,7 @@ RelatedTag.find_artist = function(e) { var referer_url = $("#upload_referer_url"); $.get("/artists/finder.json", {"url": url.val(), "referer_url": referer_url.val()}, RelatedTag.process_artist); if (e) { - e.preventDefault(); + e.preventDefault(); } } @@ -328,12 +325,12 @@ RelatedTag.hide = function() { RelatedTag.disable_artist_url = function(e) { var url = e.currentTarget.href; $.each(RelatedTag.recent_artists[0].sorted_urls, function(k, v) { - if (v["normalized_url"] === url || v["url"] === url) { + if (v.normalized_url === url || v.url === url) { if (!confirm("This will mark the URL as inactive. Continue?")) { return; } - - $.ajax("/artist_urls/" + v["id"], { + + $.ajax("/artist_urls/" + v.id, { method: "PUT", data: { artist_url: { diff --git a/app/javascript/src/javascripts/saved_searches.js b/app/javascript/src/javascripts/saved_searches.js index dc6d38b5f..4f0e0bc48 100644 --- a/app/javascript/src/javascripts/saved_searches.js +++ b/app/javascript/src/javascripts/saved_searches.js @@ -17,4 +17,4 @@ SavedSearch.labels = function(term) { $(SavedSearch.initialize_all); -export default SavedSearch \ No newline at end of file +export default SavedSearch diff --git a/app/javascript/src/javascripts/shortcuts.js b/app/javascript/src/javascripts/shortcuts.js index 9b0363ce6..5cdc09666 100644 --- a/app/javascript/src/javascripts/shortcuts.js +++ b/app/javascript/src/javascripts/shortcuts.js @@ -14,7 +14,7 @@ Shortcuts.initialize = function() { if ($("#image").length) { // post page or bookmarklet upload page Utility.keydown("shift+e", "edit_dialog", function(e) { - if (Utility.meta("current-user-id") == "") { // anonymous + if (Utility.meta("current-user-id") === "") { // anonymous return; } @@ -56,4 +56,4 @@ $(document).ready(function() { Shortcuts.initialize(); }); -export default Shortcuts \ No newline at end of file +export default Shortcuts diff --git a/app/javascript/src/javascripts/tag_script.js b/app/javascript/src/javascripts/tag_script.js index ba20ee1a7..4ecbf5ba1 100644 --- a/app/javascript/src/javascripts/tag_script.js +++ b/app/javascript/src/javascripts/tag_script.js @@ -16,10 +16,8 @@ TagScript.test = function(tags, predicate) { if ($.inArray(x.substr(1, 100), tags)) { is_true = false; } - } else { - if (!$.inArray(x, tags)) { - is_true = false; - } + } else if (!$.inArray(x, tags)) { + is_true = false; } }); @@ -57,4 +55,4 @@ TagScript.run = function(post_id, tag_script) { Post.update(post_id, {"post[old_tag_string]": old_tags, "post[tag_string]": $post.data("tags")}); } -export default TagScript \ No newline at end of file +export default TagScript diff --git a/app/javascript/src/javascripts/ugoira.js b/app/javascript/src/javascripts/ugoira.js index 8c8a0af65..6fee99ef3 100644 --- a/app/javascript/src/javascripts/ugoira.js +++ b/app/javascript/src/javascripts/ugoira.js @@ -50,7 +50,7 @@ Ugoira.create_player = (mime_type, frames, file_url) => { $("#seek-slider").slider({ min: 0, - max: Ugoira.player._frameCount-1, + max: Ugoira.player._frameCount - 1, start: (event, ui) => { // Need to pause while slider is being dragged or playback speed will bug out Ugoira.player.pause(); diff --git a/app/javascript/src/javascripts/uploads.js b/app/javascript/src/javascripts/uploads.js index 51e491a0e..99ef33de8 100644 --- a/app/javascript/src/javascripts/uploads.js +++ b/app/javascript/src/javascripts/uploads.js @@ -1,6 +1,5 @@ import Utility from './utility' import Post from './posts.js.erb' -import Artist from './artists' import RelatedTag from './related_tag.js.erb' let Upload = {}; @@ -45,8 +44,8 @@ Upload.initialize_submit = function() { error_messages.push("Must specify a rating"); } if (error_messages.length === 0) { - $("#submit-button").prop("disabled","true"); - $("#submit-button").prop("value","Submitting..."); + $("#submit-button").prop("disabled", "true"); + $("#submit-button").prop("value", "Submitting..."); $("#client-errors").hide(); } else { $("#client-errors").html("Error: " + error_messages.join(", ")); @@ -112,7 +111,7 @@ Upload.fetch_source_data = function(url, referer_url) { return $.getJSON("/source.json", { url: url, ref: referer_url }) .then(Upload.fill_source_info) .catch(function(data) { - $("#source-info span#loading-data").html("Error: " + data.responseJSON["message"]) + $("#source-info span#loading-data").html("Error: " + data.responseJSON.message) }); } diff --git a/app/javascript/src/javascripts/utility.js b/app/javascript/src/javascripts/utility.js index b5c041877..d287ac4d6 100644 --- a/app/javascript/src/javascripts/utility.js +++ b/app/javascript/src/javascripts/utility.js @@ -22,7 +22,7 @@ Utility.scroll_to = function(element) { } var top = null; - if (typeof(element) === "number") { + if (typeof element === "number") { top = element; } else { top = element.offset().top - 10; @@ -76,8 +76,7 @@ Utility.intersect = function(a, b) { a = a.slice(0).sort(); b = b.slice(0).sort(); var result = []; - while (a.length > 0 && b.length > 0) - { + while (a.length > 0 && b.length > 0) { if (a[0] < b[0]) { a.shift(); } else if (a[0] > b[0]) { @@ -150,7 +149,7 @@ $.fn.selectRange = function(start, end) { }); }; -$.fn.selectEnd = function(){ +$.fn.selectEnd = function() { if (this.length) { this.selectRange(this.val().length, this.val().length); }