Browse Source

changed var to let in 50 files (#13075)

Patrick O'Carroll 7 năm trước cách đây
mục cha
commit
552a61b6ae
50 tập tin đã thay đổi với 196 bổ sung196 xóa
  1. 1 1
      public/app/core/components/query_part/query_part.ts
  2. 3 3
      public/app/core/directives/misc.ts
  3. 4 4
      public/app/core/directives/rebuild_on_change.ts
  4. 1 1
      public/app/core/directives/tags.ts
  5. 1 1
      public/app/core/partials.ts
  6. 3 3
      public/app/core/profiler.ts
  7. 1 1
      public/app/core/services/backend_srv.ts
  8. 2 2
      public/app/core/services/impression_srv.ts
  9. 2 2
      public/app/core/services/ng_react.ts
  10. 10 10
      public/app/core/time_series2.ts
  11. 8 8
      public/app/core/utils/datemath.ts
  12. 6 6
      public/app/core/utils/kbn.ts
  13. 1 1
      public/app/core/utils/tags.ts
  14. 1 1
      public/app/core/utils/url.ts
  15. 1 1
      public/app/features/alerting/threshold_mapper.ts
  16. 1 1
      public/app/features/annotations/annotations_srv.ts
  17. 1 1
      public/app/features/annotations/event_manager.ts
  18. 2 2
      public/app/features/dashboard/dashboard_migration.ts
  19. 1 1
      public/app/features/dashboard/dashboard_model.ts
  20. 2 2
      public/app/features/panel/metrics_panel_ctrl.ts
  21. 2 2
      public/app/features/panel/panel_ctrl.ts
  22. 4 4
      public/app/features/templating/variable.ts
  23. 7 7
      public/app/plugins/datasource/cloudwatch/datasource.ts
  24. 2 2
      public/app/plugins/datasource/cloudwatch/query_parameter_ctrl.ts
  25. 2 2
      public/app/plugins/datasource/elasticsearch/bucket_agg.ts
  26. 9 9
      public/app/plugins/datasource/elasticsearch/datasource.ts
  27. 9 9
      public/app/plugins/datasource/elasticsearch/elastic_response.ts
  28. 1 1
      public/app/plugins/datasource/elasticsearch/metric_agg.ts
  29. 7 7
      public/app/plugins/datasource/elasticsearch/query_builder.ts
  30. 1 1
      public/app/plugins/datasource/elasticsearch/query_ctrl.ts
  31. 4 4
      public/app/plugins/datasource/graphite/add_graphite_func.ts
  32. 9 9
      public/app/plugins/datasource/graphite/datasource.ts
  33. 5 5
      public/app/plugins/datasource/graphite/func_editor.ts
  34. 3 3
      public/app/plugins/datasource/graphite/gfunc.ts
  35. 1 1
      public/app/plugins/datasource/graphite/graphite_query.ts
  36. 13 13
      public/app/plugins/datasource/graphite/lexer.ts
  37. 1 1
      public/app/plugins/datasource/graphite/parser.ts
  38. 2 2
      public/app/plugins/datasource/graphite/query_ctrl.ts
  39. 6 6
      public/app/plugins/datasource/influxdb/datasource.ts
  40. 9 9
      public/app/plugins/datasource/influxdb/influx_query.ts
  41. 6 6
      public/app/plugins/datasource/influxdb/influx_series.ts
  42. 6 6
      public/app/plugins/datasource/influxdb/query_builder.ts
  43. 3 3
      public/app/plugins/datasource/influxdb/query_ctrl.ts
  44. 2 2
      public/app/plugins/datasource/influxdb/query_part.ts
  45. 8 8
      public/app/plugins/datasource/opentsdb/datasource.ts
  46. 4 4
      public/app/plugins/datasource/prometheus/completer.ts
  47. 3 3
      public/app/plugins/datasource/prometheus/datasource.ts
  48. 2 2
      public/app/plugins/datasource/prometheus/metric_find_query.ts
  49. 1 1
      public/app/plugins/datasource/prometheus/result_transformer.ts
  50. 12 12
      public/app/plugins/panel/graph/threshold_manager.ts

+ 1 - 1
public/app/core/components/query_part/query_part.ts

@@ -74,7 +74,7 @@ export class QueryPart {
       return;
     }
 
-    var text = this.def.type + '(';
+    let text = this.def.type + '(';
     text += this.params.join(', ');
     text += ')';
     this.text = text;

+ 3 - 3
public/app/core/directives/misc.ts

@@ -9,7 +9,7 @@ function tip($compile) {
   return {
     restrict: 'E',
     link: function(scope, elem, attrs) {
-      var _t =
+      let _t =
         '<i class="grafana-tip fa fa-' +
         (attrs.icon || 'question-circle') +
         '" bs-tooltip="\'' +
@@ -125,7 +125,7 @@ function editorCheckbox($compile, $interpolate) {
       const tip = attrs.tip ? ' <tip>' + attrs.tip + '</tip>' : '';
       const label = '<label for="' + scope.$id + model + '" class="checkbox-label">' + text + tip + '</label>';
 
-      var template =
+      let template =
         '<input class="cr1" id="' +
         scope.$id +
         model +
@@ -163,7 +163,7 @@ function gfDropdown($parse, $compile, $timeout) {
         continue;
       }
 
-      var li =
+      let li =
         '<li' +
         (item.submenu && item.submenu.length ? ' class="dropdown-submenu"' : '') +
         '>' +

+ 4 - 4
public/app/core/directives/rebuild_on_change.ts

@@ -2,11 +2,11 @@ import $ from 'jquery';
 import coreModule from '../core_module';
 
 function getBlockNodes(nodes) {
-  var node = nodes[0];
+  let node = nodes[0];
   const endNode = nodes[nodes.length - 1];
-  var blockNodes;
+  let blockNodes;
 
-  for (var i = 1; node !== endNode && (node = node.nextSibling); i++) {
+  for (let i = 1; node !== endNode && (node = node.nextSibling); i++) {
     if (blockNodes || nodes[i] !== node) {
       if (!blockNodes) {
         blockNodes = $([].slice.call(nodes, 0, i));
@@ -27,7 +27,7 @@ function rebuildOnChange($animate) {
     priority: 600,
     restrict: 'E',
     link: function(scope, elem, attrs, ctrl, transclude) {
-      var block, childScope, previousElements;
+      let block, childScope, previousElements;
 
       function cleanUp() {
         if (previousElements) {

+ 1 - 1
public/app/core/directives/tags.ts

@@ -104,7 +104,7 @@ function bootstrapTagsinput() {
 
           select.tagsinput('removeAll');
 
-          for (var i = 0; i < scope.model.length; i++) {
+          for (let i = 0; i < scope.model.length; i++) {
             select.tagsinput('add', scope.model[i]);
           }
         },

+ 1 - 1
public/app/core/partials.ts

@@ -1,4 +1,4 @@
-var templates = (<any>require).context('../', true, /\.html$/);
+let templates = (<any>require).context('../', true, /\.html$/);
 templates.keys().forEach(function(key) {
   templates(key);
 });

+ 3 - 3
public/app/core/profiler.ts

@@ -69,7 +69,7 @@ export class Profiler {
 
       // measure digest performance
       const rootDigestStart = window.performance.now();
-      for (var i = 0; i < 30; i++) {
+      for (let i = 0; i < 30; i++) {
         this.$rootScope.$apply();
       }
 
@@ -78,8 +78,8 @@ export class Profiler {
   }
 
   getTotalWatcherCount() {
-    var count = 0;
-    var scopes = 0;
+    let count = 0;
+    let scopes = 0;
     const root = $(document.getElementsByTagName('body'));
 
     const f = function(element) {

+ 1 - 1
public/app/core/services/backend_srv.ts

@@ -43,7 +43,7 @@ export class BackendSrv {
       return;
     }
 
-    var data = err.data || { message: 'Unexpected error' };
+    let data = err.data || { message: 'Unexpected error' };
     if (_.isString(data)) {
       data = { message: data };
     }

+ 2 - 2
public/app/core/services/impression_srv.ts

@@ -7,7 +7,7 @@ export class ImpressionSrv {
 
   addDashboardImpression(dashboardId) {
     const impressionsKey = this.impressionKey(config);
-    var impressions = [];
+    let impressions = [];
     if (store.exists(impressionsKey)) {
       impressions = JSON.parse(store.get(impressionsKey));
       if (!_.isArray(impressions)) {
@@ -28,7 +28,7 @@ export class ImpressionSrv {
   }
 
   getDashboardOpened() {
-    var impressions = store.get(this.impressionKey(config)) || '[]';
+    let impressions = store.get(this.impressionKey(config)) || '[]';
 
     impressions = JSON.parse(impressions);
 

+ 2 - 2
public/app/core/services/ng_react.ts

@@ -27,7 +27,7 @@ function getReactComponent(name, $injector) {
   }
 
   // ensure the specified React component is accessible, and fail fast if it's not
-  var reactComponent;
+  let reactComponent;
   try {
     reactComponent = $injector.get(name);
   } catch (e) {}
@@ -256,7 +256,7 @@ const reactDirective = function($injector) {
 
         // for each of the properties, get their scope value and set it to scope.props
         const renderMyComponent = function() {
-          var scopeProps = {};
+          let scopeProps = {};
           const config = {};
 
           props.forEach(function(prop) {

+ 10 - 10
public/app/core/time_series2.ts

@@ -124,7 +124,7 @@ export default class TimeSeries {
     delete this.stack;
     delete this.bars.show;
 
-    for (var i = 0; i < overrides.length; i++) {
+    for (let i = 0; i < overrides.length; i++) {
       const override = overrides[i];
       if (!matchSeriesOverride(override.alias, this.alias)) {
         continue;
@@ -211,14 +211,14 @@ export default class TimeSeries {
 
     const ignoreNulls = fillStyle === 'connected';
     const nullAsZero = fillStyle === 'null as zero';
-    var currentTime;
-    var currentValue;
-    var nonNulls = 0;
-    var previousTime;
-    var previousValue = 0;
-    var previousDeltaUp = true;
-
-    for (var i = 0; i < this.datapoints.length; i++) {
+    let currentTime;
+    let currentValue;
+    let nonNulls = 0;
+    let previousTime;
+    let previousValue = 0;
+    let previousDeltaUp = true;
+
+    for (let i = 0; i < this.datapoints.length; i++) {
       currentValue = this.datapoints[i][0];
       currentTime = this.datapoints[i][1];
 
@@ -328,7 +328,7 @@ export default class TimeSeries {
   }
 
   isMsResolutionNeeded() {
-    for (var i = 0; i < this.datapoints.length; i++) {
+    for (let i = 0; i < this.datapoints.length; i++) {
       if (this.datapoints[i][1] !== null) {
         const timestamp = this.datapoints[i][1].toString();
         if (timestamp.length === 13 && timestamp % 1000 !== 0) {

+ 8 - 8
public/app/core/utils/datemath.ts

@@ -14,10 +14,10 @@ export function parse(text, roundUp?, timezone?) {
     return moment(text);
   }
 
-  var time;
-  var mathString = '';
-  var index;
-  var parseString;
+  let time;
+  let mathString = '';
+  let index;
+  let parseString;
 
   if (text.substring(0, 3) === 'now') {
     if (timezone === 'utc') {
@@ -61,14 +61,14 @@ export function isValid(text) {
 
 export function parseDateMath(mathString, time, roundUp?) {
   const dateTime = time;
-  var i = 0;
+  let i = 0;
   const len = mathString.length;
 
   while (i < len) {
     const c = mathString.charAt(i++);
-    var type;
-    var num;
-    var unit;
+    let type;
+    let num;
+    let unit;
 
     if (c === '/') {
       type = 0;

+ 6 - 6
public/app/core/utils/kbn.ts

@@ -169,8 +169,8 @@ kbn.intervals_in_seconds = {
 };
 
 kbn.calculateInterval = function(range, resolution, lowLimitInterval) {
-  var lowLimitMs = 1; // 1 millisecond default low limit
-  var intervalMs;
+  let lowLimitMs = 1; // 1 millisecond default low limit
+  let intervalMs;
 
   if (lowLimitInterval) {
     if (lowLimitInterval[0] === '>') {
@@ -304,7 +304,7 @@ kbn.formatBuilders.scaledUnits = function(factor, extArray) {
       return '';
     }
 
-    var steps = 0;
+    let steps = 0;
     const limit = extArray.length;
 
     while (Math.abs(size) >= factor) {
@@ -328,7 +328,7 @@ kbn.formatBuilders.scaledUnits = function(factor, extArray) {
 // offset is given, it adjusts the starting units at the given prefix; a value
 // of 0 starts at no scale; -3 drops to nano, +2 starts at mega, etc.
 kbn.formatBuilders.decimalSIPrefix = function(unit, offset) {
-  var prefixes = ['n', 'µ', 'm', '', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
+  let prefixes = ['n', 'µ', 'm', '', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
   prefixes = prefixes.slice(3 + (offset || 0));
   const units = prefixes.map(function(p) {
     return ' ' + p + unit;
@@ -790,8 +790,8 @@ kbn.toDuration = function(size, decimals, timeScale) {
 
   const strings = [];
   // after first value >= 1 print only $decimals more
-  var decrementDecimals = false;
-  for (var i = 0; i < units.length && decimals >= 0; i++) {
+  let decrementDecimals = false;
+  for (let i = 0; i < units.length && decimals >= 0; i++) {
     const interval = kbn.intervals_in_seconds[units[i].short] * 1000;
     const value = size / interval;
     if (value >= 1 || decrementDecimals) {

+ 1 - 1
public/app/core/utils/tags.ts

@@ -75,7 +75,7 @@ export function getTagColorsFromName(name: string): { color: string; borderColor
 
 function djb2(str) {
   let hash = 5381;
-  for (var i = 0; i < str.length; i++) {
+  for (let i = 0; i < str.length; i++) {
     hash = (hash << 5) + hash + str.charCodeAt(i); /* hash * 33 + c */
   }
   return hash;

+ 1 - 1
public/app/core/utils/url.ts

@@ -20,7 +20,7 @@ export function toUrlParams(a) {
   };
 
   const buildParams = function(prefix, obj) {
-    var i, len, key;
+    let i, len, key;
 
     if (prefix) {
       if (isArray(obj)) {

+ 1 - 1
public/app/features/alerting/threshold_mapper.ts

@@ -1,6 +1,6 @@
 export class ThresholdMapper {
   static alertToGraphThresholds(panel) {
-    for (var i = 0; i < panel.alert.conditions.length; i++) {
+    for (let i = 0; i < panel.alert.conditions.length; i++) {
       const condition = panel.alert.conditions[i];
       if (condition.type !== 'query') {
         continue;

+ 1 - 1
public/app/features/annotations/annotations_srv.ts

@@ -25,7 +25,7 @@ export class AnnotationsSrv {
       .all([this.getGlobalAnnotations(options), this.getAlertStates(options)])
       .then(results => {
         // combine the annotations and flatten results
-        var annotations = _.flattenDeep(results[0]);
+        let annotations = _.flattenDeep(results[0]);
 
         // filter out annotations that do not belong to requesting panel
         annotations = _.filter(annotations, item => {

+ 1 - 1
public/app/features/annotations/event_manager.ts

@@ -102,7 +102,7 @@ export class EventManager {
       }
     } else {
       // annotations from query
-      for (var i = 0; i < annotations.length; i++) {
+      for (let i = 0; i < annotations.length; i++) {
         const item = annotations[i];
 
         // add properties used by jquery flot events

+ 2 - 2
public/app/features/dashboard/dashboard_migration.ts

@@ -18,7 +18,7 @@ export class DashboardMigrator {
   }
 
   updateSchema(old) {
-    var i, j, k, n;
+    let i, j, k, n;
     const oldVersion = this.dashboard.schemaVersion;
     const panelUpgrades = [];
     this.dashboard.schemaVersion = 16;
@@ -83,7 +83,7 @@ export class DashboardMigrator {
     // schema version 3 changes
     if (oldVersion < 3) {
       // ensure panel ids
-      var maxId = this.dashboard.getNextPanelId();
+      let maxId = this.dashboard.getNextPanelId();
       panelUpgrades.push(function(panel) {
         if (!panel.id) {
           panel.id = maxId;

+ 1 - 1
public/app/features/dashboard/dashboard_model.ts

@@ -144,7 +144,7 @@ export class DashboardModel {
     });
 
     // make clone
-    var copy: any = {};
+    let copy: any = {};
     for (const property in this) {
       if (DashboardModel.nonPersistedProperties[property] || !this.hasOwnProperty(property)) {
         continue;

+ 2 - 2
public/app/features/panel/metrics_panel_ctrl.ts

@@ -75,7 +75,7 @@ class MetricsPanelCtrl extends PanelCtrl {
     // if we have snapshot data use that
     if (this.panel.snapshotData) {
       this.updateTimeRange();
-      var data = this.panel.snapshotData;
+      let data = this.panel.snapshotData;
       // backward compatibility
       if (!_.isArray(data)) {
         data = data.data;
@@ -155,7 +155,7 @@ class MetricsPanelCtrl extends PanelCtrl {
   }
 
   calculateInterval() {
-    var intervalOverride = this.panel.interval;
+    let intervalOverride = this.panel.interval;
 
     // if no panel interval check datasource
     if (intervalOverride) {

+ 2 - 2
public/app/features/panel/panel_ctrl.ts

@@ -317,7 +317,7 @@ export class PanelCtrl {
   }
 
   getInfoContent(options) {
-    var markdown = this.panel.description;
+    let markdown = this.panel.description;
 
     if (options.mode === 'tooltip') {
       markdown = this.error || this.panel.description;
@@ -327,7 +327,7 @@ export class PanelCtrl {
     const sanitize = this.$injector.get('$sanitize');
     const templateSrv = this.$injector.get('templateSrv');
     const interpolatedMarkdown = templateSrv.replace(markdown, this.panel.scopedVars);
-    var html = '<div class="markdown-html">';
+    let html = '<div class="markdown-html">';
 
     html += new Remarkable().render(interpolatedMarkdown);
 

+ 4 - 4
public/app/features/templating/variable.ts

@@ -10,14 +10,14 @@ export interface Variable {
   getSaveModel();
 }
 
-export var variableTypes = {};
+export let variableTypes = {};
 export { assignModelProperties };
 
 export function containsVariable(...args: any[]) {
-  var variableName = args[args.length - 1];
-  var str = args[0] || '';
+  let variableName = args[args.length - 1];
+  let str = args[0] || '';
 
-  for (var i = 1; i < args.length - 1; i++) {
+  for (let i = 1; i < args.length - 1; i++) {
     str += ' ' + args[i] || '';
   }
 

+ 7 - 7
public/app/plugins/datasource/cloudwatch/datasource.ts

@@ -85,12 +85,12 @@ export default class CloudWatchDatasource {
     const end = this.convertToCloudWatchTime(options.range.to, true);
     now = Math.round((now || Date.now()) / 1000);
 
-    var period;
+    let period;
     const range = end - start;
 
     const hourSec = 60 * 60;
     const daySec = hourSec * 24;
-    var periodUnit = 60;
+    let periodUnit = 60;
     if (!target.period) {
       if (now - start <= daySec * 15) {
         // until 15 days ago
@@ -222,10 +222,10 @@ export default class CloudWatchDatasource {
   }
 
   metricFindQuery(query) {
-    var region;
-    var namespace;
-    var metricName;
-    var filterJson;
+    let region;
+    let namespace;
+    let metricName;
+    let filterJson;
 
     const regionQuery = query.match(/^regions\(\)/);
     if (regionQuery) {
@@ -291,7 +291,7 @@ export default class CloudWatchDatasource {
       return this.templateSrv.replace(s);
     });
     const defaultPeriod = annotation.prefixMatching ? '' : '300';
-    var period = annotation.period || defaultPeriod;
+    let period = annotation.period || defaultPeriod;
     period = parseInt(period, 10);
     const parameters = {
       prefixMatching: annotation.prefixMatching,

+ 2 - 2
public/app/plugins/datasource/cloudwatch/query_parameter_ctrl.ts

@@ -120,7 +120,7 @@ export class CloudWatchQueryParameterCtrl {
       }
 
       const target = $scope.target;
-      var query = $q.when([]);
+      let query = $q.when([]);
 
       if (segment.type === 'key' || segment.type === 'plus-button') {
         query = $scope.datasource.getDimensionKeys($scope.target.namespace, $scope.target.region);
@@ -164,7 +164,7 @@ export class CloudWatchQueryParameterCtrl {
       const dims = {};
       const length = $scope.dimSegments.length;
 
-      for (var i = 0; i < length - 2; i += 3) {
+      for (let i = 0; i < length - 2; i += 3) {
         const keySegment = $scope.dimSegments[i];
         const valueSegment = $scope.dimSegments[i + 2];
         if (!valueSegment.fake) {

+ 2 - 2
public/app/plugins/datasource/elasticsearch/bucket_agg.ts

@@ -84,7 +84,7 @@ export class ElasticBucketAggCtrl {
       $scope.isFirst = $scope.index === 0;
       $scope.bucketAggCount = bucketAggs.length;
 
-      var settingsLinkText = '';
+      let settingsLinkText = '';
       const settings = $scope.agg.settings || {};
 
       switch ($scope.agg.type) {
@@ -199,7 +199,7 @@ export class ElasticBucketAggCtrl {
     $scope.addBucketAgg = function() {
       // if last is date histogram add it before
       const lastBucket = bucketAggs[bucketAggs.length - 1];
-      var addIndex = bucketAggs.length - 1;
+      let addIndex = bucketAggs.length - 1;
 
       if (lastBucket && lastBucket.type === 'date_histogram') {
         addIndex -= 1;

+ 9 - 9
public/app/plugins/datasource/elasticsearch/datasource.ts

@@ -151,9 +151,9 @@ export class ElasticDatasource {
         }
 
         const fieldNames = fieldName.split('.');
-        var fieldValue = source;
+        let fieldValue = source;
 
-        for (var i = 0; i < fieldNames.length; i++) {
+        for (let i = 0; i < fieldNames.length; i++) {
           fieldValue = fieldValue[fieldNames[i]];
           if (!fieldValue) {
             console.log('could not find field in annotation: ', fieldName);
@@ -164,9 +164,9 @@ export class ElasticDatasource {
         return fieldValue;
       };
 
-      for (var i = 0; i < hits.length; i++) {
+      for (let i = 0; i < hits.length; i++) {
         const source = hits[i]._source;
-        var time = getFieldFromSource(source, timeField);
+        let time = getFieldFromSource(source, timeField);
         if (typeof hits[i].fields !== 'undefined') {
           const fields = hits[i].fields;
           if (_.isString(fields[timeField]) || _.isNumber(fields[timeField])) {
@@ -216,7 +216,7 @@ export class ElasticDatasource {
       function(err) {
         console.log(err);
         if (err.data && err.data.error) {
-          var message = angular.toJson(err.data.error);
+          let message = angular.toJson(err.data.error);
           if (err.data.error.reason) {
             message = err.data.error.reason;
           }
@@ -241,14 +241,14 @@ export class ElasticDatasource {
   }
 
   query(options) {
-    var payload = '';
-    var target;
+    let payload = '';
+    let target;
     const sentTargets = [];
 
     // add global adhoc filters to timeFilter
     const adhocFilters = this.templateSrv.getAdhocFilters(this.name);
 
-    for (var i = 0; i < options.targets.length; i++) {
+    for (let i = 0; i < options.targets.length; i++) {
       target = options.targets[i];
       if (target.hide) {
         continue;
@@ -362,7 +362,7 @@ export class ElasticDatasource {
     const range = this.timeSrv.timeRange();
     const searchType = this.esVersion >= 5 ? 'query_then_fetch' : 'count';
     const header = this.getQueryHeader(searchType, range.from, range.to);
-    var esQuery = angular.toJson(this.queryBuilder.getTermsQuery(queryDef));
+    let esQuery = angular.toJson(this.queryBuilder.getTermsQuery(queryDef));
 
     esQuery = esQuery.replace(/\$timeFrom/g, range.from.valueOf());
     esQuery = esQuery.replace(/\$timeTo/g, range.to.valueOf());

+ 9 - 9
public/app/plugins/datasource/elasticsearch/elastic_response.ts

@@ -9,7 +9,7 @@ export class ElasticResponse {
   }
 
   processMetrics(esAgg, target, seriesList, props) {
-    var metric, y, i, newSeries, bucket, value;
+    let metric, y, i, newSeries, bucket, value;
 
     for (y = 0; y < target.metrics.length; y++) {
       metric = target.metrics[y];
@@ -177,7 +177,7 @@ export class ElasticResponse {
   // This is quite complex
   // need to recurise down the nested buckets to build series
   processBuckets(aggs, target, seriesList, table, props, depth) {
-    var bucket, aggDef, esAgg, aggId;
+    let bucket, aggDef, esAgg, aggId;
     const maxDepth = target.bucketAggs.length - 1;
 
     for (aggId in aggs) {
@@ -213,7 +213,7 @@ export class ElasticResponse {
   }
 
   private getMetricName(metric) {
-    var metricDef = _.find(queryDef.metricAggTypes, { value: metric });
+    let metricDef = _.find(queryDef.metricAggTypes, { value: metric });
     if (!metricDef) {
       metricDef = _.find(queryDef.extendedStats, { value: metric });
     }
@@ -222,7 +222,7 @@ export class ElasticResponse {
   }
 
   private getSeriesName(series, target, metricTypeCount) {
-    var metricName = this.getMetricName(series.metric);
+    let metricName = this.getMetricName(series.metric);
 
     if (target.alias) {
       const regex = /\{\{([\s\S]+?)\}\}/g;
@@ -263,7 +263,7 @@ export class ElasticResponse {
       return metricName;
     }
 
-    var name = '';
+    let name = '';
     for (const propName in series.props) {
       name += series.props[propName] + ' ';
     }
@@ -278,7 +278,7 @@ export class ElasticResponse {
   nameSeries(seriesList, target) {
     const metricTypeCount = _.uniq(_.map(seriesList, 'metric')).length;
 
-    for (var i = 0; i < seriesList.length; i++) {
+    for (let i = 0; i < seriesList.length; i++) {
       const series = seriesList[i];
       series.target = this.getSeriesName(series, target, metricTypeCount);
     }
@@ -292,7 +292,7 @@ export class ElasticResponse {
       total: hits.total,
       filterable: true,
     };
-    var propName, hit, doc, i;
+    let propName, hit, doc, i;
 
     for (i = 0; i < hits.hits.length; i++) {
       hit = hits.hits[i];
@@ -351,7 +351,7 @@ export class ElasticResponse {
   getTimeSeries() {
     const seriesList = [];
 
-    for (var i = 0; i < this.response.responses.length; i++) {
+    for (let i = 0; i < this.response.responses.length; i++) {
       const response = this.response.responses[i];
       if (response.error) {
         throw this.getErrorFromElasticResponse(this.response, response.error);
@@ -371,7 +371,7 @@ export class ElasticResponse {
         this.trimDatapoints(tmpSeriesList, target);
         this.nameSeries(tmpSeriesList, target);
 
-        for (var y = 0; y < tmpSeriesList.length; y++) {
+        for (let y = 0; y < tmpSeriesList.length; y++) {
           seriesList.push(tmpSeriesList[y]);
         }
 

+ 1 - 1
public/app/plugins/datasource/elasticsearch/metric_agg.ts

@@ -140,7 +140,7 @@ export class ElasticMetricAggCtrl {
     $scope.updateMovingAvgModelSettings = function() {
       const modelSettingsKeys = [];
       const modelSettings = queryDef.getMovingAvgSettings($scope.agg.settings.model, false);
-      for (var i = 0; i < modelSettings.length; i++) {
+      for (let i = 0; i < modelSettings.length; i++) {
         modelSettingsKeys.push(modelSettings[i].value);
       }
 

+ 7 - 7
public/app/plugins/datasource/elasticsearch/query_builder.ts

@@ -21,7 +21,7 @@ export class ElasticQueryBuilder {
   }
 
   buildTermsAgg(aggDef, queryNode, target) {
-    var metricRef, metric, y;
+    let metricRef, metric, y;
     queryNode.terms = { field: aggDef.field };
 
     if (!aggDef.settings) {
@@ -94,9 +94,9 @@ export class ElasticQueryBuilder {
 
   getFiltersAgg(aggDef) {
     const filterObj = {};
-    for (var i = 0; i < aggDef.settings.filters.length; i++) {
+    for (let i = 0; i < aggDef.settings.filters.length; i++) {
       const query = aggDef.settings.filters[i].query;
-      var label = aggDef.settings.filters[i].label;
+      let label = aggDef.settings.filters[i].label;
       label = label === '' || label === undefined ? query : label;
       filterObj[label] = {
         query_string: {
@@ -133,7 +133,7 @@ export class ElasticQueryBuilder {
       return;
     }
 
-    var i, filter, condition, queryCondition;
+    let i, filter, condition, queryCondition;
 
     for (i = 0; i < adhocFilters.length; i++) {
       filter = adhocFilters[i];
@@ -181,7 +181,7 @@ export class ElasticQueryBuilder {
     target.bucketAggs = target.bucketAggs || [{ type: 'date_histogram', id: '2', settings: { interval: 'auto' } }];
     target.timeField = this.timeField;
 
-    var i, nestedAggs, metric;
+    let i, nestedAggs, metric;
     const query = {
       size: 0,
       query: {
@@ -258,7 +258,7 @@ export class ElasticQueryBuilder {
       }
 
       const aggField = {};
-      var metricAgg = null;
+      let metricAgg = null;
 
       if (queryDef.isPipelineAgg(metric.type)) {
         if (metric.pipelineAgg && /^\d*$/.test(metric.pipelineAgg)) {
@@ -302,7 +302,7 @@ export class ElasticQueryBuilder {
       });
     }
 
-    var size = 500;
+    let size = 500;
     if (queryDef.size) {
       size = queryDef.size;
     }

+ 1 - 1
public/app/plugins/datasource/elasticsearch/query_ctrl.ts

@@ -43,7 +43,7 @@ export class ElasticQueryCtrl extends QueryCtrl {
     const bucketAggs = this.target.bucketAggs;
     const metricAggTypes = queryDef.getMetricAggTypes(this.esVersion);
     const bucketAggTypes = queryDef.bucketAggTypes;
-    var text = '';
+    let text = '';
 
     if (this.target.query) {
       text += 'Query: ' + this.target.query + ', ';

+ 4 - 4
public/app/plugins/datasource/graphite/add_graphite_func.ts

@@ -35,7 +35,7 @@ export function graphiteAddFunc($compile) {
           minLength: 1,
           items: 10,
           updater: function(value) {
-            var funcDef = ctrl.datasource.getFuncDef(value);
+            let funcDef = ctrl.datasource.getFuncDef(value);
             if (!funcDef) {
               // try find close match
               value = value.toLowerCase();
@@ -81,7 +81,7 @@ export function graphiteAddFunc($compile) {
         $compile(elem.contents())($scope);
       });
 
-      var drop;
+      let drop;
       const cleanUpDrop = function() {
         if (drop) {
           drop.destroy();
@@ -93,7 +93,7 @@ export function graphiteAddFunc($compile) {
         .on('mouseenter', 'ul.dropdown-menu li', function() {
           cleanUpDrop();
 
-          var funcDef;
+          let funcDef;
           try {
             funcDef = ctrl.datasource.getFuncDef($('a', this).text());
           } catch (e) {
@@ -101,7 +101,7 @@ export function graphiteAddFunc($compile) {
           }
 
           if (funcDef && funcDef.description) {
-            var shortDesc = funcDef.description;
+            let shortDesc = funcDef.description;
             if (shortDesc.length > 500) {
               shortDesc = shortDesc.substring(0, 497) + '...';
             }

+ 9 - 9
public/app/plugins/datasource/graphite/datasource.ts

@@ -74,9 +74,9 @@ export function GraphiteDatasource(instanceSettings, $q, backendSrv, templateSrv
     if (!result || !result.data) {
       return [];
     }
-    for (var i = 0; i < result.data.length; i++) {
+    for (let i = 0; i < result.data.length; i++) {
       const series = result.data[i];
-      for (var y = 0; y < series.datapoints.length; y++) {
+      for (let y = 0; y < series.datapoints.length; y++) {
         series.datapoints[y][1] *= 1000;
       }
     }
@@ -109,10 +109,10 @@ export function GraphiteDatasource(instanceSettings, $q, backendSrv, templateSrv
       return this.query(graphiteQuery).then(function(result) {
         const list = [];
 
-        for (var i = 0; i < result.data.length; i++) {
+        for (let i = 0; i < result.data.length; i++) {
           const target = result.data[i];
 
-          for (var y = 0; y < target.datapoints.length; y++) {
+          for (let y = 0; y < target.datapoints.length; y++) {
             const datapoint = target.datapoints[y];
             if (!datapoint[0]) {
               continue;
@@ -133,10 +133,10 @@ export function GraphiteDatasource(instanceSettings, $q, backendSrv, templateSrv
       const tags = templateSrv.replace(options.annotation.tags);
       return this.events({ range: options.rangeRaw, tags: tags }).then(results => {
         const list = [];
-        for (var i = 0; i < results.data.length; i++) {
+        for (let i = 0; i < results.data.length; i++) {
           const e = results.data[i];
 
-          var tags = e.tags;
+          let tags = e.tags;
           if (_.isString(e.tags)) {
             tags = this.parseTags(e.tags);
           }
@@ -157,7 +157,7 @@ export function GraphiteDatasource(instanceSettings, $q, backendSrv, templateSrv
 
   this.events = function(options) {
     try {
-      var tags = '';
+      let tags = '';
       if (options.tags) {
         tags = '&tags=' + options.tags;
       }
@@ -493,10 +493,10 @@ export function GraphiteDatasource(instanceSettings, $q, backendSrv, templateSrv
     const graphite_options = ['from', 'until', 'rawData', 'format', 'maxDataPoints', 'cacheTimeout'];
     const clean_options = [],
       targets = {};
-    var target, targetValue, i;
+    let target, targetValue, i;
     const regex = /\#([A-Z])/g;
     const intervalFormatFixRegex = /'(\d+)m'/gi;
-    var hasTargets = false;
+    let hasTargets = false;
 
     options['format'] = 'json';
 

+ 5 - 5
public/app/plugins/datasource/graphite/func_editor.ts

@@ -24,9 +24,9 @@ export function graphiteFuncEditor($compile, templateSrv, popoverSrv) {
       const $funcControls = $(funcControlsTemplate);
       const ctrl = $scope.ctrl;
       const func = $scope.func;
-      var scheduledRelink = false;
-      var paramCountAtLink = 0;
-      var cancelBlur = null;
+      let scheduledRelink = false;
+      let paramCountAtLink = 0;
+      let cancelBlur = null;
 
       function clickFuncParam(paramIndex) {
         /*jshint validthis:true */
@@ -133,7 +133,7 @@ export function graphiteFuncEditor($compile, templateSrv, popoverSrv) {
       function addTypeahead($input, paramIndex) {
         $input.attr('data-provide', 'typeahead');
 
-        var options = paramDef(paramIndex).options;
+        let options = paramDef(paramIndex).options;
         if (paramDef(paramIndex).type === 'int') {
           options = _.map(options, function(val) {
             return val.toString();
@@ -190,7 +190,7 @@ export function graphiteFuncEditor($compile, templateSrv, popoverSrv) {
             return false;
           }
 
-          var paramValue = templateSrv.highlightVariablesAsHtml(func.params[index]);
+          let paramValue = templateSrv.highlightVariablesAsHtml(func.params[index]);
 
           const last = index >= func.params.length - 1 && param.optional && !paramValue;
           if (last && param.multiple) {

+ 3 - 3
public/app/plugins/datasource/graphite/gfunc.ts

@@ -967,7 +967,7 @@ export class FuncInstance {
     const parameters = _.map(
       this.params,
       function(value, index) {
-        var paramType;
+        let paramType;
         if (index < this.def.params.length) {
           paramType = this.def.params[index].type;
         } else if (_.get(_.last(this.def.params), 'multiple')) {
@@ -1041,7 +1041,7 @@ export class FuncInstance {
       return;
     }
 
-    var text = this.def.name + '(';
+    let text = this.def.name + '(';
     text += this.params.join(', ');
     text += ')';
     this.text = text;
@@ -1086,7 +1086,7 @@ function parseFuncDefs(rawDefs) {
       return;
     }
 
-    var description = funcDef.description;
+    let description = funcDef.description;
     if (description) {
       // tidy up some pydoc syntax that rst2html can't handle
       description = description

+ 1 - 1
public/app/plugins/datasource/graphite/graphite_query.ts

@@ -179,7 +179,7 @@ export default class GraphiteQuery {
     delete targetsByRefId[target.refId];
 
     const nestedSeriesRefRegex = /\#([A-Z])/g;
-    var targetWithNestedQueries = target.target;
+    let targetWithNestedQueries = target.target;
 
     // Use ref count to track circular references
     function countTargetRefs(targetsByRefId, refId) {

+ 13 - 13
public/app/plugins/datasource/graphite/lexer.ts

@@ -900,7 +900,7 @@ const unicodeLetterTable = [
 
 const identifierStartTable = [];
 
-for (var i = 0; i < 128; i++) {
+for (let i = 0; i < 128; i++) {
   identifierStartTable[i] =
     (i >= 48 && i <= 57) || // 0-9
     i === 36 || // $
@@ -941,7 +941,7 @@ Lexer.prototype = {
 
   tokenize: function() {
     const list = [];
-    var token;
+    let token;
     while ((token = this.next())) {
       list.push(token);
     }
@@ -964,7 +964,7 @@ Lexer.prototype = {
       }
     }
 
-    var match = this.scanStringLiteral();
+    let match = this.scanStringLiteral();
     if (match) {
       return match;
     }
@@ -1007,9 +1007,9 @@ Lexer.prototype = {
    * (true/false) and NullLiteral (null).
    */
   scanIdentifier: function() {
-    var id = '';
-    var index = 0;
-    var type, char;
+    let id = '';
+    let index = 0;
+    let type, char;
 
     // Detects any character in the Unicode categories "Uppercase
     // letter (Lu)", "Lowercase letter (Ll)", "Titlecase letter
@@ -1020,7 +1020,7 @@ Lexer.prototype = {
     // Google's Traceur.
 
     function isUnicodeLetter(code) {
-      for (var i = 0; i < unicodeLetterTable.length; ) {
+      for (let i = 0; i < unicodeLetterTable.length; ) {
         if (code < unicodeLetterTable[i++]) {
           return false;
         }
@@ -1049,7 +1049,7 @@ Lexer.prototype = {
       const ch2 = this.peek(index + 2);
       const ch3 = this.peek(index + 3);
       const ch4 = this.peek(index + 4);
-      var code;
+      let code;
 
       if (isHexDigit(ch1) && isHexDigit(ch2) && isHexDigit(ch3) && isHexDigit(ch4)) {
         code = parseInt(ch1 + ch2 + ch3 + ch4, 16);
@@ -1168,11 +1168,11 @@ Lexer.prototype = {
    * scanNumericLiteral function in the Esprima parser's source code.
    */
   scanNumericLiteral: function(): any {
-    var index = 0;
-    var value = '';
+    let index = 0;
+    let value = '';
     const length = this.input.length;
-    var char = this.peek(index);
-    var bad;
+    let char = this.peek(index);
+    let bad;
 
     function isDecimalDigit(str) {
       return /^[0-9]$/.test(str);
@@ -1418,7 +1418,7 @@ Lexer.prototype = {
       return null;
     }
 
-    var value = '';
+    let value = '';
 
     this.skip();
 

+ 1 - 1
public/app/plugins/datasource/graphite/parser.ts

@@ -26,7 +26,7 @@ Parser.prototype = {
 
   curlyBraceSegment: function() {
     if (this.match('identifier', '{') || this.match('{')) {
-      var curlySegment = '';
+      let curlySegment = '';
 
       while (!this.match('') && !this.match('}')) {
         curlySegment += this.consumeToken().value;

+ 2 - 2
public/app/plugins/datasource/graphite/query_ctrl.ts

@@ -106,7 +106,7 @@ export class GraphiteQueryCtrl extends QueryCtrl {
   }
 
   getAltSegments(index, prefix) {
-    var query = prefix && prefix.length > 0 ? '*' + prefix + '*' : '*';
+    let query = prefix && prefix.length > 0 ? '*' + prefix + '*' : '*';
     if (index > 0) {
       query = this.queryModel.getSegmentPathUpTo(index) + '.' + query;
     }
@@ -291,7 +291,7 @@ export class GraphiteQueryCtrl extends QueryCtrl {
       return;
     }
 
-    for (var i = 0; i < this.segments.length; i++) {
+    for (let i = 0; i < this.segments.length; i++) {
       if (this.segments[i].value.indexOf('*') >= 0) {
         func.params[0] = i;
         func.added = false;

+ 6 - 6
public/app/plugins/datasource/influxdb/datasource.ts

@@ -40,14 +40,14 @@ export default class InfluxDatasource {
   }
 
   query(options) {
-    var timeFilter = this.getTimeFilter(options);
+    let timeFilter = this.getTimeFilter(options);
     const scopedVars = options.scopedVars;
     const targets = _.cloneDeep(options.targets);
     const queryTargets = [];
-    var queryModel;
-    var i, y;
+    let queryModel;
+    let i, y;
 
-    var allQueries = _.map(targets, target => {
+    let allQueries = _.map(targets, target => {
       if (target.hide) {
         return '';
       }
@@ -95,7 +95,7 @@ export default class InfluxDatasource {
         }
 
         const target = queryTargets[i];
-        var alias = target.alias;
+        let alias = target.alias;
         if (alias) {
           alias = this.templateSrv.replace(target.alias, options.scopedVars);
         }
@@ -132,7 +132,7 @@ export default class InfluxDatasource {
     }
 
     const timeFilter = this.getTimeFilter({ rangeRaw: options.rangeRaw });
-    var query = options.annotation.query.replace('$timeFilter', timeFilter);
+    let query = options.annotation.query.replace('$timeFilter', timeFilter);
     query = this.templateSrv.replace(query, null, 'regex');
 
     return this._seriesQuery(query, options).then(data => {

+ 9 - 9
public/app/plugins/datasource/influxdb/influx_query.ts

@@ -125,9 +125,9 @@ export default class InfluxQuery {
   }
 
   private renderTagCondition(tag, index, interpolate) {
-    var str = '';
-    var operator = tag.operator;
-    var value = tag.value;
+    let str = '';
+    let operator = tag.operator;
+    let value = tag.value;
     if (index > 0) {
       str = (tag.condition || 'AND') + ' ';
     }
@@ -156,8 +156,8 @@ export default class InfluxQuery {
   }
 
   getMeasurementAndPolicy(interpolate) {
-    var policy = this.target.policy;
-    var measurement = this.target.measurement || 'measurement';
+    let policy = this.target.policy;
+    let measurement = this.target.measurement || 'measurement';
 
     if (!measurement.match('^/.*/$')) {
       measurement = '"' + measurement + '"';
@@ -199,11 +199,11 @@ export default class InfluxQuery {
       }
     }
 
-    var query = 'SELECT ';
-    var i, y;
+    let query = 'SELECT ';
+    let i, y;
     for (i = 0; i < this.selectModels.length; i++) {
       const parts = this.selectModels[i];
-      var selectText = '';
+      let selectText = '';
       for (y = 0; y < parts.length; y++) {
         const part = parts[y];
         selectText = part.render(selectText);
@@ -226,7 +226,7 @@ export default class InfluxQuery {
 
     query += '$timeFilter';
 
-    var groupBySection = '';
+    let groupBySection = '';
     for (i = 0; i < this.groupByParts.length; i++) {
       const part = this.groupByParts[i];
       if (i > 0) {

+ 6 - 6
public/app/plugins/datasource/influxdb/influx_series.ts

@@ -14,7 +14,7 @@ export default class InfluxSeries {
 
   getTimeSeries() {
     const output = [];
-    var i, j;
+    let i, j;
 
     if (this.series.length === 0) {
       return output;
@@ -27,7 +27,7 @@ export default class InfluxSeries {
       });
 
       for (j = 1; j < columns; j++) {
-        var seriesName = series.name;
+        let seriesName = series.name;
         const columnName = series.columns[j];
         if (columnName !== 'value') {
           seriesName = seriesName + '.' + columnName;
@@ -86,10 +86,10 @@ export default class InfluxSeries {
     const list = [];
 
     _.each(this.series, series => {
-      var titleCol = null;
-      var timeCol = null;
+      let titleCol = null;
+      let timeCol = null;
       const tagsCol = [];
-      var textCol = null;
+      let textCol = null;
 
       _.each(series.columns, (column, index) => {
         if (column === 'time') {
@@ -143,7 +143,7 @@ export default class InfluxSeries {
 
   getTable() {
     const table = new TableModel();
-    var i, j;
+    let i, j;
 
     if (this.series.length === 0) {
       return table;

+ 6 - 6
public/app/plugins/datasource/influxdb/query_builder.ts

@@ -1,9 +1,9 @@
 import _ from 'lodash';
 
 function renderTagCondition(tag, index) {
-  var str = '';
-  var operator = tag.operator;
-  var value = tag.value;
+  let str = '';
+  let operator = tag.operator;
+  let value = tag.value;
   if (index > 0) {
     str = (tag.condition || 'AND') + ' ';
   }
@@ -28,9 +28,9 @@ export class InfluxQueryBuilder {
   constructor(private target, private database?) {}
 
   buildExploreQuery(type: string, withKey?: string, withMeasurementFilter?: string) {
-    var query;
-    var measurement;
-    var policy;
+    let query;
+    let measurement;
+    let policy;
 
     if (type === 'TAG_KEYS') {
       query = 'SHOW TAG KEYS';

+ 3 - 3
public/app/plugins/datasource/influxdb/query_ctrl.ts

@@ -279,7 +279,7 @@ export class InfluxQueryCtrl extends QueryCtrl {
       }
     }
 
-    var query, addTemplateVars;
+    let query, addTemplateVars;
     if (segment.type === 'key' || segment.type === 'plus-button') {
       query = this.queryBuilder.buildExploreQuery('TAG_KEYS');
       addTemplateVars = false;
@@ -343,8 +343,8 @@ export class InfluxQueryCtrl extends QueryCtrl {
 
   rebuildTargetTagConditions() {
     const tags = [];
-    var tagIndex = 0;
-    var tagOperator = '';
+    let tagIndex = 0;
+    let tagOperator = '';
 
     _.each(this.tagSegments, (segment2, index) => {
       if (segment2.type === 'key') {

+ 2 - 2
public/app/plugins/datasource/influxdb/query_part.ts

@@ -41,7 +41,7 @@ function fieldRenderer(part, innerExpr) {
 
 function replaceAggregationAddStrategy(selectParts, partModel) {
   // look for existing aggregation
-  for (var i = 0; i < selectParts.length; i++) {
+  for (let i = 0; i < selectParts.length; i++) {
     const part = selectParts[i];
     if (part.def.category === categories.Aggregations) {
       if (part.def.type === partModel.def.type) {
@@ -79,7 +79,7 @@ function replaceAggregationAddStrategy(selectParts, partModel) {
 }
 
 function addTransformationStrategy(selectParts, partModel) {
-  var i;
+  let i;
   // look for index to add transformation
   for (i = 0; i < selectParts.length; i++) {
     const part = selectParts[i];

+ 8 - 8
public/app/plugins/datasource/opentsdb/datasource.ts

@@ -114,7 +114,7 @@ export default class OpenTsDatasource {
     return this.performTimeSeriesQuery(queries, start, end).then(
       function(results) {
         if (results.data[0]) {
-          var annotationObject = results.data[0].annotations;
+          let annotationObject = results.data[0].annotations;
           if (options.annotation.isGlobal) {
             annotationObject = results.data[0].globalAnnotations;
           }
@@ -137,7 +137,7 @@ export default class OpenTsDatasource {
 
   targetContainsTemplate(target) {
     if (target.filters && target.filters.length > 0) {
-      for (var i = 0; i < target.filters.length; i++) {
+      for (let i = 0; i < target.filters.length; i++) {
         if (this.templateSrv.variableExists(target.filters[i].filter)) {
           return true;
         }
@@ -156,7 +156,7 @@ export default class OpenTsDatasource {
   }
 
   performTimeSeriesQuery(queries, start, end) {
-    var msResolution = false;
+    let msResolution = false;
     if (this.tsdbResolution === 2) {
       msResolution = true;
     }
@@ -213,7 +213,7 @@ export default class OpenTsDatasource {
       return key.trim();
     });
     const key = keysArray[0];
-    var keysQuery = key + '=*';
+    let keysQuery = key + '=*';
 
     if (keysArray.length > 1) {
       keysQuery += ',' + keysArray.splice(1).join(',');
@@ -278,7 +278,7 @@ export default class OpenTsDatasource {
       return this.$q.when([]);
     }
 
-    var interpolated;
+    let interpolated;
     try {
       interpolated = this.templateSrv.replace(query, {}, 'distributed');
     } catch (err) {
@@ -385,7 +385,7 @@ export default class OpenTsDatasource {
       return this.templateSrv.replace(target.alias, scopedVars);
     }
 
-    var label = md.metric;
+    let label = md.metric;
     const tagData = [];
 
     if (!_.isEmpty(md.tags)) {
@@ -438,7 +438,7 @@ export default class OpenTsDatasource {
     }
 
     if (!target.disableDownsampling) {
-      var interval = this.templateSrv.replace(target.downsampleInterval || options.interval);
+      let interval = this.templateSrv.replace(target.downsampleInterval || options.interval);
 
       if (interval.match(/\.[0-9]+s/)) {
         interval = parseFloat(interval) * 1000 + 'ms';
@@ -479,7 +479,7 @@ export default class OpenTsDatasource {
   }
 
   mapMetricsToTargets(metrics, options, tsdbVersion) {
-    var interpolatedTagValue, arrTagV;
+    let interpolatedTagValue, arrTagV;
     return _.map(metrics, metricData => {
       if (tsdbVersion === 3) {
         return metricData.query.index;

+ 4 - 4
public/app/plugins/datasource/prometheus/completer.ts

@@ -294,9 +294,9 @@ export class PromCompleter {
   }
 
   findMetricName(session, row, column) {
-    var metricName = '';
+    let metricName = '';
 
-    var tokens;
+    let tokens;
     const nameLabelNameToken = this.findToken(
       session,
       row,
@@ -323,9 +323,9 @@ export class PromCompleter {
   }
 
   findToken(session, row, column, target, value, guard) {
-    var tokens, idx;
+    let tokens, idx;
     // find index and get column of previous token
-    for (var r = row; r >= 0; r--) {
+    for (let r = row; r >= 0; r--) {
       let c;
       tokens = session.getTokens(r);
       if (r === row) {

+ 3 - 3
public/app/plugins/datasource/prometheus/datasource.ts

@@ -384,7 +384,7 @@ export class PrometheusDatasource {
     };
     const range = Math.ceil(end - start);
 
-    var interval = kbn.interval_to_seconds(options.interval);
+    let interval = kbn.interval_to_seconds(options.interval);
     // Minimum interval ("Min step"), if specified for the query. or same as interval otherwise
     const minInterval = kbn.interval_to_seconds(
       this.templateSrv.replace(target.interval, options.scopedVars) || options.interval
@@ -392,7 +392,7 @@ export class PrometheusDatasource {
     const intervalFactor = target.intervalFactor || 1;
     // Adjust the interval to take into account any specified minimum and interval factor plus Prometheus limits
     const adjustedInterval = this.adjustInterval(interval, minInterval, range, intervalFactor);
-    var scopedVars = { ...options.scopedVars, ...this.getRangeScopedVars() };
+    let scopedVars = { ...options.scopedVars, ...this.getRangeScopedVars() };
     // If the interval was adjusted, make a shallow copy of scopedVars with updated interval vars
     if (interval !== adjustedInterval) {
       interval = adjustedInterval;
@@ -507,7 +507,7 @@ export class PrometheusDatasource {
   annotationQuery(options) {
     const annotation = options.annotation;
     const expr = annotation.expr || '';
-    var tagKeys = annotation.tagKeys || '';
+    let tagKeys = annotation.tagKeys || '';
     const titleFormat = annotation.titleFormat || '';
     const textFormat = annotation.textFormat || '';
 

+ 2 - 2
public/app/plugins/datasource/prometheus/metric_find_query.ts

@@ -40,7 +40,7 @@ export default class PrometheusMetricFindQuery {
   }
 
   labelValuesQuery(label, metric) {
-    var url;
+    let url;
 
     if (!metric) {
       // return label values globally
@@ -96,7 +96,7 @@ export default class PrometheusMetricFindQuery {
     const end = this.datasource.getPrometheusTime(this.range.to, true);
     return this.datasource.performInstantQuery({ expr: query }, end).then(function(result) {
       return _.map(result.data.data.result, function(metricData) {
-        var text = metricData.metric.__name__ || '';
+        let text = metricData.metric.__name__ || '';
         delete metricData.metric.__name__;
         text +=
           '{' +

+ 1 - 1
public/app/plugins/datasource/prometheus/result_transformer.ts

@@ -73,7 +73,7 @@ export class ResultTransformer {
 
   transformMetricDataToTable(md, resultCount: number, refId: string) {
     const table = new TableModel();
-    var i, j;
+    let i, j;
     const metricLabels = {};
 
     if (md.length === 0) {

+ 12 - 12
public/app/plugins/panel/graph/threshold_manager.ts

@@ -13,7 +13,7 @@ export class ThresholdManager {
   constructor(private panelCtrl) {}
 
   getHandleHtml(handleIndex, model, valueStr) {
-    var stateClass = model.colorMode;
+    let stateClass = model.colorMode;
     if (model.colorMode === 'custom') {
       stateClass = 'critical';
     }
@@ -33,8 +33,8 @@ export class ThresholdManager {
     const handleElem = $(evt.currentTarget).parents('.alert-handle-wrapper');
     const handleIndex = $(evt.currentTarget).data('handleIndex');
 
-    var lastY = null;
-    var posTop;
+    let lastY = null;
+    let posTop;
     const plot = this.plot;
     const panelCtrl = this.panelCtrl;
     const model = this.thresholds[handleIndex];
@@ -52,7 +52,7 @@ export class ThresholdManager {
 
     function stopped() {
       // calculate graph level
-      var graphValue = plot.c2p({ left: 0, top: posTop }).y;
+      let graphValue = plot.c2p({ left: 0, top: posTop }).y;
       graphValue = parseInt(graphValue.toFixed(0));
       model.value = graphValue;
 
@@ -86,8 +86,8 @@ export class ThresholdManager {
   renderHandle(handleIndex, defaultHandleTopPos) {
     const model = this.thresholds[handleIndex];
     const value = model.value;
-    var valueStr = value;
-    var handleTopPos = 0;
+    let valueStr = value;
+    let handleTopPos = 0;
 
     // handle no value
     if (!_.isNumber(value)) {
@@ -111,7 +111,7 @@ export class ThresholdManager {
 
   prepare(elem, data) {
     this.hasSecondYAxis = false;
-    for (var i = 0; i < data.length; i++) {
+    for (let i = 0; i < data.length; i++) {
       if (data[i].yaxis > 1) {
         this.hasSecondYAxis = true;
         break;
@@ -158,9 +158,9 @@ export class ThresholdManager {
       return;
     }
 
-    var gtLimit = Infinity;
-    var ltLimit = -Infinity;
-    var i, threshold, other;
+    let gtLimit = Infinity;
+    let ltLimit = -Infinity;
+    let i, threshold, other;
 
     for (i = 0; i < panel.thresholds.length; i++) {
       threshold = panel.thresholds[i];
@@ -168,7 +168,7 @@ export class ThresholdManager {
         continue;
       }
 
-      var limit;
+      let limit;
       switch (threshold.op) {
         case 'gt': {
           limit = gtLimit;
@@ -196,7 +196,7 @@ export class ThresholdManager {
         }
       }
 
-      var fillColor, lineColor;
+      let fillColor, lineColor;
       switch (threshold.colorMode) {
         case 'critical': {
           fillColor = 'rgba(234, 112, 112, 0.12)';