From 69a9c016a89f2d4a57f6f0693c856e435b95a3f1 Mon Sep 17 00:00:00 2001 From: Maximilian Stoiber Date: Thu, 15 Mar 2018 13:46:04 +0100 Subject: [PATCH 1/3] Properly set up ESLint and enforce it in CI We've always had ESLint configured, but we never really enforced it in CI. (create-react-app kinda enforces it by not building the app if we do some crap) This makes it so we have a proper ESLint setup that works 100%, and I'm also adding ESLint to the CI to catch our dumb mistakes early. --- .eslintignore | 33 +++++++++++++++++++++++++++++++++ .eslintrc.js | 12 ++++++++++++ .eslintrc.json | 47 ----------------------------------------------- package.json | 13 +++++++++---- yarn.lock | 46 +++++++++++++++++++++++++--------------------- 5 files changed, 79 insertions(+), 72 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc.js delete mode 100644 .eslintrc.json diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000000..8767dbd6f9 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,33 @@ +# Note: This is a copy of the .gitignore, +# with flow-typed added +flow-typed +node_modules +.sass-cache +npm-debug.log +build +.DS_Store +src/config/FirebaseConfig.js +npm-debug.log +rethinkdb_data +debug +now-secrets.json +build-iris +build-athena +build-hermes +build-chronos +build-mercury +build-vulcan +build-hyperion +build-pluto +package-lock.json +.vscode +dump.rdb +*.swp +queries-by-response-size.js +queries-by-time.js +test-extend.js +stats.json +iris/.env +.expo +mobile/.expo +test-results.json diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000000..1383a7ba4f --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,12 @@ +module.exports = { + extends: 'react-app', + env: { + node: false, + }, + rules: { + 'no-unused-vars': 0, + 'no-undef': 0, + radix: 0, + 'import/first': 0, + }, +}; diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 0fd755fcc9..0000000000 --- a/.eslintrc.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "env": { - "browser": true, - "commonjs": true, - "es6": true, - "node": true - }, - "parser": "babel-eslint", - "extends": ["eslint:recommended", "plugin:promise/recommended", "plugin:flowtype/recommended", "plugin:react/recommended" ,"plugin:jest/recommended"], - "parserOptions": { - "ecmaVersion": 2017, - "ecmaFeatures": { - "experimentalObjectRestSpread": true, - "jsx": true - }, - "sourceType": "module" - }, - "plugins": [ - "react", - "flowtype", - "promise" - ], - "rules": { - "no-console": 0, - "require-await": [ - "error" - ], - "indent": 0, - "linebreak-style": [ - 0, - "unix" - ], - "quotes": [ - "error", - "single" - ], - "semi": [ - "error", - "always" - ] - }, - "settings": { - "flowtype": { - "onlyFilesWithFlowAnnotation": false - } - } -} diff --git a/package.json b/package.json index e514badc73..c177a237d9 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "devDependencies": { "babel-cli": "^6.24.1", - "babel-eslint": "^8.0.1", + "babel-eslint": "^7.2.3", "babel-plugin-import-inspector": "^2.0.0", "babel-plugin-inline-import-graphql-ast": "^2.0.4", "babel-plugin-styled-components": "^1.1.7", @@ -22,11 +22,14 @@ "danger-plugin-jest": "^1.1.0", "danger-plugin-no-console": "^1.0.0", "danger-plugin-yarn": "^1.2.1", - "eslint": "^4.15.0", - "eslint-plugin-flowtype": "^2.39.1", + "eslint": "^4.1.1", + "eslint-config-react-app": "^2.1.0", + "eslint-plugin-flowtype": "^2.34.1", + "eslint-plugin-import": "^2.6.0", "eslint-plugin-jest": "^21.6.1", + "eslint-plugin-jsx-a11y": "^5.1.1", "eslint-plugin-promise": "^3.6.0", - "eslint-plugin-react": "^7.4.0", + "eslint-plugin-react": "^7.1.0", "flow-bin": "0.66", "is-html": "^1.1.0", "lint-staged": "^3.3.0", @@ -221,6 +224,7 @@ "jest": "cross-env NODE_PATH=./ jest", "test": "npm run jest -- --runInBand --watch", "test:ci": "npm run jest -- --forceExit --outputFile test-results.json --json", + "lint": "eslint .", "flow": "flow", "db:migrate": "npm run rethinkdb:migrate -- up", "db:drop": "npm run rethinkdb:migrate -- down", @@ -233,6 +237,7 @@ "lint-staged": { "*.js": [ "prettier --write --single-quote --trailing-comma es5", + "eslint --fix", "git add" ] }, diff --git a/yarn.lock b/yarn.lock index ed153f34e7..c7530facfd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,7 +2,7 @@ # yarn lockfile v1 -"@babel/code-frame@7.0.0-beta.40", "@babel/code-frame@^7.0.0-beta.35", "@babel/code-frame@^7.0.0-beta.40": +"@babel/code-frame@7.0.0-beta.40", "@babel/code-frame@^7.0.0-beta.35": version "7.0.0-beta.40" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0-beta.40.tgz#37e2b0cf7c56026b4b21d3927cadf81adec32ac6" dependencies: @@ -96,7 +96,7 @@ babylon "7.0.0-beta.40" lodash "^4.2.0" -"@babel/traverse@7.0.0-beta.40", "@babel/traverse@^7.0.0-beta.40": +"@babel/traverse@7.0.0-beta.40": version "7.0.0-beta.40" resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.0.0-beta.40.tgz#d140e449b2e093ef9fe1a2eecc28421ffb4e521e" dependencies: @@ -110,7 +110,7 @@ invariant "^2.2.0" lodash "^4.2.0" -"@babel/types@7.0.0-beta.40", "@babel/types@^7.0.0-beta.40": +"@babel/types@7.0.0-beta.40": version "7.0.0-beta.40" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.0.0-beta.40.tgz#25c3d7aae14126abe05fcb098c65a66b6d6b8c14" dependencies: @@ -815,7 +815,7 @@ babel-core@6.26.0, babel-core@^6.0.0, babel-core@^6.25.0, babel-core@^6.26.0: slash "^1.0.0" source-map "^0.5.6" -babel-eslint@7.2.3: +babel-eslint@7.2.3, babel-eslint@^7.2.3: version "7.2.3" resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-7.2.3.tgz#b2fe2d80126470f5c19442dc757253a897710827" dependencies: @@ -824,17 +824,6 @@ babel-eslint@7.2.3: babel-types "^6.23.0" babylon "^6.17.0" -babel-eslint@^8.0.1: - version "8.2.2" - resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-8.2.2.tgz#1102273354c6f0b29b4ea28a65f97d122296b68b" - dependencies: - "@babel/code-frame" "^7.0.0-beta.40" - "@babel/traverse" "^7.0.0-beta.40" - "@babel/types" "^7.0.0-beta.40" - babylon "^7.0.0-beta.40" - eslint-scope "~3.7.1" - eslint-visitor-keys "^1.0.0" - babel-generator@6.11.4: version "6.11.4" resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.11.4.tgz#14f6933abb20c62666d27e3b7b9f5b9dc0712a9a" @@ -1550,7 +1539,7 @@ babylon@6.14.1: version "6.14.1" resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.14.1.tgz#956275fab72753ad9b3435d7afe58f8bf0a29815" -babylon@7.0.0-beta.40, babylon@^7.0.0-beta.40: +babylon@7.0.0-beta.40: version "7.0.0-beta.40" resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.40.tgz#91fc8cd56d5eb98b28e6fde41045f2957779940a" @@ -3652,7 +3641,7 @@ eslint-plugin-flowtype@2.39.1: dependencies: lodash "^4.15.0" -eslint-plugin-flowtype@^2.39.1: +eslint-plugin-flowtype@^2.34.1: version "2.46.1" resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.46.1.tgz#c4f81d580cd89c82bc3a85a1ccf4ae3a915143a4" dependencies: @@ -3673,11 +3662,26 @@ eslint-plugin-import@2.8.0: minimatch "^3.0.3" read-pkg-up "^2.0.0" +eslint-plugin-import@^2.6.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.9.0.tgz#26002efbfca5989b7288ac047508bd24f217b169" + dependencies: + builtin-modules "^1.1.1" + contains-path "^0.1.0" + debug "^2.6.8" + doctrine "1.5.0" + eslint-import-resolver-node "^0.3.1" + eslint-module-utils "^2.1.1" + has "^1.0.1" + lodash "^4.17.4" + minimatch "^3.0.3" + read-pkg-up "^2.0.0" + eslint-plugin-jest@^21.6.1: version "21.13.0" resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-21.13.0.tgz#9fc903158d79e953aefd861a55e8a8c9f6ab3d36" -eslint-plugin-jsx-a11y@5.1.1: +eslint-plugin-jsx-a11y@5.1.1, eslint-plugin-jsx-a11y@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-5.1.1.tgz#5c96bb5186ca14e94db1095ff59b3e2bd94069b1" dependencies: @@ -3702,7 +3706,7 @@ eslint-plugin-react@7.4.0: jsx-ast-utils "^2.0.0" prop-types "^15.5.10" -eslint-plugin-react@^7.4.0: +eslint-plugin-react@^7.1.0: version "7.7.0" resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.7.0.tgz#f606c719dbd8a1a2b3d25c16299813878cca0160" dependencies: @@ -3711,7 +3715,7 @@ eslint-plugin-react@^7.4.0: jsx-ast-utils "^2.0.1" prop-types "^15.6.0" -eslint-scope@^3.7.1, eslint-scope@~3.7.1: +eslint-scope@^3.7.1: version "3.7.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8" dependencies: @@ -3764,7 +3768,7 @@ eslint@4.10.0: table "^4.0.1" text-table "~0.2.0" -eslint@^4.15.0: +eslint@^4.1.1: version "4.18.2" resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.18.2.tgz#0f81267ad1012e7d2051e186a9004cc2267b8d45" dependencies: From c34663e0621814ea6a13a00d4b9a5bd7f4550b6b Mon Sep 17 00:00:00 2001 From: Maximilian Stoiber Date: Thu, 15 Mar 2018 13:46:53 +0100 Subject: [PATCH 2/3] Fix ESLint errors --- public/push-sw.js | 175 ++++++++++++++++++++------------------- public/service-worker.js | 1 + 2 files changed, 92 insertions(+), 84 deletions(-) diff --git a/public/push-sw.js b/public/push-sw.js index 21782e62fc..b38410e0c9 100644 --- a/public/push-sw.js +++ b/public/push-sw.js @@ -1,84 +1,91 @@ -/* - * Push notificiations ServiceWorker - * - * NOTE(@mxstbr): This only gets updated if you change the filename, not if you - * update the contents. Make sure to change the version number in the filename - * after updating the code! - */ - -// A new notification is coming in, yay! -self.addEventListener('push', function(event) { - var notificationData = {}; - - try { - notificationData = event.data.json(); - } catch (e) { - console.log('event.data.json() failed', e); - // 🚨 We either got no data or it's malformatted, ABORT ABORT ABORT - return; - } - - // Check if the user is looking at Spectrum right now and don't show a notification - event.waitUntil( - clients - .matchAll({ - type: 'window', - includeUncontrolled: true, - }) - .then(windowClients => { - for (let i = 0; i < windowClients.length; i++) { - const windowClient = windowClients[i]; - // The user is looking at Spectrum right now abort showing the notification! - // (except for if we're on localhost, i.e. in development) - if ( - windowClient.focused && - !(self.registration.scope.indexOf('http://localhost:3000') === 0) - ) { - return; - } - } - return self.registration.showNotification(notificationData.title, { - vibrate: [200], - icon: '/img/apple-icon-144x144-precomposed.png', - badge: '/img/badge.png', - body: notificationData.body, - title: notificationData.title, - timestamp: notificationData.timestamp, - image: notificationData.image, - tag: notificationData.tag, - data: notificationData.data, - // If we don't set a tag and set renotify to true this'll throw an error - // renotify: notificationData.renotify || !!notificationData.tag, - }); - }) - ); -}); - -// On notification click -self.addEventListener('notificationclick', function(event) { - event.notification.close(); - - const urlToOpen = - event.notification.data && event.notification.data.href - ? new URL(event.notification.data.href, self.location.origin).href - : '/'; - - // see if the current is open and if it is focus it - event.waitUntil( - self.clients - .matchAll({ - type: 'window', - includeUncontrolled: true, - }) - .then(function(clientList) { - // If there is an open Spectrum.chat window navigate to the notification href - if (clientList.length > 0) { - return clientList[0] - .focus() - .then(client => client.navigate(urlToOpen)); - } - // If there's no open Spectrum.chat window open a new one - return self.clients.openWindow(urlToOpen); - }) - ); -}); +/* + * Push notificiations ServiceWorker + * + * NOTE(@mxstbr): This only gets updated if you change the filename, not if you + * update the contents. Make sure to change the version number in the filename + * after updating the code! + */ + +// A new notification is coming in, yay! +// eslint-disable-next-line +self.addEventListener('push', function(event) { + var notificationData = {}; + + try { + notificationData = event.data.json(); + } catch (e) { + console.log('event.data.json() failed', e); + // 🚨 We either got no data or it's malformatted, ABORT ABORT ABORT + return; + } + + // Check if the user is looking at Spectrum right now and don't show a notification + event.waitUntil( + clients + .matchAll({ + type: 'window', + includeUncontrolled: true, + }) + .then(windowClients => { + for (let i = 0; i < windowClients.length; i++) { + const windowClient = windowClients[i]; + // The user is looking at Spectrum right now abort showing the notification! + // (except for if we're on localhost, i.e. in development) + if ( + windowClient.focused && + // eslint-disable-next-line + !(self.registration.scope.indexOf('http://localhost:3000') === 0) + ) { + return; + } + } + // eslint-disable-next-line + return self.registration.showNotification(notificationData.title, { + vibrate: [200], + icon: '/img/apple-icon-144x144-precomposed.png', + badge: '/img/badge.png', + body: notificationData.body, + title: notificationData.title, + timestamp: notificationData.timestamp, + image: notificationData.image, + tag: notificationData.tag, + data: notificationData.data, + // If we don't set a tag and set renotify to true this'll throw an error + // renotify: notificationData.renotify || !!notificationData.tag, + }); + }) + ); +}); + +// On notification click +// eslint-disable-next-line +self.addEventListener('notificationclick', function(event) { + event.notification.close(); + + const urlToOpen = + event.notification.data && event.notification.data.href + ? // eslint-disable-next-line + new URL(event.notification.data.href, self.location.origin).href + : '/'; + + // see if the current is open and if it is focus it + event.waitUntil( + // eslint-disable-next-line + self.clients + .matchAll({ + type: 'window', + includeUncontrolled: true, + }) + .then(function(clientList) { + // If there is an open Spectrum.chat window navigate to the notification href + if (clientList.length > 0) { + return clientList[0] + .focus() + .then(client => client.navigate(urlToOpen)); + } + // If there's no open Spectrum.chat window open a new one + // eslint-disable-next-line + return self.clients.openWindow(urlToOpen); + }) + ); +}); diff --git a/public/service-worker.js b/public/service-worker.js index ea854b776c..da97ae3e3f 100644 --- a/public/service-worker.js +++ b/public/service-worker.js @@ -1,3 +1,4 @@ +/* eslint-disable */ // A simple, no-op service worker that takes immediate control. // from: https://stackoverflow.com/a/38980776 From 62addbe4231472dfaf398a98c721469b2978441b Mon Sep 17 00:00:00 2001 From: Maximilian Stoiber Date: Thu, 15 Mar 2018 13:55:37 +0100 Subject: [PATCH 3/3] Run eslint --fix to fix some warnings --- athena/utils/actors.js | 2 +- .../migrations/20170410074258-initial-data.js | 288 +++++++++++------- .../20170613200350-notifications.js | 47 +-- ...616113103-compound-indexes-for-ordering.js | 7 +- .../20170701173337-linkify-messages.js | 1 - iris/migrations/20170702194221-fix-images.js | 1 - .../20170706114239-providerfield-indexes.js | 17 +- .../migrations/20170706205658-slack-import.js | 18 +- .../20170714171920-web-push-subscription.js | 23 +- ...184557-notifications-entity-added-index.js | 2 - ...20170829233734-userid-index-on-invoices.js | 2 - .../20170926102527-speedy-gonzales.js | 2 - ...-communityid-index-on-reputation-events.js | 2 - .../20170928143435-slate-to-draftjs.js.js | 1 - ...445-remove-markdown-links-from-messages.js | 1 - .../20171008101118-last-slate-to-draft.js | 1 - .../20171013195530-core-metrics-table.js | 26 +- ...235659-add-direst-message-user-settings.js | 2 - .../20171029090619-users-channels-index.js | 2 - .../20171029094352-users-threads-index.js | 2 - ...0171129215512-index-communities-by-slug.js | 2 - ...29221050-curated-content-table-creation.js | 2 - ...20180209015734-github-provider-id-index.js | 2 - .../20180214111357-expo-push-subscriptions.js | 2 - ...9144845-create-community-settings-table.js | 2 - 25 files changed, 266 insertions(+), 191 deletions(-) diff --git a/athena/utils/actors.js b/athena/utils/actors.js index ed2a4c99d6..a1685dff7c 100644 --- a/athena/utils/actors.js +++ b/athena/utils/actors.js @@ -4,7 +4,7 @@ export const getDistinctActors = (array: Array): Array => { let unique = {}; let distinct = []; for (let actor of array) { - if (typeof unique[actor.id] == 'undefined') { + if (typeof unique[actor.id] === 'undefined') { distinct.push(actor); } unique[actor.id] = 0; diff --git a/iris/migrations/20170410074258-initial-data.js b/iris/migrations/20170410074258-initial-data.js index 36fa10848d..89f7c11198 100644 --- a/iris/migrations/20170410074258-initial-data.js +++ b/iris/migrations/20170410074258-initial-data.js @@ -1,60 +1,97 @@ -'use strict'; - exports.up = function(r, conn) { return ( Promise.all([ - r.tableCreate('threads').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableCreate('channels').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableCreate('communities').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableCreate('messages').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableCreate('sessions').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableCreate('reactions').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableCreate('directMessageThreads').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableCreate('users').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableCreate('recurringPayments').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableCreate('invoices').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableCreate('usersCommunities').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableCreate('usersChannels').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableCreate('usersDirectMessageThreads').run(conn).catch(err => { - console.log(err); - throw err; - }), + r + .tableCreate('threads') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableCreate('channels') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableCreate('communities') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableCreate('messages') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableCreate('sessions') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableCreate('reactions') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableCreate('directMessageThreads') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableCreate('users') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableCreate('recurringPayments') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableCreate('invoices') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableCreate('usersCommunities') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableCreate('usersChannels') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableCreate('usersDirectMessageThreads') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), ]) // Create secondary indexes .then(() => @@ -220,58 +257,97 @@ exports.up = function(r, conn) { exports.down = function(r, conn) { return Promise.all([ - r.tableDrop('threads').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableDrop('channels').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableDrop('communities').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableDrop('messages').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableDrop('sessions').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableDrop('users').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableDrop('directMessageThreads').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableDrop('reactions').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableDrop('recurringPayments').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableDrop('invoices').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableDrop('usersCommunities').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableDrop('usersChannels').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableDrop('usersDirectMessageThreads').run(conn).catch(err => { - console.log(err); - throw err; - }), + r + .tableDrop('threads') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableDrop('channels') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableDrop('communities') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableDrop('messages') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableDrop('sessions') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableDrop('users') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableDrop('directMessageThreads') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableDrop('reactions') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableDrop('recurringPayments') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableDrop('invoices') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableDrop('usersCommunities') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableDrop('usersChannels') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableDrop('usersDirectMessageThreads') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), ]).catch(err => { console.log(err); throw err; diff --git a/iris/migrations/20170613200350-notifications.js b/iris/migrations/20170613200350-notifications.js index 99f5d023f2..0352aeaec3 100644 --- a/iris/migrations/20170613200350-notifications.js +++ b/iris/migrations/20170613200350-notifications.js @@ -1,5 +1,3 @@ -'use strict'; - exports.up = function(r, conn) { return ( // Create new tables, update old ones with receiveNotifications @@ -22,18 +20,27 @@ exports.up = function(r, conn) { console.log(err); throw err; }), - r.tableCreate('notifications').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableCreate('usersThreads').run(conn).catch(err => { - console.log(err); - throw err; - }), - r.tableCreate('usersNotifications').run(conn).catch(err => { - console.log(err); - throw err; - }), + r + .tableCreate('notifications') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableCreate('usersThreads') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), + r + .tableCreate('usersNotifications') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), ]) // Add secondary indexes to new tables .then(() => @@ -46,10 +53,14 @@ exports.up = function(r, conn) { console.log(err); throw err; }), - r.table('usersThreads').indexCreate('userId').run(conn).catch(err => { - console.log(err); - throw err; - }), + r + .table('usersThreads') + .indexCreate('userId') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), r .table('usersThreads') .indexCreate('threadId') diff --git a/iris/migrations/20170616113103-compound-indexes-for-ordering.js b/iris/migrations/20170616113103-compound-indexes-for-ordering.js index 373743b871..d058431616 100644 --- a/iris/migrations/20170616113103-compound-indexes-for-ordering.js +++ b/iris/migrations/20170616113103-compound-indexes-for-ordering.js @@ -1,5 +1,3 @@ -'use strict'; - exports.up = function(r, conn) { return Promise.all([ // messages#threadIdAndTimestamp @@ -27,7 +25,10 @@ exports.up = function(r, conn) { ]) .run(conn), // community#createdAt - r.table('communities').indexCreate('createdAt').run(conn), + r + .table('communities') + .indexCreate('createdAt') + .run(conn), ]).catch(err => { console.log(err); throw err; diff --git a/iris/migrations/20170701173337-linkify-messages.js b/iris/migrations/20170701173337-linkify-messages.js index ab0ef2522f..94f1394cca 100644 --- a/iris/migrations/20170701173337-linkify-messages.js +++ b/iris/migrations/20170701173337-linkify-messages.js @@ -1,4 +1,3 @@ -'use strict'; const markdownLinkify = require('../utils/markdown-linkify'); exports.up = function(r, conn) { diff --git a/iris/migrations/20170702194221-fix-images.js b/iris/migrations/20170702194221-fix-images.js index be024aa2d2..68450fa273 100644 --- a/iris/migrations/20170702194221-fix-images.js +++ b/iris/migrations/20170702194221-fix-images.js @@ -1,4 +1,3 @@ -'use strict'; const MARKDOWN_LINK = /(?:\[(.*?)\]\((.*?)\))/g; exports.up = function(r, conn) { diff --git a/iris/migrations/20170706114239-providerfield-indexes.js b/iris/migrations/20170706114239-providerfield-indexes.js index b0bb980e15..a514566617 100644 --- a/iris/migrations/20170706114239-providerfield-indexes.js +++ b/iris/migrations/20170706114239-providerfield-indexes.js @@ -1,10 +1,17 @@ -'use strict'; - exports.up = function(r, conn) { return Promise.all([ - r.table('users').indexCreate('providerId').run(conn), - r.table('users').indexCreate('fbProviderId').run(conn), - r.table('users').indexCreate('googleProviderId').run(conn), + r + .table('users') + .indexCreate('providerId') + .run(conn), + r + .table('users') + .indexCreate('fbProviderId') + .run(conn), + r + .table('users') + .indexCreate('googleProviderId') + .run(conn), ]).catch(err => { console.log(err); throw err; diff --git a/iris/migrations/20170706205658-slack-import.js b/iris/migrations/20170706205658-slack-import.js index b5bff20732..60deda8dac 100644 --- a/iris/migrations/20170706205658-slack-import.js +++ b/iris/migrations/20170706205658-slack-import.js @@ -1,11 +1,12 @@ -'use strict'; - exports.up = function(r, conn) { return Promise.all([ - r.tableCreate('slackImports').run(conn).catch(err => { - console.log(err); - throw err; - }), + r + .tableCreate('slackImports') + .run(conn) + .catch(err => { + console.log(err); + throw err; + }), ]) .then(() => Promise.all([ @@ -17,7 +18,10 @@ exports.up = function(r, conn) { console.log(err); throw err; }), - r.table('users').indexCreate('email', r.row('email')).run(conn), + r + .table('users') + .indexCreate('email', r.row('email')) + .run(conn), ]) ) .catch(err => { diff --git a/iris/migrations/20170714171920-web-push-subscription.js b/iris/migrations/20170714171920-web-push-subscription.js index bcc47aede8..39bd998f4d 100644 --- a/iris/migrations/20170714171920-web-push-subscription.js +++ b/iris/migrations/20170714171920-web-push-subscription.js @@ -1,5 +1,3 @@ -'use strict'; - exports.up = function(r, conn) { return r .tableCreate('webPushSubscriptions') @@ -7,14 +5,25 @@ exports.up = function(r, conn) { .catch(err => { throw new Error(err); }) - .then(() => r.table('webPushSubscriptions').indexCreate('userId').run(conn)) .then(() => - r.table('webPushSubscriptions').indexCreate('endpoint').run(conn) + r + .table('webPushSubscriptions') + .indexCreate('userId') + .run(conn) + ) + .then(() => + r + .table('webPushSubscriptions') + .indexCreate('endpoint') + .run(conn) ); }; exports.down = function(r, conn) { - return r.tableDrop('webPushSubscriptions').run(conn).catch(err => { - throw new Error(err); - }); + return r + .tableDrop('webPushSubscriptions') + .run(conn) + .catch(err => { + throw new Error(err); + }); }; diff --git a/iris/migrations/20170724184557-notifications-entity-added-index.js b/iris/migrations/20170724184557-notifications-entity-added-index.js index 2a35f40a83..c3475934dd 100644 --- a/iris/migrations/20170724184557-notifications-entity-added-index.js +++ b/iris/migrations/20170724184557-notifications-entity-added-index.js @@ -1,5 +1,3 @@ -'use strict'; - exports.up = function(r, conn) { return Promise.all([ r diff --git a/iris/migrations/20170829233734-userid-index-on-invoices.js b/iris/migrations/20170829233734-userid-index-on-invoices.js index 71d2f97202..1ed0b73435 100644 --- a/iris/migrations/20170829233734-userid-index-on-invoices.js +++ b/iris/migrations/20170829233734-userid-index-on-invoices.js @@ -1,5 +1,3 @@ -'use strict'; - exports.up = function(r, conn) { return Promise.all([ r diff --git a/iris/migrations/20170926102527-speedy-gonzales.js b/iris/migrations/20170926102527-speedy-gonzales.js index ad4ce2f92d..1b70c438a7 100644 --- a/iris/migrations/20170926102527-speedy-gonzales.js +++ b/iris/migrations/20170926102527-speedy-gonzales.js @@ -1,5 +1,3 @@ -'use strict'; - exports.up = function(r, conn) { return Promise.all([ r diff --git a/iris/migrations/20170927002438-communityid-index-on-reputation-events.js b/iris/migrations/20170927002438-communityid-index-on-reputation-events.js index 3bea0d94f3..2b311c0c27 100644 --- a/iris/migrations/20170927002438-communityid-index-on-reputation-events.js +++ b/iris/migrations/20170927002438-communityid-index-on-reputation-events.js @@ -1,5 +1,3 @@ -'use strict'; - exports.up = function(r, conn) { return Promise.all([ r diff --git a/iris/migrations/20170928143435-slate-to-draftjs.js.js b/iris/migrations/20170928143435-slate-to-draftjs.js.js index 66060e3b46..c149c5d447 100644 --- a/iris/migrations/20170928143435-slate-to-draftjs.js.js +++ b/iris/migrations/20170928143435-slate-to-draftjs.js.js @@ -1,4 +1,3 @@ -'use strict'; const compose = require('redux/lib/compose').default; const { convertToRaw, genKey } = require('draft-js'); const { stateFromMarkdown } = require('draft-js-import-markdown'); diff --git a/iris/migrations/20171005075445-remove-markdown-links-from-messages.js b/iris/migrations/20171005075445-remove-markdown-links-from-messages.js index 23d2f00464..1aab8f1dce 100644 --- a/iris/migrations/20171005075445-remove-markdown-links-from-messages.js +++ b/iris/migrations/20171005075445-remove-markdown-links-from-messages.js @@ -1,4 +1,3 @@ -'use strict'; const replace = require('string-replace-to-array'); const MARKDOWN_LINK = /(?:\[(.*?)\]\((.*?)\))/g; diff --git a/iris/migrations/20171008101118-last-slate-to-draft.js b/iris/migrations/20171008101118-last-slate-to-draft.js index a58fd1b416..cd42514139 100644 --- a/iris/migrations/20171008101118-last-slate-to-draft.js +++ b/iris/migrations/20171008101118-last-slate-to-draft.js @@ -1,4 +1,3 @@ -'use strict'; const compose = require('redux/lib/compose').default; const { convertToRaw, genKey } = require('draft-js'); const { stateFromMarkdown } = require('draft-js-import-markdown'); diff --git a/iris/migrations/20171013195530-core-metrics-table.js b/iris/migrations/20171013195530-core-metrics-table.js index 3864e26f99..d76c73e315 100644 --- a/iris/migrations/20171013195530-core-metrics-table.js +++ b/iris/migrations/20171013195530-core-metrics-table.js @@ -1,5 +1,3 @@ -'use strict'; - exports.up = function(r, conn) { return Promise.all([ r @@ -131,19 +129,17 @@ exports.up = function(r, conn) { threadMessages, dmMessages, ]).then( - ( - [ - cpu, - mpu, - tpu, - users, - communities, - threads, - dmThreads, - threadMessages, - dmMessages, - ] - ) => { + ([ + cpu, + mpu, + tpu, + users, + communities, + threads, + dmThreads, + threadMessages, + dmMessages, + ]) => { const coreMetrics = { cpu: cpu || 0, mpu: mpu || 0, diff --git a/iris/migrations/20171018235659-add-direst-message-user-settings.js b/iris/migrations/20171018235659-add-direst-message-user-settings.js index 4c21abb2b3..729528b2af 100644 --- a/iris/migrations/20171018235659-add-direst-message-user-settings.js +++ b/iris/migrations/20171018235659-add-direst-message-user-settings.js @@ -1,5 +1,3 @@ -'use strict'; - exports.up = function(r, conn) { return Promise.all([ r diff --git a/iris/migrations/20171029090619-users-channels-index.js b/iris/migrations/20171029090619-users-channels-index.js index a10524aa67..1148f7b6f1 100644 --- a/iris/migrations/20171029090619-users-channels-index.js +++ b/iris/migrations/20171029090619-users-channels-index.js @@ -1,5 +1,3 @@ -'use strict'; - exports.up = function(r, conn) { return r .table('usersChannels') diff --git a/iris/migrations/20171029094352-users-threads-index.js b/iris/migrations/20171029094352-users-threads-index.js index daab3fa4cf..8b3a6dfa6b 100644 --- a/iris/migrations/20171029094352-users-threads-index.js +++ b/iris/migrations/20171029094352-users-threads-index.js @@ -1,5 +1,3 @@ -'use strict'; - exports.up = function(r, conn) { return r .table('usersThreads') diff --git a/iris/migrations/20171129215512-index-communities-by-slug.js b/iris/migrations/20171129215512-index-communities-by-slug.js index 2a73a97482..d91f5e672f 100644 --- a/iris/migrations/20171129215512-index-communities-by-slug.js +++ b/iris/migrations/20171129215512-index-communities-by-slug.js @@ -1,5 +1,3 @@ -'use strict'; - exports.up = function(r, conn) { return Promise.all([ r diff --git a/iris/migrations/20171129221050-curated-content-table-creation.js b/iris/migrations/20171129221050-curated-content-table-creation.js index a43f088d82..d66786b7f0 100644 --- a/iris/migrations/20171129221050-curated-content-table-creation.js +++ b/iris/migrations/20171129221050-curated-content-table-creation.js @@ -1,5 +1,3 @@ -'use strict'; - exports.up = function(r, conn) { return Promise.all([ r diff --git a/iris/migrations/20180209015734-github-provider-id-index.js b/iris/migrations/20180209015734-github-provider-id-index.js index ea1564a0c9..afc1d59ddb 100644 --- a/iris/migrations/20180209015734-github-provider-id-index.js +++ b/iris/migrations/20180209015734-github-provider-id-index.js @@ -1,5 +1,3 @@ -'use strict'; - exports.up = function(r, conn) { return Promise.all([ r diff --git a/iris/migrations/20180214111357-expo-push-subscriptions.js b/iris/migrations/20180214111357-expo-push-subscriptions.js index f067e9a871..598ffbc454 100644 --- a/iris/migrations/20180214111357-expo-push-subscriptions.js +++ b/iris/migrations/20180214111357-expo-push-subscriptions.js @@ -1,5 +1,3 @@ -'use strict'; - exports.up = function(r, conn) { return r .tableCreate('expoPushSubscriptions') diff --git a/iris/migrations/20180309144845-create-community-settings-table.js b/iris/migrations/20180309144845-create-community-settings-table.js index c57ab7a013..e1beb49337 100644 --- a/iris/migrations/20180309144845-create-community-settings-table.js +++ b/iris/migrations/20180309144845-create-community-settings-table.js @@ -1,5 +1,3 @@ -'use strict'; - exports.up = function(r, conn) { return r .tableCreate('communitySettings')