diff --git a/src/ui/public/paginated_table/paginated_table.js b/src/ui/public/paginated_table/paginated_table.js index 91947f9b060a..af6900584000 100644 --- a/src/ui/public/paginated_table/paginated_table.js +++ b/src/ui/public/paginated_table/paginated_table.js @@ -4,7 +4,7 @@ import paginatedTableTemplate from 'ui/paginated_table/paginated_table.html'; uiModules .get('kibana') .directive('paginatedTable', function ($filter) { - var orderBy = $filter('orderBy'); + let orderBy = $filter('orderBy'); return { restrict: 'E', @@ -19,14 +19,14 @@ uiModules }, controllerAs: 'paginatedTable', controller: function ($scope) { - var self = this; + let self = this; self.sort = { columnIndex: null, direction: null }; self.sortColumn = function (colIndex) { - var col = $scope.columns[colIndex]; + let col = $scope.columns[colIndex]; if (!col) return; if (col.sortable === false) return; @@ -36,7 +36,7 @@ uiModules if (self.sort.columnIndex !== colIndex) { sortDirection = 'asc'; } else { - var directions = { + let directions = { null: 'asc', 'asc': 'desc', 'desc': null @@ -56,7 +56,7 @@ uiModules } else { // use generic sort handler self.sort.getter = function (row) { - var value = row[index]; + let value = row[index]; if (value && value.value != null) value = value.value; if (typeof value === 'boolean') value = value ? 0 : 1; return value; @@ -75,7 +75,7 @@ uiModules return; } - var sort = self.sort; + let sort = self.sort; if (sort.direction == null) { $scope.sortedRows = $scope.rows.slice(0); } else { diff --git a/src/ui/public/parse_query/lib/from_user.js b/src/ui/public/parse_query/lib/from_user.js index c2eefd85c483..6aac1f93c0fe 100644 --- a/src/ui/public/parse_query/lib/from_user.js +++ b/src/ui/public/parse_query/lib/from_user.js @@ -1,7 +1,7 @@ import _ from 'lodash'; import DecorateQueryProvider from 'ui/courier/data_source/_decorate_query'; export default function GetQueryFromUser(es, Private) { - var decorateQuery = Private(DecorateQueryProvider); + let decorateQuery = Private(DecorateQueryProvider); /** * Take text from the user and make it into a query object @@ -13,7 +13,7 @@ export default function GetQueryFromUser(es, Private) { return decorateQuery({query_string: {query: text}}); } - var matchAll = getQueryStringQuery('*'); + let matchAll = getQueryStringQuery('*'); // If we get an empty object, treat it as a * if (_.isObject(text)) { diff --git a/src/ui/public/parse_query/parse_query.js b/src/ui/public/parse_query/parse_query.js index 8cae03fca433..148a2f962f79 100644 --- a/src/ui/public/parse_query/parse_query.js +++ b/src/ui/public/parse_query/parse_query.js @@ -4,7 +4,7 @@ import uiModules from 'ui/modules'; uiModules .get('kibana') .directive('parseQuery', function (Private) { - var fromUser = Private(ParseQueryLibFromUserProvider); + let fromUser = Private(ParseQueryLibFromUserProvider); return { restrict: 'A', @@ -13,7 +13,7 @@ uiModules 'ngModel': '=' }, link: function ($scope, elem, attr, ngModel) { - var init = function () { + let init = function () { $scope.ngModel = fromUser($scope.ngModel); }; diff --git a/src/ui/public/persisted_state/persisted_state.js b/src/ui/public/persisted_state/persisted_state.js index f31636b326b5..3975c20c24ea 100644 --- a/src/ui/public/persisted_state/persisted_state.js +++ b/src/ui/public/persisted_state/persisted_state.js @@ -5,7 +5,7 @@ import SimpleEmitter from 'ui/utils/simple_emitter'; import EventsProvider from 'ui/events'; export default function (Private) { - var Events = Private(EventsProvider); + let Events = Private(EventsProvider); function validateParent(parent, path) { if (path.length <= 0) { @@ -17,7 +17,7 @@ export default function (Private) { } function validateValue(value) { - var msg = 'State value must be a plain object'; + let msg = 'State value must be a plain object'; if (!value) return; if (!_.isPlainObject(value)) throw new errors.PersistedStateError(msg); } @@ -73,21 +73,21 @@ export default function (Private) { }; PersistedState.prototype.set = function (key, value) { - var params = prepSetParams(key, value, this._path); - var val = this._set(params.key, params.value); + let params = prepSetParams(key, value, this._path); + let val = this._set(params.key, params.value); this.emit('set'); return val; }; PersistedState.prototype.setSilent = function (key, value) { - var params = prepSetParams(key, value, this._path); + let params = prepSetParams(key, value, this._path); return this._set(params.key, params.value, true); }; PersistedState.prototype.reset = function (path) { - var keyPath = this._getIndex(path); - var origValue = _.get(this._defaultState, keyPath); - var currentValue = _.get(this._mergedState, keyPath); + let keyPath = this._getIndex(path); + let origValue = _.get(this._defaultState, keyPath); + let currentValue = _.get(this._mergedState, keyPath); if (_.isUndefined(origValue)) { this._cleanPath(path, this._mergedState); @@ -108,7 +108,7 @@ export default function (Private) { }; PersistedState.prototype.removeChild = function (path) { - var origValue = _.get(this._defaultState, this._getIndex(path)); + let origValue = _.get(this._defaultState, this._getIndex(path)); if (_.isUndefined(origValue)) { this.reset(path); @@ -139,19 +139,19 @@ export default function (Private) { }; PersistedState.prototype._getPartialIndex = function (key) { - var keyPath = this._getIndex(key); + let keyPath = this._getIndex(key); return keyPath.slice(this._path.length); }; PersistedState.prototype._cleanPath = function (path, stateTree) { - var partialPath = this._getPartialIndex(path); - var remove = true; + let partialPath = this._getPartialIndex(path); + let remove = true; // recursively delete value tree, when no other keys exist while (partialPath.length > 0) { - var lastKey = partialPath.splice(partialPath.length - 1, 1)[0]; - var statePath = this._path.concat(partialPath); - var stateVal = statePath.length > 0 ? _.get(stateTree, statePath) : stateTree; + let lastKey = partialPath.splice(partialPath.length - 1, 1)[0]; + let statePath = this._path.concat(partialPath); + let stateVal = statePath.length > 0 ? _.get(stateTree, statePath) : stateTree; // if stateVal isn't an object, do nothing if (!_.isPlainObject(stateVal)) return; @@ -162,13 +162,13 @@ export default function (Private) { }; PersistedState.prototype._getDefault = function () { - var def = (this._hasPath()) ? undefined : {}; + let def = (this._hasPath()) ? undefined : {}; return (this._parent ? this.get() : def); }; PersistedState.prototype._setPath = function (path) { - var isString = _.isString(path); - var isArray = _.isArray(path); + let isString = _.isString(path); + let isArray = _.isArray(path); if (!isString && !isArray) return []; return (isString) ? [this._getIndex(path)] : path; @@ -196,11 +196,11 @@ export default function (Private) { }; PersistedState.prototype._set = function (key, value, silent, initialChildState) { - var self = this; - var stateChanged = false; - var initialState = !this._initialized; - var keyPath = this._getIndex(key); - var hasKeyPath = keyPath.length > 0; + let self = this; + let stateChanged = false; + let initialState = !this._initialized; + let keyPath = this._getIndex(key); + let hasKeyPath = keyPath.length > 0; // if this is the initial state value, save value as the default if (initialState) { @@ -226,7 +226,7 @@ export default function (Private) { } } else { // check for changes at path, emit an event when different - var curVal = hasKeyPath ? this.get(keyPath) : this._mergedState; + let curVal = hasKeyPath ? this.get(keyPath) : this._mergedState; stateChanged = !_.isEqual(curVal, value); if (!initialChildState) { @@ -243,11 +243,11 @@ export default function (Private) { } // update the merged state value - var targetObj = this._mergedState || _.cloneDeep(this._defaultState); - var sourceObj = _.merge({}, this._defaultChildState, this._changedState); + let targetObj = this._mergedState || _.cloneDeep(this._defaultState); + let sourceObj = _.merge({}, this._defaultChildState, this._changedState); // handler arguments are (targetValue, sourceValue, key, target, source) - var mergeMethod = function (targetValue, sourceValue, mergeKey) { + let mergeMethod = function (targetValue, sourceValue, mergeKey) { // if not initial state, skip default merge method (ie. return value, see note below) if (!initialState && !initialChildState && _.isEqual(keyPath, self._getIndex(mergeKey))) { // use the sourceValue or fall back to targetValue diff --git a/src/ui/public/private/private.js b/src/ui/public/private/private.js index ead3fbbde6c3..4c371da82cc4 100644 --- a/src/ui/public/private/private.js +++ b/src/ui/public/private/private.js @@ -23,10 +23,10 @@ import uiModules from 'ui/modules'; * ```js * define(function (require) { * return function ServerHealthProvider(Private, Promise) { - * var ping = Private(require('ui/ping')); + * let ping = Private(require('ui/ping')); * return { * check: Promise.method(function () { - * var attempts = 0; + * let attempts = 0; * return (function attempt() { * attempts += 1; * return ping.ping() @@ -87,7 +87,7 @@ import uiModules from 'ui/modules'; */ -var nextId = _.partial(_.uniqueId, 'privateProvider#'); +let nextId = _.partial(_.uniqueId, 'privateProvider#'); function name(fn) { return fn.name || fn.toString().split('\n').shift(); @@ -95,11 +95,11 @@ function name(fn) { uiModules.get('kibana') .provider('Private', function () { - var provider = this; + let provider = this; // one cache/swaps per Provider - var cache = {}; - var swaps = {}; + let cache = {}; + let swaps = {}; // return the uniq id for this function function identify(fn) { @@ -117,15 +117,15 @@ uiModules.get('kibana') }; provider.swap = function (fn, prov) { - var id = identify(fn); + let id = identify(fn); swaps[id] = prov; }; provider.$get = ['$injector', function PrivateFactory($injector) { // prevent circular deps by tracking where we came from - var privPath = []; - var pathToString = function () { + let privPath = []; + let pathToString = function () { return privPath.map(name).join(' -> '); }; @@ -140,8 +140,8 @@ uiModules.get('kibana') privPath.push(prov); - var context = {}; - var instance = $injector.invoke(prov, context, locals); + let context = {}; + let instance = $injector.invoke(prov, context, locals); if (!_.isObject(instance)) instance = context; privPath.pop(); @@ -167,7 +167,7 @@ uiModules.get('kibana') // main api, get the appropriate instance for a provider function Private(prov) { - var id = identify(prov); + let id = identify(prov); let $delegateId; let $delegateProv; diff --git a/src/ui/public/promises/promises.js b/src/ui/public/promises/promises.js index af9f21212d6a..a2d1ef5249c2 100644 --- a/src/ui/public/promises/promises.js +++ b/src/ui/public/promises/promises.js @@ -1,7 +1,7 @@ import _ from 'lodash'; import uiModules from 'ui/modules'; -var module = uiModules.get('kibana'); +let module = uiModules.get('kibana'); // Provides a tiny subset of the excelent API from // bluebird, reimplemented using the $q service @@ -9,7 +9,7 @@ module.service('Promise', function ($q, $timeout) { function Promise(fn) { if (typeof this === 'undefined') throw new Error('Promise constructor must be called with "new"'); - var defer = $q.defer(); + let defer = $q.defer(); try { fn(defer.resolve, defer.reject); } catch (e) { @@ -20,12 +20,12 @@ module.service('Promise', function ($q, $timeout) { Promise.all = Promise.props = $q.all; Promise.resolve = function (val) { - var defer = $q.defer(); + let defer = $q.defer(); defer.resolve(val); return defer.promise; }; Promise.reject = function (reason) { - var defer = $q.defer(); + let defer = $q.defer(); defer.reject(reason); return defer.promise; }; @@ -36,7 +36,7 @@ module.service('Promise', function ($q, $timeout) { }; Promise.method = function (fn) { return function () { - var args = Array.prototype.slice.call(arguments); + let args = Array.prototype.slice.call(arguments); return Promise.try(fn, args, this); }; }; @@ -64,7 +64,7 @@ module.service('Promise', function ($q, $timeout) { return obj && typeof obj.then === 'function'; }; Promise.halt = _.once(function () { - var promise = new Promise(); + let promise = new Promise(); promise.then = _.constant(promise); promise.catch = _.constant(promise); return promise; @@ -155,7 +155,7 @@ module.factory('PromiseEmitter', function (Promise) { * @return {Promise} */ function PromiseEmitter(fn, handler) { - var prom = new Promise(fn); + let prom = new Promise(fn); if (!handler) return prom; diff --git a/src/ui/public/reflow_watcher/reflow_watcher.js b/src/ui/public/reflow_watcher/reflow_watcher.js index 6a6bcb4aee1e..2592cc9e4bc1 100644 --- a/src/ui/public/reflow_watcher/reflow_watcher.js +++ b/src/ui/public/reflow_watcher/reflow_watcher.js @@ -4,12 +4,12 @@ import _ from 'lodash'; import EventsProvider from 'ui/events'; export default function ReflowWatcherService(Private, $rootScope, $http) { - var EventEmitter = Private(EventsProvider); - var $body = $(document.body); - var $window = $(window); + let EventEmitter = Private(EventsProvider); + let $body = $(document.body); + let $window = $(window); - var MOUSE_EVENTS = 'mouseup'; - var WINDOW_EVENTS = 'resize'; + let MOUSE_EVENTS = 'mouseup'; + let WINDOW_EVENTS = 'resize'; _.class(ReflowWatcher).inherits(EventEmitter); /** diff --git a/src/ui/public/registry/_registry.js b/src/ui/public/registry/_registry.js index 94c2bf6a3a96..396ad08237ed 100644 --- a/src/ui/public/registry/_registry.js +++ b/src/ui/public/registry/_registry.js @@ -1,7 +1,7 @@ import _ from 'lodash'; import IndexedArray from 'ui/indexed_array'; import RegistryVisTypesProvider from 'ui/registry/vis_types'; -var notPropsOptNames = IndexedArray.OPT_NAMES.concat('constructor'); +let notPropsOptNames = IndexedArray.OPT_NAMES.concat('constructor'); /** * Create a registry, which is just a Private module provider. @@ -16,7 +16,7 @@ var notPropsOptNames = IndexedArray.OPT_NAMES.concat('constructor'); * * + register a module * ```js - * var registry = require('ui/registry/vis_types'); + * let registry = require('ui/registry/vis_types'); * registry.add(function InjectablePrivateModule($http, Promise) { * ... * }) @@ -24,7 +24,7 @@ var notPropsOptNames = IndexedArray.OPT_NAMES.concat('constructor'); * * + get all registered modules * ```js - * var visTypes = Private(RegistryVisTypesProvider); + * let visTypes = Private(RegistryVisTypesProvider); * ``` * * @@ -49,10 +49,10 @@ var notPropsOptNames = IndexedArray.OPT_NAMES.concat('constructor'); export default function createRegistry(spec) { spec = spec || {}; - var constructor = _.has(spec, 'constructor') && spec.constructor; - var iaOpts = _.defaults(_.pick(spec, IndexedArray.OPT_NAMES), { index: ['name'] }); - var props = _.omit(spec, notPropsOptNames); - var providers = []; + let constructor = _.has(spec, 'constructor') && spec.constructor; + let iaOpts = _.defaults(_.pick(spec, IndexedArray.OPT_NAMES), { index: ['name'] }); + let props = _.omit(spec, notPropsOptNames); + let providers = []; /** * This is the Private module that will be instanciated by @@ -62,10 +62,10 @@ export default function createRegistry(spec) { * that were registered, the registry spec * defines how things will be indexed. */ - var registry = function (Private, $injector) { + let registry = function (Private, $injector) { // index all of the modules iaOpts.initialSet = providers.map(Private); - var modules = new IndexedArray(iaOpts); + let modules = new IndexedArray(iaOpts); // mixin other props _.assign(modules, props); diff --git a/src/ui/public/registry/field_formats.js b/src/ui/public/registry/field_formats.js index 7b376f2b8a4d..941353001b71 100644 --- a/src/ui/public/registry/field_formats.js +++ b/src/ui/public/registry/field_formats.js @@ -7,7 +7,7 @@ export default uiRegistry({ group: ['fieldType'], constructor: function (config, $rootScope) { - var self = this; + let self = this; let defaultMap; function init() { @@ -56,7 +56,7 @@ export default uiRegistry({ * @return {FieldFormat} */ self.getInstance = _.memoize(function (formatId) { - var FieldFormat = self.byId[formatId]; + let FieldFormat = self.byId[formatId]; return new FieldFormat(); }); @@ -67,8 +67,8 @@ export default uiRegistry({ * @return {FieldFormat} */ self.getDefaultInstance = _.memoize(function (fieldType) { - var conf = self.getDefaultConfig(fieldType); - var FieldFormat = self.byId[conf.id]; + let conf = self.getDefaultConfig(fieldType); + let FieldFormat = self.byId[conf.id]; return new FieldFormat(conf.params); }); diff --git a/src/ui/public/routes/route_manager.js b/src/ui/public/routes/route_manager.js index 01ec0a6aa644..832990ba6de6 100644 --- a/src/ui/public/routes/route_manager.js +++ b/src/ui/public/routes/route_manager.js @@ -4,16 +4,16 @@ import wrapRouteWithPrep from './wrap_route_with_prep'; import RouteSetupManager from './route_setup_manager'; function RouteManager() { - var self = this; - var setup = new RouteSetupManager(); - var when = []; - var defaults = []; + let self = this; + let setup = new RouteSetupManager(); + let when = []; + let defaults = []; let otherwise; self.config = function ($routeProvider) { when.forEach(function (args) { - var path = args[0]; - var route = args[1] || {}; + let path = args[0]; + let route = args[1] || {}; // merge in any defaults defaults.forEach(function (args) { diff --git a/src/ui/public/routes/route_setup_manager.js b/src/ui/public/routes/route_setup_manager.js index 28e486d80fc8..1cb89fe45645 100644 --- a/src/ui/public/routes/route_setup_manager.js +++ b/src/ui/public/routes/route_setup_manager.js @@ -66,7 +66,7 @@ module.exports = class RouteSetupManager { ) .then(() => { // wait for the queue to fill up, then do all the work - var defer = Promise.defer(); + let defer = Promise.defer(); userWork.resolveWhenFull(defer); return defer.promise.then(() => Promise.all(userWork.doWork())); diff --git a/src/ui/public/routes/routes.js b/src/ui/public/routes/routes.js index 7bdafc6b6930..cbb9878df7a1 100644 --- a/src/ui/public/routes/routes.js +++ b/src/ui/public/routes/routes.js @@ -1,7 +1,7 @@ import RouteManager from './route_manager'; import 'angular-route/angular-route'; import uiModules from 'ui/modules'; -var defaultRouteManager = new RouteManager(); +let defaultRouteManager = new RouteManager(); module.exports = { ...defaultRouteManager, diff --git a/src/ui/public/routes/work_queue.js b/src/ui/public/routes/work_queue.js index eb2aa086588f..40f429432782 100644 --- a/src/ui/public/routes/work_queue.js +++ b/src/ui/public/routes/work_queue.js @@ -1,10 +1,10 @@ import _ from 'lodash'; function WorkQueue() { - var q = this; + let q = this; - var work = []; - var fullDefers = []; + let work = []; + let fullDefers = []; q.limit = 0; Object.defineProperty(q, 'length', { @@ -13,13 +13,13 @@ function WorkQueue() { } }); - var resolve = function (defers) { + let resolve = function (defers) { return defers.splice(0).map(function (defer) { return defer.resolve(); }); }; - var checkIfFull = function () { + let checkIfFull = function () { if (work.length >= q.limit && fullDefers.length) { resolve(fullDefers); } @@ -31,7 +31,7 @@ function WorkQueue() { }; q.doWork = function () { - var resps = resolve(work); + let resps = resolve(work); checkIfFull(); return resps; }; diff --git a/src/ui/public/routes/wrap_route_with_prep.js b/src/ui/public/routes/wrap_route_with_prep.js index e5156eb4df2c..5c4b98a82d0a 100644 --- a/src/ui/public/routes/wrap_route_with_prep.js +++ b/src/ui/public/routes/wrap_route_with_prep.js @@ -7,11 +7,11 @@ import errors from 'ui/errors'; function wrapRouteWithPrep(route, setup) { if (!route.resolve && route.redirectTo) return; - var userWork = new WorkQueue(); + let userWork = new WorkQueue(); // the point at which we will consider the queue "full" userWork.limit = _.keys(route.resolve).length; - var resolve = { + let resolve = { __prep__: function ($injector) { return $injector.invoke(setup.doWork, setup, { userWork }); } @@ -21,7 +21,7 @@ function wrapRouteWithPrep(route, setup) { // prep is complete _.forOwn(route.resolve || {}, function (expr, name) { resolve[name] = function ($injector, Promise) { - var defer = Promise.defer(); + let defer = Promise.defer(); userWork.push(defer); return defer.promise.then(function () { return $injector[angular.isString(expr) ? 'get' : 'invoke'](expr); diff --git a/src/ui/public/stack_trace_mapper/set_error_stack.js b/src/ui/public/stack_trace_mapper/set_error_stack.js index 8ce562f0fbd8..ff6f5b783845 100644 --- a/src/ui/public/stack_trace_mapper/set_error_stack.js +++ b/src/ui/public/stack_trace_mapper/set_error_stack.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -var err = new Error(); +let err = new Error(); try { setByAssignment(err, 'john'); } catch (e) {} // eslint-disable-line // err.stack is not always writeable, so we @@ -13,7 +13,7 @@ if (err.stack === 'john') module.exports = setByAssignment; else module.exports = setByShadowing; function setByShadowing(err, stack) { - var props = _.mapValues(err, function (val) { + let props = _.mapValues(err, function (val) { return { enumerable: true, value: val diff --git a/src/ui/public/stack_trace_mapper/stack_line_format.js b/src/ui/public/stack_trace_mapper/stack_line_format.js index e1486aee635e..7d4c2ebe476c 100644 --- a/src/ui/public/stack_trace_mapper/stack_line_format.js +++ b/src/ui/public/stack_trace_mapper/stack_line_format.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -var opts = [ +let opts = [ /@((?:[!#$&-;=?-\[\]_a-z~]|%[0-9a-f]{2})+\.js)\:(\d+)(?:\:(\d+)|())/ig, /(?: \(|at )((?:[!#$&-;=?-\[\]_a-z~]|%[0-9a-f]{2})+\.js)\:(\d+)(?:\:(\d+)|())/ig ]; @@ -8,7 +8,7 @@ var opts = [ let sample; try { throw new Error('msg'); } catch (e) { sample = e.stack; } -var format = _.find(opts, function (format) { +let format = _.find(opts, function (format) { return format.test(sample); }); diff --git a/src/ui/public/stack_trace_mapper/stack_trace_mapper.js b/src/ui/public/stack_trace_mapper/stack_trace_mapper.js index fbf8fa05f29a..85b436618433 100644 --- a/src/ui/public/stack_trace_mapper/stack_trace_mapper.js +++ b/src/ui/public/stack_trace_mapper/stack_trace_mapper.js @@ -22,7 +22,7 @@ StackTraceMapper.prototype.init = function (mapUrls) { StackTraceMapper.prototype.mapError = function (err) { if (!stackLineFormat || !err.stack) return err; - var stack = err.stack.replace(stackLineFormat, this.mapLine); + let stack = err.stack.replace(stackLineFormat, this.mapLine); return setErrorStack(err, stack); }; @@ -39,10 +39,10 @@ StackTraceMapper.prototype.getMapFor = function (url) { StackTraceMapper.prototype.loadMaps = function (mapUrls) { mapUrls = _.clone(mapUrls || {}); - var maps = this.maps; + let maps = this.maps; $('script[src][src-map]').each(function () { - var $el = $(this); + let $el = $(this); mapUrls[$el.attr('src')] = $el.attr('src-map'); }); diff --git a/src/ui/public/stack_trace_mapper/translate_stack_line.js b/src/ui/public/stack_trace_mapper/translate_stack_line.js index 103ef5d98964..f19f64cfe618 100644 --- a/src/ui/public/stack_trace_mapper/translate_stack_line.js +++ b/src/ui/public/stack_trace_mapper/translate_stack_line.js @@ -3,17 +3,17 @@ import _ from 'lodash'; module.exports = function (map, match, filename, line, col) { if (!map) return match; - var position = { + let position = { line: parseFloat(line) || 0, column: parseFloat(col) || 0 }; - var srcPosition = map.smc.originalPositionFor(position); + let srcPosition = map.smc.originalPositionFor(position); if (!srcPosition || !srcPosition.source) return match; - var srcFilename = srcPosition.source; - var srcLine = srcPosition.line; - var srcCol = srcPosition.column; + let srcFilename = srcPosition.source; + let srcLine = srcPosition.line; + let srcCol = srcPosition.column; if (srcCol === 0 && position.column) { // TODO: teach sourcemaps correct column @@ -26,10 +26,10 @@ module.exports = function (map, match, filename, line, col) { // fold the components into the original match, so that supporting // characters (parens, periods, etc) from the format are kept, and so // we don't accidentally replace the wrong part we use splitting and consumption - var resp = ''; - var remainingResp = match; - var fold = function (replace, replacement) { - var wrappingContent = remainingResp.split(replace); + let resp = ''; + let remainingResp = match; + let fold = function (replace, replacement) { + let wrappingContent = remainingResp.split(replace); resp += wrappingContent.shift() + replacement; remainingResp = wrappingContent.join(replace); }; diff --git a/src/ui/public/state_management/_state_sync.js b/src/ui/public/state_management/_state_sync.js index d94b5f6ffd72..61dc9011f76a 100644 --- a/src/ui/public/state_management/_state_sync.js +++ b/src/ui/public/state_management/_state_sync.js @@ -7,8 +7,8 @@ import rison from 'ui/utils/rison'; export default function ($location) { // feed in some of the private state from globalState return function (globalState, updateListeners, app) { - var getAppStash = function (search) { - var appStash = search._a && rison.decode(search._a); + let getAppStash = function (search) { + let appStash = search._a && rison.decode(search._a); if (app.current) { // Apply the defaults to appStash appStash = _.defaults(appStash || {}, app.defaults); @@ -16,20 +16,20 @@ export default function ($location) { return appStash; }; - var diffTrans = function (trans) { - var obj = trans[0]; - var update = trans[1]; + let diffTrans = function (trans) { + let obj = trans[0]; + let update = trans[1]; - var diff = {}; + let diff = {}; // the keys that are currently set on obj, excluding methods - var objKeys = Object.keys(obj).filter(function (key) { + let objKeys = Object.keys(obj).filter(function (key) { return typeof obj[key] !== 'function'; }); if (update) { // the keys obj should have after applying the update - var updateKeys = diff.keys = Object.keys(update).filter(function (key) { + let updateKeys = diff.keys = Object.keys(update).filter(function (key) { return typeof update[key] !== 'function'; }); @@ -52,8 +52,8 @@ export default function ($location) { return diff; }; - var notify = function (trans, diff) { - var listeners = null; + let notify = function (trans, diff) { + let listeners = null; if (trans[0] === app.current) { listeners = app.listeners; @@ -66,11 +66,11 @@ export default function ($location) { }); }; - var applyDiff = function (trans, diff) { + let applyDiff = function (trans, diff) { if (!diff.all.length) return; - var obj = trans[0]; - var update = trans[1]; + let obj = trans[0]; + let update = trans[1]; diff.remove.forEach(function (key) { delete obj[key]; @@ -81,13 +81,13 @@ export default function ($location) { }); }; - var syncTrans = function (trans, forceNotify) { + let syncTrans = function (trans, forceNotify) { // obj that will be modified by update(trans[1]) // if it is empty, we can skip it all - var skipWrite = !trans[0]; + let skipWrite = !trans[0]; trans[0] = trans[0] || {}; - var diff = diffTrans(trans); + let diff = diffTrans(trans); if (!skipWrite && (forceNotify || diff.all.length)) { applyDiff(trans, diff); notify(trans, diff); @@ -98,17 +98,17 @@ export default function ($location) { return { // sync by pushing to the url push: function (forceNotify) { - var search = $location.search(); + let search = $location.search(); - var appStash = getAppStash(search) || {}; - var globalStash = search._g ? rison.decode(search._g) : {}; + let appStash = getAppStash(search) || {}; + let globalStash = search._g ? rison.decode(search._g) : {}; - var res = _.mapValues({ + let res = _.mapValues({ app: [appStash, app.current], global: [globalStash, globalState] }, function (trans, key) { - var diff = syncTrans(trans, forceNotify); - var urlKey = '_' + key.charAt(0); + let diff = syncTrans(trans, forceNotify); + let urlKey = '_' + key.charAt(0); if (diff.keys.length === 0) { delete search[urlKey]; } else { @@ -122,10 +122,10 @@ export default function ($location) { }, // sync by pulling from the url pull: function (forceNotify) { - var search = $location.search(); + let search = $location.search(); - var appStash = getAppStash(search); - var globalStash = search._g && rison.decode(search._g); + let appStash = getAppStash(search); + let globalStash = search._g && rison.decode(search._g); return _.mapValues({ app: [app.current, appStash], diff --git a/src/ui/public/state_management/app_state.js b/src/ui/public/state_management/app_state.js index 5f20cacef96a..8cb3320bf482 100644 --- a/src/ui/public/state_management/app_state.js +++ b/src/ui/public/state_management/app_state.js @@ -2,11 +2,11 @@ import _ from 'lodash'; import modules from 'ui/modules'; import StateManagementStateProvider from 'ui/state_management/state'; import PersistedStatePersistedStateProvider from 'ui/persisted_state/persisted_state'; -var urlParam = '_a'; +let urlParam = '_a'; function AppStateProvider(Private, $rootScope, getAppState) { - var State = Private(StateManagementStateProvider); - var PersistedState = Private(PersistedStatePersistedStateProvider); + let State = Private(StateManagementStateProvider); + let PersistedState = Private(PersistedStatePersistedStateProvider); let persistedStates; let eventUnsubscribers; @@ -30,31 +30,31 @@ function AppStateProvider(Private, $rootScope, getAppState) { AppState.prototype.makeStateful = function (prop) { if (persistedStates[prop]) return persistedStates[prop]; - var self = this; + let self = this; // set up the ui state persistedStates[prop] = new PersistedState(); // update the app state when the stateful instance changes - var updateOnChange = function () { - var replaceState = false; // TODO: debouncing logic + let updateOnChange = function () { + let replaceState = false; // TODO: debouncing logic self[prop] = persistedStates[prop].getChanges(); self.save(replaceState); }; - var handlerOnChange = (method) => persistedStates[prop][method]('change', updateOnChange); + let handlerOnChange = (method) => persistedStates[prop][method]('change', updateOnChange); handlerOnChange('on'); eventUnsubscribers.push(() => handlerOnChange('off')); // update the stateful object when the app state changes - var persistOnChange = function (changes) { + let persistOnChange = function (changes) { if (!changes) return; if (changes.indexOf(prop) !== -1) { persistedStates[prop].set(self[prop]); } }; - var handlePersist = (method) => this[method]('fetch_with_changes', persistOnChange); + let handlePersist = (method) => this[method]('fetch_with_changes', persistOnChange); handlePersist('on'); eventUnsubscribers.push(() => handlePersist('off')); @@ -80,7 +80,7 @@ modules.get('kibana/global_state') // Checks to see if the appState might already exist, even if it hasn't been newed up get.previouslyStored = function () { - var search = $location.search(); + let search = $location.search(); return search[urlParam] ? true : false; }; diff --git a/src/ui/public/state_management/global_state.js b/src/ui/public/state_management/global_state.js index f76f93a51de0..fcc3d202b66d 100644 --- a/src/ui/public/state_management/global_state.js +++ b/src/ui/public/state_management/global_state.js @@ -5,10 +5,10 @@ import rison from 'ui/utils/rison'; import StateManagementStateProvider from 'ui/state_management/state'; import uiModules from 'ui/modules'; -var module = uiModules.get('kibana/global_state'); +let module = uiModules.get('kibana/global_state'); module.service('globalState', function (Private, $rootScope, $location) { - var State = Private(StateManagementStateProvider); + let State = Private(StateManagementStateProvider); _.class(GlobalState).inherits(State); function GlobalState(defaults) { diff --git a/src/ui/public/state_management/state.js b/src/ui/public/state_management/state.js index dfc0f8c62b7e..6fa8c1f3356b 100644 --- a/src/ui/public/state_management/state.js +++ b/src/ui/public/state_management/state.js @@ -7,13 +7,13 @@ import Notifier from 'ui/notify/notifier'; export default function StateProvider(Private, $rootScope, $location) { - var Events = Private(EventsProvider); + let Events = Private(EventsProvider); _.class(State).inherits(Events); function State(urlParam, defaults) { State.Super.call(this); - var self = this; + let self = this; self.setDefaults(defaults); self._urlParam = urlParam || '_s'; @@ -40,11 +40,11 @@ export default function StateProvider(Private, $rootScope, $location) { } State.prototype._readFromURL = function () { - var search = $location.search(); + let search = $location.search(); try { return search[this._urlParam] ? rison.decode(search[this._urlParam]) : null; } catch (e) { - var notify = new Notifier(); + let notify = new Notifier(); notify.error('Unable to parse URL'); search[this._urlParam] = rison.encode(this._defaults); $location.search(search).replace(); @@ -57,7 +57,7 @@ export default function StateProvider(Private, $rootScope, $location) { * @returns {void} */ State.prototype.fetch = function () { - var stash = this._readFromURL(); + let stash = this._readFromURL(); // nothing to read from the url? save if ordered to persist if (stash === null) { @@ -70,7 +70,7 @@ export default function StateProvider(Private, $rootScope, $location) { _.defaults(stash, this._defaults); // apply diff to state from stash, will change state in place via side effect - var diffResults = applyDiff(this, stash); + let diffResults = applyDiff(this, stash); if (diffResults.keys.length) { this.emit('fetch_with_changes', diffResults.keys); @@ -82,8 +82,8 @@ export default function StateProvider(Private, $rootScope, $location) { * @returns {void} */ State.prototype.save = function (replace) { - var stash = this._readFromURL(); - var state = this.toObject(); + let stash = this._readFromURL(); + let state = this.toObject(); replace = replace || false; if (!stash) { @@ -93,14 +93,14 @@ export default function StateProvider(Private, $rootScope, $location) { _.defaults(state, this._defaults); // apply diff to state from stash, will change state in place via side effect - var diffResults = applyDiff(stash, state); + let diffResults = applyDiff(stash, state); if (diffResults.keys.length) { this.emit('save_with_changes', diffResults.keys); } // persist the state in the URL - var search = $location.search(); + let search = $location.search(); search[this._urlParam] = this.toRISON(); if (replace) { $location.search(search).replace(); @@ -125,7 +125,7 @@ export default function StateProvider(Private, $rootScope, $location) { State.prototype.reset = function () { // apply diff to _attributes from defaults, this is side effecting so // it will change the state in place. - var diffResults = applyDiff(this, this._defaults); + let diffResults = applyDiff(this, this._defaults); if (diffResults.keys.length) { this.emit('reset_with_changes', diffResults.keys); } diff --git a/src/ui/public/storage/storage.js b/src/ui/public/storage/storage.js index a5c3ad10aeed..aa043158724b 100644 --- a/src/ui/public/storage/storage.js +++ b/src/ui/public/storage/storage.js @@ -2,7 +2,7 @@ import modules from 'ui/modules'; import angular from 'angular'; function Storage(store) { - var self = this; + let self = this; self.store = store; self.get = function (key) { @@ -30,7 +30,7 @@ function Storage(store) { }; } -var createService = function (type) { +let createService = function (type) { return function ($window) { return new Storage($window[type]); }; diff --git a/src/ui/public/stringify/types/_numeral.js b/src/ui/public/stringify/types/_numeral.js index 2f448010caa2..ee55f155b434 100644 --- a/src/ui/public/stringify/types/_numeral.js +++ b/src/ui/public/stringify/types/_numeral.js @@ -3,9 +3,9 @@ import 'ui/field_format_editor/numeral/numeral'; import IndexPatternsFieldFormatProvider from 'ui/index_patterns/_field_format/field_format'; import BoundToConfigObjProvider from 'ui/bound_to_config_obj'; export default function AbstractNumeralFormatProvider(Private) { - var FieldFormat = Private(IndexPatternsFieldFormatProvider); - var BoundToConfigObj = Private(BoundToConfigObjProvider); - var numeral = require('numeral')(); + let FieldFormat = Private(IndexPatternsFieldFormatProvider); + let BoundToConfigObj = Private(BoundToConfigObjProvider); + let numeral = require('numeral')(); _.class(Numeral).inherits(FieldFormat); function Numeral(params) { diff --git a/src/ui/public/stringify/types/bytes.js b/src/ui/public/stringify/types/bytes.js index d1fdcaf271ea..88e72823a4a4 100644 --- a/src/ui/public/stringify/types/bytes.js +++ b/src/ui/public/stringify/types/bytes.js @@ -1,7 +1,7 @@ import StringifyTypesNumeralProvider from 'ui/stringify/types/_numeral'; export default function BytesFormatProvider(Private) { - var Numeral = Private(StringifyTypesNumeralProvider); + let Numeral = Private(StringifyTypesNumeralProvider); return Numeral.factory({ id: 'bytes', title: 'Bytes', diff --git a/src/ui/public/stringify/types/date.js b/src/ui/public/stringify/types/date.js index 4140c55d4d0f..d88ff3ed4d91 100644 --- a/src/ui/public/stringify/types/date.js +++ b/src/ui/public/stringify/types/date.js @@ -5,8 +5,8 @@ import IndexPatternsFieldFormatProvider from 'ui/index_patterns/_field_format/fi import BoundToConfigObjProvider from 'ui/bound_to_config_obj'; import dateTemplate from 'ui/stringify/editors/date.html'; export default function DateTimeFormatProvider(Private) { - var FieldFormat = Private(IndexPatternsFieldFormatProvider); - var BoundToConfigObj = Private(BoundToConfigObjProvider); + let FieldFormat = Private(IndexPatternsFieldFormatProvider); + let BoundToConfigObj = Private(BoundToConfigObjProvider); _.class(DateTime).inherits(FieldFormat); @@ -27,7 +27,7 @@ export default function DateTimeFormatProvider(Private) { template: dateTemplate, controllerAs: 'cntrl', controller: function ($interval, $scope) { - var self = this; + let self = this; self.sampleInputs = [ Date.now(), +moment().startOf('year'), @@ -43,11 +43,11 @@ export default function DateTimeFormatProvider(Private) { DateTime.prototype._convert = function (val) { // don't give away our ref to converter so // we can hot-swap when config changes - var pattern = this.param('pattern'); - var timezone = this.param('timezone'); + let pattern = this.param('pattern'); + let timezone = this.param('timezone'); - var timezoneChanged = this._timeZone !== timezone; - var datePatternChanged = this._memoizedPattern !== pattern; + let timezoneChanged = this._timeZone !== timezone; + let datePatternChanged = this._memoizedPattern !== pattern; if (timezoneChanged || datePatternChanged) { this._timeZone = timezone; this._memoizedPattern = pattern; diff --git a/src/ui/public/stringify/types/ip.js b/src/ui/public/stringify/types/ip.js index 877bd1f464dc..b80c1951bad5 100644 --- a/src/ui/public/stringify/types/ip.js +++ b/src/ui/public/stringify/types/ip.js @@ -1,7 +1,7 @@ import _ from 'lodash'; import IndexPatternsFieldFormatProvider from 'ui/index_patterns/_field_format/field_format'; export default function IpFormatProvider(Private) { - var FieldFormat = Private(IndexPatternsFieldFormatProvider); + let FieldFormat = Private(IndexPatternsFieldFormatProvider); _.class(Ip).inherits(FieldFormat); function Ip(params) { diff --git a/src/ui/public/stringify/types/number.js b/src/ui/public/stringify/types/number.js index 7ffd611b4137..e9d12b1d241f 100644 --- a/src/ui/public/stringify/types/number.js +++ b/src/ui/public/stringify/types/number.js @@ -1,7 +1,7 @@ import StringifyTypesNumeralProvider from 'ui/stringify/types/_numeral'; export default function NumberFormatProvider(Private) { - var Numeral = Private(StringifyTypesNumeralProvider); + let Numeral = Private(StringifyTypesNumeralProvider); return Numeral.factory({ id: 'number', title: 'Number', diff --git a/src/ui/public/stringify/types/percent.js b/src/ui/public/stringify/types/percent.js index 02a8be502f6d..f309604ef0f0 100644 --- a/src/ui/public/stringify/types/percent.js +++ b/src/ui/public/stringify/types/percent.js @@ -2,8 +2,8 @@ import _ from 'lodash'; import BoundToConfigObjProvider from 'ui/bound_to_config_obj'; import StringifyTypesNumeralProvider from 'ui/stringify/types/_numeral'; export default function PercentFormatProvider(Private) { - var BoundToConfigObj = Private(BoundToConfigObjProvider); - var Numeral = Private(StringifyTypesNumeralProvider); + let BoundToConfigObj = Private(BoundToConfigObjProvider); + let Numeral = Private(StringifyTypesNumeralProvider); return Numeral.factory({ id: 'percent', diff --git a/src/ui/public/stringify/types/source.js b/src/ui/public/stringify/types/source.js index b4c9473921e9..9662bfebef4e 100644 --- a/src/ui/public/stringify/types/source.js +++ b/src/ui/public/stringify/types/source.js @@ -3,8 +3,8 @@ import noWhiteSpace from 'ui/utils/no_white_space'; import angular from 'angular'; import IndexPatternsFieldFormatProvider from 'ui/index_patterns/_field_format/field_format'; export default function _SourceFormatProvider(Private, shortDotsFilter) { - var FieldFormat = Private(IndexPatternsFieldFormatProvider); - var template = _.template(noWhiteSpace(require('ui/stringify/types/_source.html'))); + let FieldFormat = Private(IndexPatternsFieldFormatProvider); + let template = _.template(noWhiteSpace(require('ui/stringify/types/_source.html'))); _.class(Source).inherits(FieldFormat); function Source(params) { @@ -20,15 +20,15 @@ export default function _SourceFormatProvider(Private, shortDotsFilter) { html: function sourceToHtml(source, field, hit) { if (!field) return this.getConverter('text')(source, field, hit); - var highlights = (hit && hit.highlight) || {}; - var formatted = field.indexPattern.formatHit(hit); - var highlightPairs = []; - var sourcePairs = []; + let highlights = (hit && hit.highlight) || {}; + let formatted = field.indexPattern.formatHit(hit); + let highlightPairs = []; + let sourcePairs = []; _.keys(formatted).forEach(function (key) { - var pairs = highlights[key] ? highlightPairs : sourcePairs; - var field = shortDotsFilter(key); - var val = formatted[key]; + let pairs = highlights[key] ? highlightPairs : sourcePairs; + let field = shortDotsFilter(key); + let val = formatted[key]; pairs.push([field, val]); }, []); diff --git a/src/ui/public/stringify/types/string.js b/src/ui/public/stringify/types/string.js index 7b0a4583cb2e..3db37865534e 100644 --- a/src/ui/public/stringify/types/string.js +++ b/src/ui/public/stringify/types/string.js @@ -2,7 +2,7 @@ import _ from 'lodash'; import 'ui/field_format_editor/samples/samples'; import IndexPatternsFieldFormatProvider from 'ui/index_patterns/_field_format/field_format'; export default function StringFormatProvider(Private) { - var FieldFormat = Private(IndexPatternsFieldFormatProvider); + let FieldFormat = Private(IndexPatternsFieldFormatProvider); _.class(_String).inherits(FieldFormat); diff --git a/src/ui/public/stringify/types/truncate.js b/src/ui/public/stringify/types/truncate.js index 1ad69fc4fc92..666add881958 100644 --- a/src/ui/public/stringify/types/truncate.js +++ b/src/ui/public/stringify/types/truncate.js @@ -2,8 +2,8 @@ import _ from 'lodash'; import IndexPatternsFieldFormatProvider from 'ui/index_patterns/_field_format/field_format'; export default function TruncateFormatProvider(Private) { - var FieldFormat = Private(IndexPatternsFieldFormatProvider); - var omission = '...'; + let FieldFormat = Private(IndexPatternsFieldFormatProvider); + let omission = '...'; _.class(Truncate).inherits(FieldFormat); @@ -16,7 +16,7 @@ export default function TruncateFormatProvider(Private) { Truncate.fieldType = ['string']; Truncate.prototype._convert = function (val) { - var length = this.param('fieldLength'); + let length = this.param('fieldLength'); if (length > 0) { return _.trunc(val, { 'length': length + omission.length, diff --git a/src/ui/public/stringify/types/url.js b/src/ui/public/stringify/types/url.js index 510a0d3afa1c..eb1c46aeaaaf 100644 --- a/src/ui/public/stringify/types/url.js +++ b/src/ui/public/stringify/types/url.js @@ -5,7 +5,7 @@ import IndexPatternsFieldFormatProvider from 'ui/index_patterns/_field_format/fi import urlTemplate from 'ui/stringify/editors/url.html'; export default function UrlFormatProvider(Private, highlightFilter) { - var FieldFormat = Private(IndexPatternsFieldFormatProvider); + let FieldFormat = Private(IndexPatternsFieldFormatProvider); _.class(Url).inherits(FieldFormat); @@ -31,7 +31,7 @@ export default function UrlFormatProvider(Private, highlightFilter) { template: urlTemplate, controllerAs: 'url', controller: function ($scope) { - var iconPattern = '/bundles/src/ui/public/stringify/icons/{{value}}.png'; + let iconPattern = '/bundles/src/ui/public/stringify/icons/{{value}}.png'; this.samples = { a: [ 'john', '/some/pathname/asset.png', 1234 ], @@ -39,7 +39,7 @@ export default function UrlFormatProvider(Private, highlightFilter) { }; $scope.$watch('editor.formatParams.type', function (type, prev) { - var params = $scope.editor.formatParams; + let params = $scope.editor.formatParams; if (type === 'img' && type !== prev && !params.urlTemplate) { params.urlTemplate = iconPattern; } @@ -60,7 +60,7 @@ export default function UrlFormatProvider(Private, highlightFilter) { ]; Url.prototype._formatUrl = function (value) { - var template = this.param('urlTemplate'); + let template = this.param('urlTemplate'); if (!template) return value; return this._compileTemplate(template)({ @@ -70,7 +70,7 @@ export default function UrlFormatProvider(Private, highlightFilter) { }; Url.prototype._formatLabel = function (value, url) { - var template = this.param('labelTemplate'); + let template = this.param('labelTemplate'); if (url == null) url = this._formatUrl(value); if (!template) return url; @@ -86,8 +86,8 @@ export default function UrlFormatProvider(Private, highlightFilter) { }, html: function (rawValue, field, hit) { - var url = _.escape(this._formatUrl(rawValue)); - var label = _.escape(this._formatLabel(rawValue, url)); + let url = _.escape(this._formatUrl(rawValue)); + let label = _.escape(this._formatLabel(rawValue, url)); switch (this.param('type')) { case 'img': @@ -103,19 +103,19 @@ export default function UrlFormatProvider(Private, highlightFilter) { }; Url.prototype._compileTemplate = function (template) { - var parts = template.split(Url.templateMatchRE).map(function (part, i) { + let parts = template.split(Url.templateMatchRE).map(function (part, i) { // trim all the odd bits, the variable names return (i % 2) ? part.trim() : part; }); return function (locals) { // replace all the odd bits with their local var - var output = ''; - var i = -1; + let output = ''; + let i = -1; while (++i < parts.length) { if (i % 2) { if (locals.hasOwnProperty(parts[i])) { - var local = locals[parts[i]]; + let local = locals[parts[i]]; output += local == null ? '' : local; } } else { diff --git a/src/ui/public/style_compile/style_compile.js b/src/ui/public/style_compile/style_compile.js index cebd9a8ee7e1..4ec2bd7367c0 100644 --- a/src/ui/public/style_compile/style_compile.js +++ b/src/ui/public/style_compile/style_compile.js @@ -2,15 +2,15 @@ import _ from 'lodash'; import $ from 'jquery'; import 'ui/config'; import uiModules from 'ui/modules'; -var $style = $('