Skip to content

Commit

Permalink
Merge pull request #6706 from epixa/letconst-notui
Browse files Browse the repository at this point in the history
[internal] Replace var assignments with let in non-ui
  • Loading branch information
Matt Bargar committed Mar 31, 2016
2 parents 26cedc7 + f3ec776 commit 354950b
Show file tree
Hide file tree
Showing 40 changed files with 137 additions and 134 deletions.
2 changes: 1 addition & 1 deletion src/cli/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Command.prototype.parseOptions = _.wrap(Command.prototype.parseOptions, function

Command.prototype.action = _.wrap(Command.prototype.action, function (action, fn) {
return action.call(this, function (...args) {
var ret = fn.apply(this, args);
let ret = fn.apply(this, args);
if (ret && typeof ret.then === 'function') {
ret.then(null, function (e) {
console.log('FATAL CLI ERROR', e.stack);
Expand Down
2 changes: 1 addition & 1 deletion src/cli/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ ${indent(cmd.optionHelp(), 2)}
}

function humanReadableArgName(arg) {
var nameOutput = arg.name + (arg.variadic === true ? '...' : '');
let nameOutput = arg.name + (arg.variadic === true ? '...' : '');
return arg.required ? '<' + nameOutput + '>' : '[' + nameOutput + ']';
}
4 changes: 2 additions & 2 deletions src/cli_plugin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ program
.command('help <command>')
.description('get the help for a specific command')
.action(function (cmdName) {
var cmd = _.find(program.commands, { _name: cmdName });
let cmd = _.find(program.commands, { _name: cmdName });
if (!cmd) return program.error(`unknown command ${cmdName}`);
cmd.help();
});
Expand All @@ -35,7 +35,7 @@ program
});

// check for no command name
var subCommand = argv[2] && !String(argv[2][0]).match(/^-|^\.|\//);
let subCommand = argv[2] && !String(argv[2][0]).match(/^-|^\.|\//);
if (!subCommand) {
program.defaultHelp();
}
Expand Down
12 changes: 6 additions & 6 deletions src/fixtures/agg_resp/geohash_grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ export default function GeoHashGridAggResponseFixture() {
// },
// });

var geoHashCharts = _.union(
let geoHashCharts = _.union(
_.range(48, 57), // 0-9
_.range(65, 90), // A-Z
_.range(97, 122) // a-z
);

var totalDocCount = 0;
let totalDocCount = 0;

var tags = _.times(_.random(4, 20), function (i) {
let tags = _.times(_.random(4, 20), function (i) {
// random number of tags
var docCount = 0;
var buckets = _.times(_.random(40, 200), function () {
let docCount = 0;
let buckets = _.times(_.random(40, 200), function () {
return _.sample(geoHashCharts, 3).join('');
})
.sort()
.map(function (geoHash) {
var count = _.random(1, 5000);
let count = _.random(1, 5000);

totalDocCount += count;
docCount += count;
Expand Down
2 changes: 1 addition & 1 deletion src/fixtures/fake_chart_events.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var results = {};
let results = {};

results.timeSeries = {
data: {
Expand Down
2 changes: 1 addition & 1 deletion src/fixtures/fake_hierarchical_data.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var data = { };
let data = { };

data.metricOnly = {
hits: { total: 1000, hits: [], max_score: 0 },
Expand Down
2 changes: 1 addition & 1 deletion src/fixtures/fake_row.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'lodash';
var longString = Array(200).join('_');
let longString = Array(200).join('_');

export default function (id, mapping) {
function fakeVals(type) {
Expand Down
2 changes: 1 addition & 1 deletion src/fixtures/logstash_fields.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function stubbedLogstashFields() {
var sourceData = [
let sourceData = [
{ name: 'bytes', type: 'number', indexed: true, analyzed: true, sortable: true, filterable: true, count: 10 },
{ name: 'ssl', type: 'boolean', indexed: true, analyzed: true, sortable: true, filterable: true, count: 20 },
{ name: '@timestamp', type: 'date', indexed: true, analyzed: true, sortable: true, filterable: true, count: 30 },
Expand Down
6 changes: 3 additions & 3 deletions src/fixtures/mock_courier.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import sinon from 'auto-release-sinon';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';

export default function (Private, Promise) {
var indexPatterns = Private(FixturesStubbedLogstashIndexPatternProvider);
var getIndexPatternStub = sinon.stub();
let indexPatterns = Private(FixturesStubbedLogstashIndexPatternProvider);
let getIndexPatternStub = sinon.stub();
getIndexPatternStub.returns(Promise.resolve(indexPatterns));

var courier = {
let courier = {
indexPatterns: { get: getIndexPatternStub },
getStub: getIndexPatternStub
};
Expand Down
2 changes: 1 addition & 1 deletion src/fixtures/mock_ui_state.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'lodash';
var keys = {};
let keys = {};
export default {
get: function (path, def) {
return keys[path] == null ? def : keys[path];
Expand Down
2 changes: 1 addition & 1 deletion src/fixtures/stubbed_doc_source_response.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import FixturesLogstashFieldsProvider from 'fixtures/logstash_fields';

function stubbedDocSourceResponse(Private) {
var mockLogstashFields = Private(FixturesLogstashFieldsProvider);
let mockLogstashFields = Private(FixturesLogstashFieldsProvider);

return function (id, index) {
index = index || '.kibana';
Expand Down
12 changes: 6 additions & 6 deletions src/fixtures/stubbed_logstash_index_pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ import TestUtilsStubIndexPatternProvider from 'test_utils/stub_index_pattern';
import IndexPatternsFieldTypesProvider from 'ui/index_patterns/_field_types';
import FixturesLogstashFieldsProvider from 'fixtures/logstash_fields';
export default function stubbedLogstashIndexPatternService(Private) {
var StubIndexPattern = Private(TestUtilsStubIndexPatternProvider);
var fieldTypes = Private(IndexPatternsFieldTypesProvider);
var mockLogstashFields = Private(FixturesLogstashFieldsProvider);
let StubIndexPattern = Private(TestUtilsStubIndexPatternProvider);
let fieldTypes = Private(IndexPatternsFieldTypesProvider);
let mockLogstashFields = Private(FixturesLogstashFieldsProvider);


var fields = mockLogstashFields.map(function (field) {
let fields = mockLogstashFields.map(function (field) {
field.displayName = field.name;
var type = fieldTypes.byName[field.type];
let type = fieldTypes.byName[field.type];
if (!type) throw new TypeError('unknown type ' + field.type);
if (!_.has(field, 'sortable')) field.sortable = type.sortable;
if (!_.has(field, 'filterable')) field.filterable = type.filterable;
return field;
});

var indexPattern = new StubIndexPattern('logstash-*', 'time', fields);
let indexPattern = new StubIndexPattern('logstash-*', 'time', fields);
indexPattern.id = 'logstash-*';

return indexPattern;
Expand Down
4 changes: 2 additions & 2 deletions src/fixtures/stubbed_search_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import searchResponse from 'fixtures/search_response';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';

export default function stubSearchSource(Private, $q, Promise) {
var deferedResult = $q.defer();
var indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
let deferedResult = $q.defer();
let indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);

return {
sort: sinon.spy(),
Expand Down
8 changes: 4 additions & 4 deletions src/fixtures/vislib/_vis_fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _ from 'lodash';
import $ from 'jquery';
import VislibVisProvider from 'ui/vislib/vis';

var $visCanvas = $('<div>')
let $visCanvas = $('<div>')
.attr('id', 'vislib-vis-fixtures')
.css({
height: '500px',
Expand All @@ -15,8 +15,8 @@ var $visCanvas = $('<div>')
})
.appendTo('body');

var count = 0;
var visHeight = $visCanvas.height();
let count = 0;
let visHeight = $visCanvas.height();

$visCanvas.new = function () {
count += 1;
Expand All @@ -32,7 +32,7 @@ afterEach(function () {

module.exports = function VislibFixtures(Private) {
return function (visLibParams) {
var Vis = Private(VislibVisProvider);
let Vis = Private(VislibVisProvider);
return new Vis($visCanvas.new(), _.defaults({}, visLibParams || {}, {
shareYAxis: true,
addTooltip: true,
Expand Down
2 changes: 1 addition & 1 deletion src/optimize/babel_options.build.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cloneDeep } from 'lodash';
var fromRoot = require('path').resolve.bind(null, __dirname, '../../');
let fromRoot = require('path').resolve.bind(null, __dirname, '../../');

if (!process.env.BABEL_CACHE_PATH) {
process.env.BABEL_CACHE_PATH = fromRoot('optimize/.babelcache.json');
Expand Down
7 changes: 5 additions & 2 deletions src/optimize/babel_options.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
var cloneDeep = require('lodash').cloneDeep;
var fromRoot = require('path').resolve.bind(null, __dirname, '../../');
// this file is not transpiled
'use strict'; // eslint-disable-line strict

let cloneDeep = require('lodash').cloneDeep;
let fromRoot = require('path').resolve.bind(null, __dirname, '../../');

if (!process.env.BABEL_CACHE_PATH) {
process.env.BABEL_CACHE_PATH = fromRoot('optimize/.babelcache.json');
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/kbn_doc_views/public/views/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ docViewsRegistry.register(function () {
};

$scope.showArrayInObjectsWarning = function (row, field) {
var value = $scope.flattened[field];
let value = $scope.flattened[field];
return _.isArray(value) && typeof value[0] === 'object';
};
}
Expand Down
Loading

0 comments on commit 354950b

Please sign in to comment.