diff --git a/src/cli/command.js b/src/cli/command.js index bed84797bab5e..135d03e32b6c1 100644 --- a/src/cli/command.js +++ b/src/cli/command.js @@ -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); diff --git a/src/cli/help.js b/src/cli/help.js index 539b05e0ed033..89bc90a24cbd6 100644 --- a/src/cli/help.js +++ b/src/cli/help.js @@ -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 + ']'; } diff --git a/src/cli_plugin/cli.js b/src/cli_plugin/cli.js index 5f322a48bb289..5a09416a9cb1a 100644 --- a/src/cli_plugin/cli.js +++ b/src/cli_plugin/cli.js @@ -23,7 +23,7 @@ program .command('help ') .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(); }); @@ -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(); } diff --git a/src/fixtures/agg_resp/geohash_grid.js b/src/fixtures/agg_resp/geohash_grid.js index b62d56d21ae57..33a446ff360b2 100644 --- a/src/fixtures/agg_resp/geohash_grid.js +++ b/src/fixtures/agg_resp/geohash_grid.js @@ -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; diff --git a/src/fixtures/fake_chart_events.js b/src/fixtures/fake_chart_events.js index 949234c8c58ec..383a61c900815 100644 --- a/src/fixtures/fake_chart_events.js +++ b/src/fixtures/fake_chart_events.js @@ -1,4 +1,4 @@ -var results = {}; +let results = {}; results.timeSeries = { data: { diff --git a/src/fixtures/fake_hierarchical_data.js b/src/fixtures/fake_hierarchical_data.js index d15ae5253e7be..2b1096cc9c271 100644 --- a/src/fixtures/fake_hierarchical_data.js +++ b/src/fixtures/fake_hierarchical_data.js @@ -1,4 +1,4 @@ -var data = { }; +let data = { }; data.metricOnly = { hits: { total: 1000, hits: [], max_score: 0 }, diff --git a/src/fixtures/fake_row.js b/src/fixtures/fake_row.js index 837d4081c989c..032fe0f1a9235 100644 --- a/src/fixtures/fake_row.js +++ b/src/fixtures/fake_row.js @@ -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) { diff --git a/src/fixtures/logstash_fields.js b/src/fixtures/logstash_fields.js index c23cfafbbcaf6..e4f993da81470 100644 --- a/src/fixtures/logstash_fields.js +++ b/src/fixtures/logstash_fields.js @@ -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 }, diff --git a/src/fixtures/mock_courier.js b/src/fixtures/mock_courier.js index d1932a2837e45..ef68696693551 100644 --- a/src/fixtures/mock_courier.js +++ b/src/fixtures/mock_courier.js @@ -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 }; diff --git a/src/fixtures/mock_ui_state.js b/src/fixtures/mock_ui_state.js index c4b77a4b8ba5d..50d913ae337e8 100644 --- a/src/fixtures/mock_ui_state.js +++ b/src/fixtures/mock_ui_state.js @@ -1,5 +1,5 @@ import _ from 'lodash'; -var keys = {}; +let keys = {}; export default { get: function (path, def) { return keys[path] == null ? def : keys[path]; diff --git a/src/fixtures/stubbed_doc_source_response.js b/src/fixtures/stubbed_doc_source_response.js index 7034d99427101..5bed6d41af348 100644 --- a/src/fixtures/stubbed_doc_source_response.js +++ b/src/fixtures/stubbed_doc_source_response.js @@ -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'; diff --git a/src/fixtures/stubbed_logstash_index_pattern.js b/src/fixtures/stubbed_logstash_index_pattern.js index 1bbcfd76e175c..8377132b6d8ea 100644 --- a/src/fixtures/stubbed_logstash_index_pattern.js +++ b/src/fixtures/stubbed_logstash_index_pattern.js @@ -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; diff --git a/src/fixtures/stubbed_search_source.js b/src/fixtures/stubbed_search_source.js index 3cf015475b750..118aaede15047 100644 --- a/src/fixtures/stubbed_search_source.js +++ b/src/fixtures/stubbed_search_source.js @@ -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(), diff --git a/src/fixtures/vislib/_vis_fixture.js b/src/fixtures/vislib/_vis_fixture.js index 589a65f8a8160..8f06190120053 100644 --- a/src/fixtures/vislib/_vis_fixture.js +++ b/src/fixtures/vislib/_vis_fixture.js @@ -2,7 +2,7 @@ import _ from 'lodash'; import $ from 'jquery'; import VislibVisProvider from 'ui/vislib/vis'; -var $visCanvas = $('
') +let $visCanvas = $('
') .attr('id', 'vislib-vis-fixtures') .css({ height: '500px', @@ -15,8 +15,8 @@ var $visCanvas = $('
') }) .appendTo('body'); -var count = 0; -var visHeight = $visCanvas.height(); +let count = 0; +let visHeight = $visCanvas.height(); $visCanvas.new = function () { count += 1; @@ -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, diff --git a/src/optimize/babel_options.build.js b/src/optimize/babel_options.build.js index c58e6bee57f99..885a318ab84d1 100644 --- a/src/optimize/babel_options.build.js +++ b/src/optimize/babel_options.build.js @@ -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'); diff --git a/src/optimize/babel_options.js b/src/optimize/babel_options.js index df98c4b71a811..e562700da3708 100644 --- a/src/optimize/babel_options.js +++ b/src/optimize/babel_options.js @@ -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'); diff --git a/src/plugins/kbn_doc_views/public/views/table.js b/src/plugins/kbn_doc_views/public/views/table.js index c0ebc4b8edf6b..af201f39c3539 100644 --- a/src/plugins/kbn_doc_views/public/views/table.js +++ b/src/plugins/kbn_doc_views/public/views/table.js @@ -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'; }; } diff --git a/src/server/config/__tests__/config.js b/src/server/config/__tests__/config.js index 7a48a7c616572..cf43ce256f585 100644 --- a/src/server/config/__tests__/config.js +++ b/src/server/config/__tests__/config.js @@ -9,12 +9,12 @@ import Joi from 'joi'; * * Config should be newed up with a joi schema (containing defaults via joi) * - * var schema = { ... } + * let schema = { ... } * new Config(schema); * */ -var data = { +let data = { test: { hosts: ['host-01', 'host-02'], client: { @@ -25,7 +25,7 @@ var data = { } }; -var schema = Joi.object({ +let schema = Joi.object({ test: Joi.object({ enable: Joi.boolean().default(true), hosts: Joi.array().items(Joi.string()), @@ -44,39 +44,39 @@ describe('lib/config/config', function () { describe('constructor', function () { it('should not allow any config if the schema is not passed', function () { - var config = new Config(); - var run = function () { + let config = new Config(); + let run = function () { config.set('something.enable', true); }; expect(run).to.throwException(); }); it('should allow keys in the schema', function () { - var config = new Config(schema); - var run = function () { + let config = new Config(schema); + let run = function () { config.set('test.client.host', 'http://0.0.0.0'); }; expect(run).to.not.throwException(); }); it('should not allow keys not in the schema', function () { - var config = new Config(schema); - var run = function () { + let config = new Config(schema); + let run = function () { config.set('paramNotDefinedInTheSchema', true); }; expect(run).to.throwException(); }); it('should not allow child keys not in the schema', function () { - var config = new Config(schema); - var run = function () { + let config = new Config(schema); + let run = function () { config.set('test.client.paramNotDefinedInTheSchema', true); }; expect(run).to.throwException(); }); it('should set defaults', function () { - var config = new Config(schema); + let config = new Config(schema); expect(config.get('test.enable')).to.be(true); expect(config.get('test.client.type')).to.be('datastore'); }); @@ -92,7 +92,7 @@ describe('lib/config/config', function () { it('should reset the config object with new values', function () { config.set(data); - var newData = config.get(); + let newData = config.get(); newData.test.enable = false; config.resetTo(newData); expect(config.get()).to.eql(newData); @@ -134,21 +134,21 @@ describe('lib/config/config', function () { }); it('should use an object to set config values', function () { - var hosts = ['host-01', 'host-02']; + let hosts = ['host-01', 'host-02']; config.set({ test: { enable: false, hosts: hosts } }); expect(config.get('test.enable')).to.be(false); expect(config.get('test.hosts')).to.eql(hosts); }); it('should use a flatten object to set config values', function () { - var hosts = ['host-01', 'host-02']; + let hosts = ['host-01', 'host-02']; config.set({ 'test.enable': false, 'test.hosts': hosts }); expect(config.get('test.enable')).to.be(false); expect(config.get('test.hosts')).to.eql(hosts); }); it('should override values with just the values present', function () { - var newData = _.cloneDeep(data); + let newData = _.cloneDeep(data); config.set(data); newData.test.enable = false; config.set({ test: { enable: false } }); @@ -156,7 +156,7 @@ describe('lib/config/config', function () { }); it('should thow an exception when setting a value with the wrong type', function (done) { - var run = function () { + let run = function () { config.set('test.enable', 'something'); }; expect(run).to.throwException(function (err) { @@ -179,7 +179,7 @@ describe('lib/config/config', function () { }); it('should return the whole config object when called without a key', function () { - var newData = _.cloneDeep(data); + let newData = _.cloneDeep(data); newData.test.enable = true; expect(config.get()).to.eql(newData); }); @@ -194,14 +194,14 @@ describe('lib/config/config', function () { }); it('should throw exception for unknown config values', function () { - var run = function () { + let run = function () { config.get('test.does.not.exist'); }; expect(run).to.throwException(/Unknown config key: test.does.not.exist/); }); it('should not throw exception for undefined known config values', function () { - var run = function getUndefValue() { + let run = function getUndefValue() { config.get('test.undefValue'); }; expect(run).to.not.throwException(); @@ -216,13 +216,13 @@ describe('lib/config/config', function () { }); it('should allow you to extend the schema at the top level', function () { - var newSchema = Joi.object({ test: Joi.boolean().default(true) }).default(); + let newSchema = Joi.object({ test: Joi.boolean().default(true) }).default(); config.extendSchema('myTest', newSchema); expect(config.get('myTest.test')).to.be(true); }); it('should allow you to extend the schema with a prefix', function () { - var newSchema = Joi.object({ test: Joi.boolean().default(true) }).default(); + let newSchema = Joi.object({ test: Joi.boolean().default(true) }).default(); config.extendSchema('prefix.myTest', newSchema); expect(config.get('prefix')).to.eql({ myTest: { test: true }}); expect(config.get('prefix.myTest')).to.eql({ test: true }); @@ -230,8 +230,8 @@ describe('lib/config/config', function () { }); it('should NOT allow you to extend the schema if somethign else is there', function () { - var newSchema = Joi.object({ test: Joi.boolean().default(true) }).default(); - var run = function () { + let newSchema = Joi.object({ test: Joi.boolean().default(true) }).default(); + let run = function () { config.extendSchema('test', newSchema); }; expect(run).to.throwException(); @@ -241,7 +241,7 @@ describe('lib/config/config', function () { describe('#removeSchema(key)', function () { it('should completely remove the key', function () { - var config = new Config(Joi.object().keys({ + let config = new Config(Joi.object().keys({ a: Joi.number().default(1) })); @@ -251,7 +251,7 @@ describe('lib/config/config', function () { }); it('only removes existing keys', function () { - var config = new Config(Joi.object()); + let config = new Config(Joi.object()); expect(() => config.removeSchema('b')).to.throwException('Unknown schema'); }); diff --git a/src/server/config/__tests__/explode_by.js b/src/server/config/__tests__/explode_by.js index 5ca86e331ef11..3514413e575b6 100644 --- a/src/server/config/__tests__/explode_by.js +++ b/src/server/config/__tests__/explode_by.js @@ -4,7 +4,7 @@ import expect from 'expect.js'; describe('explode_by(dot, flatObject)', function () { it('should explode a flatten object with dots', function () { - var flatObject = { + let flatObject = { 'test.enable': true, 'test.hosts': ['host-01', 'host-02'] }; @@ -17,7 +17,7 @@ describe('explode_by(dot, flatObject)', function () { }); it('should explode a flatten object with slashes', function () { - var flatObject = { + let flatObject = { 'test/enable': true, 'test/hosts': ['host-01', 'host-02'] }; diff --git a/src/server/config/__tests__/flatten_with.js b/src/server/config/__tests__/flatten_with.js index 928c441ef4a76..9dc40fc08097e 100644 --- a/src/server/config/__tests__/flatten_with.js +++ b/src/server/config/__tests__/flatten_with.js @@ -4,7 +4,7 @@ import expect from 'expect.js'; describe('flatten_with(dot, nestedObj)', function () { it('should flatten object with dot', function () { - var nestedObj = { + let nestedObj = { test: { enable: true, hosts: ['host-01', 'host-02'], diff --git a/src/server/config/__tests__/override.js b/src/server/config/__tests__/override.js index 20cb4642a4cb3..18b3117dcbe56 100644 --- a/src/server/config/__tests__/override.js +++ b/src/server/config/__tests__/override.js @@ -4,7 +4,7 @@ import expect from 'expect.js'; describe('override(target, source)', function () { it('should override the values form source to target', function () { - var target = { + let target = { test: { enable: true, host: ['host-01', 'host-02'], @@ -13,7 +13,7 @@ describe('override(target, source)', function () { } } }; - var source = { test: { client: { type: 'nosql' } } }; + let source = { test: { client: { type: 'nosql' } } }; expect(override(target, source)).to.eql({ test: { enable: true, diff --git a/src/server/config/explode_by.js b/src/server/config/explode_by.js index 4d9bd0838f356..50e2b2e82615f 100644 --- a/src/server/config/explode_by.js +++ b/src/server/config/explode_by.js @@ -1,10 +1,10 @@ import _ from 'lodash'; module.exports = function (dot, flatObject) { - var fullObject = {}; + let fullObject = {}; _.each(flatObject, function (value, key) { - var keys = key.split(dot); + let keys = key.split(dot); (function walk(memo, keys, value) { - var _key = keys.shift(); + let _key = keys.shift(); if (keys.length === 0) { memo[_key] = value; } else { diff --git a/src/server/config/flatten_with.js b/src/server/config/flatten_with.js index ac4a907130963..d4a276607bfc7 100644 --- a/src/server/config/flatten_with.js +++ b/src/server/config/flatten_with.js @@ -1,8 +1,8 @@ import _ from 'lodash'; module.exports = function (dot, nestedObj, flattenArrays) { let key; // original key - var stack = []; // track key stack - var flatObj = {}; + let stack = []; // track key stack + let flatObj = {}; (function flattenObj(obj) { _.keys(obj).forEach(function (key) { stack.push(key); diff --git a/src/server/config/override.js b/src/server/config/override.js index 0a938f29ead3a..ef850a32754ae 100644 --- a/src/server/config/override.js +++ b/src/server/config/override.js @@ -3,8 +3,8 @@ import flattenWith from './flatten_with'; import explodeBy from './explode_by'; module.exports = function (target, source) { - var _target = flattenWith('.', target); - var _source = flattenWith('.', source); + let _target = flattenWith('.', target); + let _source = flattenWith('.', source); return explodeBy('.', _.defaults(_source, _target)); }; diff --git a/src/server/logging/__tests__/apply_filters_to_keys.js b/src/server/logging/__tests__/apply_filters_to_keys.js index fc0c520520b47..0175b90ff221b 100644 --- a/src/server/logging/__tests__/apply_filters_to_keys.js +++ b/src/server/logging/__tests__/apply_filters_to_keys.js @@ -3,7 +3,7 @@ import expect from 'expect.js'; describe('applyFiltersToKeys(obj, actionsByKey)', function () { it('applies for each key+prop in actionsByKey', function () { - var data = applyFiltersToKeys({ + let data = applyFiltersToKeys({ a: { b: { c: 1 diff --git a/src/server/logging/apply_filters_to_keys.js b/src/server/logging/apply_filters_to_keys.js index 860bdd38b76f0..bc85f2fd1f555 100644 --- a/src/server/logging/apply_filters_to_keys.js +++ b/src/server/logging/apply_filters_to_keys.js @@ -21,7 +21,7 @@ function apply(obj, key, action) { obj[k] = ('' + val).replace(/./g, 'X'); } else if (/\/.+\//.test(action)) { - var matches = action.match(/\/(.+)\//); + let matches = action.match(/\/(.+)\//); if (matches) { let regex = new RegExp(matches[1]); obj[k] = ('' + val).replace(regex, replacer); diff --git a/src/server/logging/log_format.js b/src/server/logging/log_format.js index c1fa7a4744791..7d11c59abd265 100644 --- a/src/server/logging/log_format.js +++ b/src/server/logging/log_format.js @@ -41,13 +41,13 @@ module.exports = class TransformObjStream extends Stream.Transform { } _transform(event, enc, next) { - var data = this.filter(this.readEvent(event)); + let data = this.filter(this.readEvent(event)); this.push(this.format(data) + '\n'); next(); } readEvent(event) { - var data = { + let data = { type: event.event, '@timestamp': moment.utc(event.timestamp).format(), tags: [].concat(event.tags || []), @@ -69,7 +69,7 @@ module.exports = class TransformObjStream extends Stream.Transform { referer: event.source.referer }; - var contentLength = 0; + let contentLength = 0; if (typeof event.responsePayload === 'object') { contentLength = stringify(event.responsePayload).length; } else { @@ -82,7 +82,7 @@ module.exports = class TransformObjStream extends Stream.Transform { contentLength: contentLength }; - var query = querystring.stringify(event.query); + let query = querystring.stringify(event.query); if (query) data.req.url += '?' + query; diff --git a/src/server/pid/index.js b/src/server/pid/index.js index 4584d78d81b6b..e43956b959ff2 100644 --- a/src/server/pid/index.js +++ b/src/server/pid/index.js @@ -2,19 +2,19 @@ import _ from 'lodash'; import Boom from 'boom'; import Promise from 'bluebird'; import { unlinkSync as unlink } from 'fs'; -var writeFile = Promise.promisify(require('fs').writeFile); +let writeFile = Promise.promisify(require('fs').writeFile); module.exports = Promise.method(function (kbnServer, server, config) { - var path = config.get('pid.file'); + let path = config.get('pid.file'); if (!path) return; - var pid = String(process.pid); + let pid = String(process.pid); return writeFile(path, pid, { flag: 'wx' }) .catch(function (err) { if (err.code !== 'EEXIST') throw err; - var log = { + let log = { tmpl: 'pid file already exists at <%= path %>', path: path, pid: pid @@ -36,7 +36,7 @@ module.exports = Promise.method(function (kbnServer, server, config) { pid: pid }); - var clean = _.once(function (code) { + let clean = _.once(function (code) { unlink(path); }); diff --git a/src/server/plugins/scan.js b/src/server/plugins/scan.js index 07af33f38c98d..baa5147e44530 100644 --- a/src/server/plugins/scan.js +++ b/src/server/plugins/scan.js @@ -6,7 +6,7 @@ import { each } from 'bluebird'; import PluginCollection from './plugin_collection'; module.exports = async (kbnServer, server, config) => { - var plugins = kbnServer.plugins = new PluginCollection(kbnServer); + let plugins = kbnServer.plugins = new PluginCollection(kbnServer); let scanDirs = [].concat(config.get('plugins.scanDirs') || []); let pluginPaths = [].concat(config.get('plugins.paths') || []); diff --git a/src/server/status/__tests__/server_status.js b/src/server/status/__tests__/server_status.js index 82fdeef1675ef..1c18461092fa9 100644 --- a/src/server/status/__tests__/server_status.js +++ b/src/server/status/__tests__/server_status.js @@ -17,21 +17,21 @@ describe('ServerStatus class', function () { describe('#create(name)', function () { it('should create a new status by name', function () { - var status = serverStatus.create('name'); + let status = serverStatus.create('name'); expect(status).to.be.a(Status); }); }); describe('#get(name)', function () { it('exposes plugins by name', function () { - var status = serverStatus.create('name'); + let status = serverStatus.create('name'); expect(serverStatus.get('name')).to.be(status); }); }); describe('#getState(name)', function () { it('should expose the state of the plugin by name', function () { - var status = serverStatus.create('name'); + let status = serverStatus.create('name'); status.green(); expect(serverStatus.getState('name')).to.be('green'); }); @@ -39,11 +39,11 @@ describe('ServerStatus class', function () { describe('#overall()', function () { it('considers each status to produce a summary', function () { - var status = serverStatus.create('name'); + let status = serverStatus.create('name'); expect(serverStatus.overall().state).to.be('uninitialized'); - var match = function (overall, state) { + let match = function (overall, state) { expect(overall).to.have.property('state', state.id); expect(overall).to.have.property('title', state.title); expect(overall).to.have.property('icon', state.icon); @@ -65,20 +65,20 @@ describe('ServerStatus class', function () { describe('#toJSON()', function () { it('serializes to overall status and individuals', function () { - var one = serverStatus.create('one'); - var two = serverStatus.create('two'); - var three = serverStatus.create('three'); + let one = serverStatus.create('one'); + let two = serverStatus.create('two'); + let three = serverStatus.create('three'); one.green(); two.yellow(); three.red(); - var obj = JSON.parse(JSON.stringify(serverStatus)); + let obj = JSON.parse(JSON.stringify(serverStatus)); expect(obj).to.have.property('overall'); expect(obj.overall.state).to.eql(serverStatus.overall().state); expect(obj.statuses).to.have.length(3); - var outs = _.indexBy(obj.statuses, 'name'); + let outs = _.indexBy(obj.statuses, 'name'); expect(outs.one).to.have.property('state', 'green'); expect(outs.two).to.have.property('state', 'yellow'); expect(outs.three).to.have.property('state', 'red'); diff --git a/src/server/status/__tests__/status.js b/src/server/status/__tests__/status.js index 7f41596db8e76..5d390949cd387 100644 --- a/src/server/status/__tests__/status.js +++ b/src/server/status/__tests__/status.js @@ -17,7 +17,7 @@ describe('Status class', function () { }); it('emits change when the status is set', function (done) { - var status = serverStatus.create('test'); + let status = serverStatus.create('test'); status.once('change', function (prev, prevMsg) { expect(status.state).to.be('green'); @@ -40,8 +40,8 @@ describe('Status class', function () { }); it('should only trigger the change listener when something changes', function () { - var status = serverStatus.create('test'); - var stub = sinon.stub(); + let status = serverStatus.create('test'); + let stub = sinon.stub(); status.on('change', stub); status.green('Ready'); status.green('Ready'); @@ -50,17 +50,17 @@ describe('Status class', function () { }); it('should create a JSON representation of the status', function () { - var status = serverStatus.create('test'); + let status = serverStatus.create('test'); status.green('Ready'); - var json = status.toJSON(); + let json = status.toJSON(); expect(json.state).to.eql('green'); expect(json.message).to.eql('Ready'); }); it('should call on handler if status is already matched', function (done) { - var status = serverStatus.create('test'); - var msg = 'Test Ready'; + let status = serverStatus.create('test'); + let msg = 'Test Ready'; status.green(msg); status.on('green', function (prev, prevMsg) { @@ -73,8 +73,8 @@ describe('Status class', function () { }); it('should call once handler if status is already matched', function (done) { - var status = serverStatus.create('test'); - var msg = 'Test Ready'; + let status = serverStatus.create('test'); + let msg = 'Test Ready'; status.green(msg); status.once('green', function (prev, prevMsg) { @@ -88,16 +88,16 @@ describe('Status class', function () { function testState(color) { it(`should change the state to ${color} when #${color}() is called`, function () { - var status = serverStatus.create('test'); - var message = 'testing ' + color; + let status = serverStatus.create('test'); + let message = 'testing ' + color; status[color](message); expect(status).to.have.property('state', color); expect(status).to.have.property('message', message); }); it(`should trigger the "change" listner when #${color}() is called`, function (done) { - var status = serverStatus.create('test'); - var message = 'testing ' + color; + let status = serverStatus.create('test'); + let message = 'testing ' + color; status.on('change', function (prev, prevMsg) { expect(status.state).to.be(color); expect(status.message).to.be(message); @@ -110,8 +110,8 @@ describe('Status class', function () { }); it(`should trigger the "${color}" listner when #${color}() is called`, function (done) { - var status = serverStatus.create('test'); - var message = 'testing ' + color; + let status = serverStatus.create('test'); + let message = 'testing ' + color; status.on(color, function (prev, prevMsg) { expect(status.state).to.be(color); expect(status.message).to.be(message); diff --git a/src/server/status/index.js b/src/server/status/index.js index 5efbdf50b7566..fe658f2b35493 100644 --- a/src/server/status/index.js +++ b/src/server/status/index.js @@ -22,8 +22,8 @@ module.exports = function (kbnServer, server, config) { }); server.decorate('reply', 'renderStatusPage', function () { - var app = kbnServer.uiExports.getHiddenApp('status_page'); - var resp = app ? this.renderApp(app) : this(kbnServer.status.toString()); + let app = kbnServer.uiExports.getHiddenApp('status_page'); + let resp = app ? this.renderApp(app) : this(kbnServer.status.toString()); resp.code(kbnServer.status.isGreen() ? 200 : 503); return resp; }); diff --git a/src/server/status/metrics.js b/src/server/status/metrics.js index 52b32af19bfca..b5cfd6784a0f9 100644 --- a/src/server/status/metrics.js +++ b/src/server/status/metrics.js @@ -10,7 +10,7 @@ module.exports = function (kbnServer, server, config) { let secSinceLast = (now - lastReport) / 1000; lastReport = now; - var port = config.get('server.port'); + let port = config.get('server.port'); let requests = _.get(event, ['requests', port, 'total'], 0); let requestsPerSecond = requests / secSinceLast; diff --git a/src/server/status/samples.js b/src/server/status/samples.js index aac5e2efe7bf5..fd2bc4aa27c84 100644 --- a/src/server/status/samples.js +++ b/src/server/status/samples.js @@ -7,8 +7,8 @@ function Samples(max) { } Samples.prototype.add = function (sample) { - var vals = this.vals; - var length = this.length = Math.min(this.length + 1, this.max); + let vals = this.vals; + let length = this.length = Math.min(this.length + 1, this.max); _.forOwn(sample, function (val, name) { if (val == null) val = null; diff --git a/src/server/status/server_status.js b/src/server/status/server_status.js index 4fb914ca00980..33b9e848d8186 100644 --- a/src/server/status/server_status.js +++ b/src/server/status/server_status.js @@ -31,15 +31,15 @@ module.exports = class ServerStatus { } overall() { - var state = _(this._created) + let state = _(this._created) .map(function (status) { return states.get(status.state); }) .sortBy('severity') .pop(); - var statuses = _.where(this._created, { state: state.id }); - var since = _.get(_.sortBy(statuses, 'since'), [0, 'since']); + let statuses = _.where(this._created, { state: state.id }); + let since = _.get(_.sortBy(statuses, 'since'), [0, 'since']); return { state: state.id, @@ -59,7 +59,7 @@ module.exports = class ServerStatus { } toString() { - var overall = this.overall(); + let overall = this.overall(); return `${overall.title} – ${overall.nickname}`; } diff --git a/src/server/status/status.js b/src/server/status/status.js index 929118d08512f..b260694b1cdf2 100644 --- a/src/server/status/status.js +++ b/src/server/status/status.js @@ -13,7 +13,7 @@ class Status extends EventEmitter { this.on('change', function (previous, previousMsg) { this.since = new Date(); - var tags = ['status', name]; + let tags = ['status', name]; tags.push(this.state === 'red' ? 'error' : 'info'); server.log(tags, { diff --git a/src/test_utils/no_digest_promises.js b/src/test_utils/no_digest_promises.js index 98ce02c45942a..38a4203ab1b45 100644 --- a/src/test_utils/no_digest_promises.js +++ b/src/test_utils/no_digest_promises.js @@ -8,7 +8,7 @@ Bluebird.longStackTraces(); * replace the Promise service with Bluebird so that tests * can use promises without having to call $rootScope.apply() * - * var noDigestPromises = require('test_utils/no_digest_promises'); + * let noDigestPromises = require('test_utils/no_digest_promises'); * * describe('some module that does complex shit with promises', function () { * beforeEach(noDigestPromises.activate); @@ -16,7 +16,7 @@ Bluebird.longStackTraces(); * }); */ -var active = false; +let active = false; uiModules .get('kibana') diff --git a/src/test_utils/simulate_keys.js b/src/test_utils/simulate_keys.js index 0eb8c5d7a79b3..8282d8e5cc9e3 100644 --- a/src/test_utils/simulate_keys.js +++ b/src/test_utils/simulate_keys.js @@ -2,8 +2,8 @@ import $ from 'jquery'; import _ from 'lodash'; import Promise from 'bluebird'; import keyMap from 'ui/utils/key_map'; -var reverseKeyMap = _.mapValues(_.invert(keyMap), _.ary(_.parseInt, 1)); -var KeyboardEvent = window.KeyboardEvent; +let reverseKeyMap = _.mapValues(_.invert(keyMap), _.ary(_.parseInt, 1)); +let KeyboardEvent = window.KeyboardEvent; /** * Simulate keyboard events in an element. This allows testing the way that @@ -35,7 +35,7 @@ var KeyboardEvent = window.KeyboardEvent; * @async */ export default function ($el, sequence) { - var modifierState = { + let modifierState = { ctrlKey: false, shiftKey: false, altKey: false, @@ -45,7 +45,7 @@ export default function ($el, sequence) { return doList(_.clone(sequence)); function setModifier(key, state) { - var name = key + 'Key'; + let name = key + 'Key'; if (modifierState.hasOwnProperty(name)) { modifierState[name] = !!state; } @@ -55,7 +55,7 @@ export default function ($el, sequence) { return Promise.try(function () { if (!list || !list.length) return; - var event = list[0]; + let event = list[0]; if (_.isString(event)) { event = { type: 'press', key: event }; } @@ -91,14 +91,14 @@ export default function ($el, sequence) { } function fire(type, key, repeat) { - var keyCode = reverseKeyMap[key]; + let keyCode = reverseKeyMap[key]; if (!keyCode) throw new TypeError('invalid key "' + key + '"'); if (type === 'keydown') setModifier(key, true); if (type === 'keyup') setModifier(key, false); - var $target = _.isFunction($el) ? $el() : $el; - var $event = new $.Event(type, _.defaults({ keyCode: keyCode }, modifierState)); + let $target = _.isFunction($el) ? $el() : $el; + let $event = new $.Event(type, _.defaults({ keyCode: keyCode }, modifierState)); $target.trigger($event); } }; diff --git a/src/test_utils/stub_index_pattern.js b/src/test_utils/stub_index_pattern.js index 7d5f2624c15c0..45938e4acba06 100644 --- a/src/test_utils/stub_index_pattern.js +++ b/src/test_utils/stub_index_pattern.js @@ -9,10 +9,10 @@ import RegistryFieldFormatsProvider from 'ui/registry/field_formats'; import IndexPatternsFlattenHitProvider from 'ui/index_patterns/_flatten_hit'; import IndexPatternsFieldProvider from 'ui/index_patterns/_field'; export default function (Private) { - var fieldFormats = Private(RegistryFieldFormatsProvider); - var flattenHit = Private(IndexPatternsFlattenHitProvider); + let fieldFormats = Private(RegistryFieldFormatsProvider); + let flattenHit = Private(IndexPatternsFlattenHitProvider); - var Field = Private(IndexPatternsFieldProvider); + let Field = Private(IndexPatternsFieldProvider); function StubIndexPattern(pattern, timeField, fields) { this.id = pattern; diff --git a/src/utils/package_json.js b/src/utils/package_json.js index d85a159ddff17..36a953d4c000b 100644 --- a/src/utils/package_json.js +++ b/src/utils/package_json.js @@ -5,7 +5,7 @@ let packageDir; let packagePath; while (!packagePath || !existsSync(packagePath)) { - var prev = packageDir; + let prev = packageDir; packageDir = prev ? join(prev, '..') : __dirname; packagePath = join(packageDir, 'package.json');