Skip to content

Commit

Permalink
[internal] Replace var with let in root of ui/public
Browse files Browse the repository at this point in the history
This change was applied only to files in the root of the src/ui/public
directory.

This was an automatic replacement from var to let for any variable
declaration that doubles as the initial assignment. Ultimately we want
most of these to be converted to const, but this commit is so large that
it warrants breaking each step of automation up into its own commit.

For example:

`var foo = 'bar';` becomes `let foo = 'var';`

This was accomplished by replacing:
find: `var ([a-zA-Z_$][0-9a-zA-Z_$]*)(\s+)=`
replace: `let $1$2=`
  • Loading branch information
epixa committed Apr 12, 2016
1 parent 2f3cdf6 commit 469c0bd
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/ui/public/bound_to_config_obj.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ export default function BoundToConfigObjProvider($rootScope, config) {
* @return {Object}
*/
function BoundToConfigObj(input) {
var self = this;
let self = this;

_.forOwn(input, function (val, prop) {
if (!_.isString(val) || val.charAt(0) !== '=') {
self[prop] = val;
return;
}

var configKey = val.substr(1);
let configKey = val.substr(1);

update();
$rootScope.$on('init:config', update);
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/compile_recursive_directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ uiModules
}

// Break the recursion loop by removing the contents
var contents = element.contents().remove();
let contents = element.contents().remove();
let compiledContents;
return {
pre: (link && link.pre) ? link.pre : null,
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/elastic_textarea.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from 'lodash';
import uiModules from 'ui/modules';
var NL_RE = /\n/g;
var events = 'keydown keypress keyup change';
let NL_RE = /\n/g;
let events = 'keydown keypress keyup change';

uiModules.get('kibana')
.directive('elasticTextarea', function () {
Expand Down
10 changes: 5 additions & 5 deletions src/ui/public/errors.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import _ from 'lodash';
import angular from 'angular';

var canStack = (function () {
var err = new Error();
let canStack = (function () {
let err = new Error();
return !!err.stack;
}());

var errors = {};
let errors = {};

// abstract error class
function KbnError(msg, constructor) {
Expand Down Expand Up @@ -119,7 +119,7 @@ _.class(errors.MappingConflict).inherits(KbnError);
* @param {String} field - the fields which contains the conflict
*/
errors.RestrictedMapping = function RestrictedMapping(field, index) {
var msg = field + ' is a restricted field name';
let msg = field + ' is a restricted field name';
if (index) msg += ', found it while attempting to fetch mapping for index pattern: ' + index;

KbnError.call(this, msg, errors.RestrictedMapping);
Expand Down Expand Up @@ -165,7 +165,7 @@ _.class(errors.DuplicateField).inherits(KbnError);
errors.SavedObjectNotFound = function SavedObjectNotFound(type, id) {
this.savedObjectType = type;
this.savedObjectId = id;
var idMsg = id ? ' (id: ' + id + ')' : '';
let idMsg = id ? ' (id: ' + id + ')' : '';
KbnError.call(this,
'Could not locate that ' + type + idMsg,
errors.SavedObjectNotFound);
Expand Down
8 changes: 4 additions & 4 deletions src/ui/public/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Notifier from 'ui/notify/notifier';
import SimpleEmitter from 'ui/utils/simple_emitter';

export default function EventsProvider(Private, Promise) {
var notify = new Notifier({ location: 'EventEmitter' });
let notify = new Notifier({ location: 'EventEmitter' });

_.class(Events).inherits(SimpleEmitter);
function Events() {
Expand All @@ -23,7 +23,7 @@ export default function EventsProvider(Private, Promise) {
this._listeners[name] = [];
}

var listener = {
let listener = {
handler: handler
};
this._listeners[name].push(listener);
Expand Down Expand Up @@ -75,8 +75,8 @@ export default function EventsProvider(Private, Promise) {
* @returns {Promise}
*/
Events.prototype.emit = function (name) {
var self = this;
var args = _.rest(arguments);
let self = this;
let args = _.rest(arguments);

if (!self._listeners[name]) {
return self._emitChain;
Expand Down
22 changes: 11 additions & 11 deletions src/ui/public/fixed_scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ import $ from 'jquery';
import _ from 'lodash';
import uiModules from 'ui/modules';

var SCROLLER_HEIGHT = 20;
let SCROLLER_HEIGHT = 20;

uiModules
.get('kibana')
.directive('fixedScroll', function ($timeout) {
return {
restrict: 'A',
link: function ($scope, $el) {
var $window = $(window);
var $scroller = $('<div class="fixed-scroll-scroller">').height(SCROLLER_HEIGHT);
let $window = $(window);
let $scroller = $('<div class="fixed-scroll-scroller">').height(SCROLLER_HEIGHT);


/**
* Remove the listeners bound in listen()
* @type {function}
*/
var unlisten = _.noop;
let unlisten = _.noop;

/**
* Listen for scroll events on the $scroller and the $el, sets unlisten()
Expand Down Expand Up @@ -74,15 +74,15 @@ uiModules
function setup() {
cleanUp();

var containerWidth = $el.width();
var contentWidth = $el.prop('scrollWidth');
var containerHorizOverflow = contentWidth - containerWidth;
let containerWidth = $el.width();
let contentWidth = $el.prop('scrollWidth');
let containerHorizOverflow = contentWidth - containerWidth;

var elTop = $el.offset().top - $window.scrollTop();
var elBottom = elTop + $el.height();
var windowVertOverflow = elBottom - $window.height();
let elTop = $el.offset().top - $window.scrollTop();
let elBottom = elTop + $el.height();
let windowVertOverflow = elBottom - $window.height();

var requireScroller = containerHorizOverflow > 0 && windowVertOverflow > 0;
let requireScroller = containerHorizOverflow > 0 && windowVertOverflow > 0;
if (!requireScroller) return;

// push the content away from the scroller
Expand Down
10 changes: 5 additions & 5 deletions src/ui/public/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ import _ from 'lodash';
* "kibana" module's injector.
*
*/
var existingModules = {};
var links = [];
let existingModules = {};
let links = [];

/**
* Take an angular module and extends the dependencies for that module to include all of the modules
Expand Down Expand Up @@ -79,7 +79,7 @@ function link(module) {
* @return {AngularModule}
*/
function get(moduleName, requires) {
var module = existingModules[moduleName];
let module = existingModules[moduleName];

if (module === void 0) {
// create the module
Expand All @@ -102,13 +102,13 @@ function get(moduleName, requires) {
}

function close(moduleName) {
var module = existingModules[moduleName];
let module = existingModules[moduleName];

// already closed
if (!module) return;

// if the module is currently linked, unlink it
var i = links.indexOf(module);
let i = links.indexOf(module);
if (i > -1) links.splice(i, 1);

// remove from linked modules list of required modules
Expand Down

0 comments on commit 469c0bd

Please sign in to comment.