Skip to content

Commit

Permalink
Removal of EJSON, Accounts, Email, HTTP, Random, ReactiveDict, Reacti…
Browse files Browse the repository at this point in the history
…veVar, SHA256 and WebApp global variables (#12377)

* First wave of removal of Meteor global

* Second wave of removal of Meteor global

* Third wave of removal of Meteor global

* Fix tests

* Remove global variable SHA256

* Remove global variable WebApp

* Remove global variable EJSON

* Remove global variable Email

* Remove global variable HTTP

* Remove global variable Random

* Remove global variable ReactiveDict

* Remove global variable ReactiveVar

* Remove global variable Accounts

* Fix ESLint
  • Loading branch information
rodrigok authored Nov 1, 2018
1 parent 6e88d4d commit 26d59c3
Show file tree
Hide file tree
Showing 259 changed files with 317 additions and 13 deletions.
9 changes: 0 additions & 9 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"globals": {
"__meteor_runtime_config__" : false,
"AccountBox" : false,
"Accounts" : false,
"AgentUsers" : false,
"Apps" : false,
"Assets" : false,
Expand All @@ -19,11 +18,8 @@
"CryptoJS" : false,
"Department" : false,
"DDPRateLimiter" : false,
"EJSON" : false,
"Email" : false,
"FlowRouter" : false,
"FileUpload" : false,
"HTTP" : false,
"getNextAgent" : false,
"handleError" : false,
"getAvatarUrlFromUsername" : false,
Expand All @@ -43,9 +39,6 @@
"Package" : false,
"parentCall" : false,
"Promise" : false,
"Random" : false,
"ReactiveDict" : false,
"ReactiveVar" : false,
"Reload" : false,
"RocketChat" : true,
"RocketChatFile" : false,
Expand All @@ -54,7 +47,6 @@
"ServiceConfiguration" : false,
"Session" : false,
"Settings" : false,
"SHA256" : false,
"SideNav" : false,
"t" : false,
"TAPi18n" : false,
Expand All @@ -67,7 +59,6 @@
"Triggers" : false,
"UAParser" : false,
"visitor" : false,
"WebApp" : false,
"VideoRecorder" : false,
"VRecDialog" : false
}
Expand Down
1 change: 1 addition & 0 deletions client/routes/router.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* globals KonchatNotification */
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import s from 'underscore.string';

Blaze.registerHelper('pathFor', function(path, kw) {
Expand Down
1 change: 1 addition & 0 deletions client/startup/i18n.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* globals isRtl */

import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import moment from 'moment';

const currentLanguage = new ReactiveVar();
Expand Down
1 change: 1 addition & 0 deletions packages/chatpal-search/client/template/admin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import toastr from 'toastr';

Template.ChatpalAdmin.onCreated(function() {
Expand Down
1 change: 1 addition & 0 deletions packages/chatpal-search/client/template/result.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DateFormat } from 'meteor/rocketchat:lib';
import { ReactiveVar } from 'meteor/reactive-var';

Template.ChatpalSearchResultTemplate.onCreated(function() {
this.badRequest = new ReactiveVar(false);
Expand Down
1 change: 1 addition & 0 deletions packages/chatpal-search/server/provider/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { HTTP } from 'meteor/http';
import ChatpalLogger from '../utils/logger';
import { Random } from 'meteor/random';

Expand Down
2 changes: 2 additions & 0 deletions packages/chatpal-search/server/utils/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { HTTP } from 'meteor/http';

Meteor.methods({
'chatpalUtilsCreateKey'(email) {
try {
Expand Down
3 changes: 3 additions & 0 deletions packages/meteor-accounts-saml/saml_client.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/* globals cordova */
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { Random } from 'meteor/random';

if (!Accounts.saml) {
Accounts.saml = {};
}
Expand Down
2 changes: 2 additions & 0 deletions packages/meteor-accounts-saml/saml_rocketchat.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';

const logger = new Logger('steffo:meteor-accounts-saml', {
methods: {
updated: {
Expand Down
3 changes: 3 additions & 0 deletions packages/meteor-accounts-saml/saml_server.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* globals RoutePolicy, SAML */
/* jshint newcap: false */
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { Random } from 'meteor/random';
import { WebApp } from 'meteor/webapp';
import _ from 'underscore';

if (!Accounts.saml) {
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-2fa/client/TOTPPassword.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import toastr from 'toastr';

function reportError(error, callback) {
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-2fa/client/accountSecurity.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import toastr from 'toastr';
import qrcode from 'yaqrcode';

Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-2fa/server/lib/totp.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { SHA256 } from 'meteor/sha';
import { Random } from 'meteor/random';
import speakeasy from 'speakeasy';

RocketChat.TOTP = {
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-2fa/server/loginHandler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';

Accounts.registerLoginHandler('totp', function(options) {
if (!options.totp || !options.totp.code) {
return;
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-api/server/api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* global Restivus, DDP, DDPCommon */
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';

import _ from 'underscore';
const logger = new Logger('API', {});
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-api/server/helpers/getLoggedInUser.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Accounts } from 'meteor/accounts-base';

RocketChat.API.helperMethods.set('getLoggedInUser', function _getLoggedInUser() {
let user;

Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-api/server/v1/commands.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';

RocketChat.API.v1.addRoute('commands.get', { authRequired: true }, {
get() {
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-api/server/v1/push.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* globals Push */
import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';

RocketChat.API.v1.addRoute('push.token', { authRequired: true }, {
post() {
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-apps/client/admin/appInstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// if you're developing it and using a rest api with a particular parameter passed
// then it will be enabled by default for development reasons. The server prefers a url
// over the passed in body, so if both are found it will only use the url.
import { ReactiveVar } from 'meteor/reactive-var';

Template.appInstall.helpers({
appFile() {
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-apps/client/admin/appLogs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ReactiveVar } from 'meteor/reactive-var';
import moment from 'moment';
import hljs from 'highlight.js';

Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-apps/client/admin/appManage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import _ from 'underscore';
import s from 'underscore.string';
import toastr from 'toastr';
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-apps/client/admin/appWhatIsIt.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';

Template.appWhatIsIt.onCreated(function() {
this.isLoading = new ReactiveVar(false);
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-apps/client/admin/apps.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import toastr from 'toastr';
import { ReactiveVar } from 'meteor/reactive-var';

import { AppEvents } from '../communication';
const ENABLED_STATUS = ['auto_enabled', 'manually_enabled'];
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-apps/server/bridges/http.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { HTTP } from 'meteor/http';

export class AppHttpBridge {
async call(info) {
if (!info.request.content && typeof info.request.data === 'object') {
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-apps/server/bridges/messages.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';

export class AppMessageBridge {
constructor(orch) {
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-apps/server/communication/rest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { HTTP } from 'meteor/http';
import Busboy from 'busboy';

export class AppsRestApi {
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-apps/server/converters/messages.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Random } from 'meteor/random';

export class AppMessagesConverter {
constructor(orch) {
this.orch = orch;
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-assets/server/assets.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* global WebAppHashing, WebAppInternals */
import { Meteor } from 'meteor/meteor';
import { WebApp } from 'meteor/webapp';
import _ from 'underscore';

import sizeOf from 'image-size';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* globals ChatPermissions */
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';

Template.permissions.helpers({
role() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import toastr from 'toastr';

Template.permissionsRole.helpers({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* globals ChatSubscription */
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Random } from 'meteor/random';
import _ from 'underscore';
import toastr from 'toastr';

Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-autotranslate/server/autotranslate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { HTTP } from 'meteor/http';
import _ from 'underscore';
import s from 'underscore.string';

Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-cas/client/cas_client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { Random } from 'meteor/random';

const openCenteredPopup = function(url, width, height) {

Expand Down
3 changes: 3 additions & 0 deletions packages/rocketchat-cas/server/cas_server.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* globals RoutePolicy, logger */
/* jshint newcap: false */
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { Random } from 'meteor/random';
import { WebApp } from 'meteor/webapp';
import _ from 'underscore';

import fiber from 'fibers';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* global AutoComplete Deps */
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import toastr from 'toastr';
import resetSelection from '../resetSelection';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { ReactiveVar } from 'meteor/reactive-var';
import _ from 'underscore';

RocketChat.ChannelSettings = new class {
constructor() {
this.options = new ReactiveVar({});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* globals popover */
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import toastr from 'toastr';
import moment from 'moment';
import s from 'underscore.string';
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-cors/cors.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* globals WebAppInternals */
import { Meteor } from 'meteor/meteor';
import { WebApp } from 'meteor/webapp';
import _ from 'underscore';

import url from 'url';
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-crowd/client/loginHelper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';

Meteor.loginWithCrowd = function(...args) {
// Pull username and password
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-crowd/server/crowd.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* globals:CROWD:true */
/* eslint new-cap: [2, {"capIsNewExceptions": ["SHA256"]}] */
import { SHA256 } from 'meteor/sha';
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
const logger = new Logger('CROWD', {});

function fallbackDefaultAccountSystem(bind, username, password) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* globals OAuth*/
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { Random } from 'meteor/random';
import s from 'underscore.string';

// Request custom OAuth credentials for the user
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* globals OAuth*/
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { HTTP } from 'meteor/http';
import _ from 'underscore';

const logger = new Logger('CustomOAuth');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import s from 'underscore.string';
import { ReactiveVar } from 'meteor/reactive-var';

import { RocketChatTabBar } from 'meteor/rocketchat:lib';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';

Template.soundInfo.helpers({
name() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import _ from 'underscore';

class CustomSounds {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* globals RocketChatFileCustomSoundsInstance */
import { Meteor } from 'meteor/meteor';
import { WebApp } from 'meteor/webapp';
import _ from 'underscore';

Meteor.startup(function() {
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-emoji-custom/admin/adminEmoji.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import s from 'underscore.string';

import { ReactiveVar } from 'meteor/reactive-var';
import { RocketChatTabBar } from 'meteor/rocketchat:lib';

Template.adminEmoji.helpers({
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-emoji-custom/admin/emojiInfo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';

Template.emojiInfo.helpers({
name() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* globals RocketChatFileEmojiCustomInstance */
import { Meteor } from 'meteor/meteor';
import { WebApp } from 'meteor/webapp';
import _ from 'underscore';

Meteor.startup(function() {
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-emoji/client/emojiPicker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* globals Template, isSetNotNull */
import { ReactiveVar } from 'meteor/reactive-var';

const emojiCategories = {};
/**
* Turns category hash to a nice readable translated name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* globals FileUploadBase, UploadFS, fileUploadHandler:true */
/* exported fileUploadHandler */
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';

new UploadFS.Store({
collection: RocketChat.models.Uploads.model,
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-file-upload/lib/FileUploadBase.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* globals FileUploadBase:true, UploadFS */
/* exported FileUploadBase */
import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';
import _ from 'underscore';

UploadFS.config.defaultStorePermissions = new UploadFS.StorePermissions({
Expand Down
Loading

0 comments on commit 26d59c3

Please sign in to comment.