From 3ae090908d2e62a0a6482a7afcbc4ba46914eeac Mon Sep 17 00:00:00 2001 From: Court Ewing Date: Tue, 12 Apr 2016 17:45:32 -0400 Subject: [PATCH] [internal] Replace let with const in root of ui/public This change was applied only to files in the root of the src/ui/public directory. All instances of `let` were replaced with `const`, and then any instance that flagged the `no-const-assign` rule in the linter was put back. --- src/ui/public/bound_to_config_obj.js | 4 ++-- src/ui/public/compile_recursive_directive.js | 2 +- src/ui/public/elastic_textarea.js | 4 ++-- src/ui/public/errors.js | 8 ++++---- src/ui/public/events.js | 8 ++++---- src/ui/public/fixed_scroll.js | 16 ++++++++-------- src/ui/public/modules.js | 8 ++++---- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/ui/public/bound_to_config_obj.js b/src/ui/public/bound_to_config_obj.js index 47b8b45080953..763d293175f6c 100644 --- a/src/ui/public/bound_to_config_obj.js +++ b/src/ui/public/bound_to_config_obj.js @@ -16,7 +16,7 @@ export default function BoundToConfigObjProvider($rootScope, config) { * @return {Object} */ function BoundToConfigObj(input) { - let self = this; + const self = this; _.forOwn(input, function (val, prop) { if (!_.isString(val) || val.charAt(0) !== '=') { @@ -24,7 +24,7 @@ export default function BoundToConfigObjProvider($rootScope, config) { return; } - let configKey = val.substr(1); + const configKey = val.substr(1); update(); $rootScope.$on('init:config', update); diff --git a/src/ui/public/compile_recursive_directive.js b/src/ui/public/compile_recursive_directive.js index 7754e56b6349c..0ce8b611740f4 100644 --- a/src/ui/public/compile_recursive_directive.js +++ b/src/ui/public/compile_recursive_directive.js @@ -25,7 +25,7 @@ uiModules } // Break the recursion loop by removing the contents - let contents = element.contents().remove(); + const contents = element.contents().remove(); let compiledContents; return { pre: (link && link.pre) ? link.pre : null, diff --git a/src/ui/public/elastic_textarea.js b/src/ui/public/elastic_textarea.js index d0258ac4568c6..efc3c87b7b10b 100644 --- a/src/ui/public/elastic_textarea.js +++ b/src/ui/public/elastic_textarea.js @@ -1,7 +1,7 @@ import _ from 'lodash'; import uiModules from 'ui/modules'; -let NL_RE = /\n/g; -let events = 'keydown keypress keyup change'; +const NL_RE = /\n/g; +const events = 'keydown keypress keyup change'; uiModules.get('kibana') .directive('elasticTextarea', function () { diff --git a/src/ui/public/errors.js b/src/ui/public/errors.js index 54638d2a231ad..e1d2464a6aaab 100644 --- a/src/ui/public/errors.js +++ b/src/ui/public/errors.js @@ -1,12 +1,12 @@ import _ from 'lodash'; import angular from 'angular'; -let canStack = (function () { - let err = new Error(); +const canStack = (function () { + const err = new Error(); return !!err.stack; }()); -let errors = {}; +const errors = {}; // abstract error class function KbnError(msg, constructor) { @@ -165,7 +165,7 @@ _.class(errors.DuplicateField).inherits(KbnError); errors.SavedObjectNotFound = function SavedObjectNotFound(type, id) { this.savedObjectType = type; this.savedObjectId = id; - let idMsg = id ? ' (id: ' + id + ')' : ''; + const idMsg = id ? ' (id: ' + id + ')' : ''; KbnError.call(this, 'Could not locate that ' + type + idMsg, errors.SavedObjectNotFound); diff --git a/src/ui/public/events.js b/src/ui/public/events.js index 47fff68353c67..5f7a29ccf398b 100644 --- a/src/ui/public/events.js +++ b/src/ui/public/events.js @@ -3,7 +3,7 @@ import Notifier from 'ui/notify/notifier'; import SimpleEmitter from 'ui/utils/simple_emitter'; export default function EventsProvider(Private, Promise) { - let notify = new Notifier({ location: 'EventEmitter' }); + const notify = new Notifier({ location: 'EventEmitter' }); _.class(Events).inherits(SimpleEmitter); function Events() { @@ -23,7 +23,7 @@ export default function EventsProvider(Private, Promise) { this._listeners[name] = []; } - let listener = { + const listener = { handler: handler }; this._listeners[name].push(listener); @@ -75,8 +75,8 @@ export default function EventsProvider(Private, Promise) { * @returns {Promise} */ Events.prototype.emit = function (name) { - let self = this; - let args = _.rest(arguments); + const self = this; + const args = _.rest(arguments); if (!self._listeners[name]) { return self._emitChain; diff --git a/src/ui/public/fixed_scroll.js b/src/ui/public/fixed_scroll.js index fc68b913d4a47..786645af80ad4 100644 --- a/src/ui/public/fixed_scroll.js +++ b/src/ui/public/fixed_scroll.js @@ -2,7 +2,7 @@ import $ from 'jquery'; import _ from 'lodash'; import uiModules from 'ui/modules'; -let SCROLLER_HEIGHT = 20; +const SCROLLER_HEIGHT = 20; uiModules .get('kibana') @@ -74,15 +74,15 @@ uiModules function setup() { cleanUp(); - let containerWidth = $el.width(); - let contentWidth = $el.prop('scrollWidth'); - let containerHorizOverflow = contentWidth - containerWidth; + const containerWidth = $el.width(); + const contentWidth = $el.prop('scrollWidth'); + const containerHorizOverflow = contentWidth - containerWidth; - let elTop = $el.offset().top - $window.scrollTop(); - let elBottom = elTop + $el.height(); - let windowVertOverflow = elBottom - $window.height(); + const elTop = $el.offset().top - $window.scrollTop(); + const elBottom = elTop + $el.height(); + const windowVertOverflow = elBottom - $window.height(); - let requireScroller = containerHorizOverflow > 0 && windowVertOverflow > 0; + const requireScroller = containerHorizOverflow > 0 && windowVertOverflow > 0; if (!requireScroller) return; // push the content away from the scroller diff --git a/src/ui/public/modules.js b/src/ui/public/modules.js index 9ed1e0c58e39c..0be8c7c05ae0a 100644 --- a/src/ui/public/modules.js +++ b/src/ui/public/modules.js @@ -47,8 +47,8 @@ import _ from 'lodash'; * "kibana" module's injector. * */ -let existingModules = {}; -let links = []; +const existingModules = {}; +const links = []; /** * Take an angular module and extends the dependencies for that module to include all of the modules @@ -102,13 +102,13 @@ function get(moduleName, requires) { } function close(moduleName) { - let module = existingModules[moduleName]; + const module = existingModules[moduleName]; // already closed if (!module) return; // if the module is currently linked, unlink it - let i = links.indexOf(module); + const i = links.indexOf(module); if (i > -1) links.splice(i, 1); // remove from linked modules list of required modules