diff --git a/package.json b/package.json index d6a7719601d..7af8ab502b7 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "grunt-ng-annotate": "^1.0.1", "grunt-string-replace": "~1.2.1", "grunt-systemjs-builder": "^0.2.5", - "grunt-tslint": "^2.5.0", + "grunt-tslint": "^3.0.1", "grunt-typescript": "^0.8.0", "grunt-usemin": "3.0.0", "jshint-stylish": "~0.1.5", diff --git a/public/app/core/controllers/grafana_ctrl.ts b/public/app/core/controllers/grafana_ctrl.ts index 9802a2e3b15..2363ffb94b1 100644 --- a/public/app/core/controllers/grafana_ctrl.ts +++ b/public/app/core/controllers/grafana_ctrl.ts @@ -47,13 +47,13 @@ coreModule.controller('GrafanaCtrl', function($scope, alertSrv, utilSrv, $rootSc }; $rootScope.colors = [ - "#7EB26D","#EAB839","#6ED0E0","#EF843C","#E24D42","#1F78C1","#BA43A9","#705DA0", //1 - "#508642","#CCA300","#447EBC","#C15C17","#890F02","#0A437C","#6D1F62","#584477", //2 - "#B7DBAB","#F4D598","#70DBED","#F9BA8F","#F29191","#82B5D8","#E5A8E2","#AEA2E0", //3 - "#629E51","#E5AC0E","#64B0C8","#E0752D","#BF1B00","#0A50A1","#962D82","#614D93", //4 - "#9AC48A","#F2C96D","#65C5DB","#F9934E","#EA6460","#5195CE","#D683CE","#806EB7", //5 - "#3F6833","#967302","#2F575E","#99440A","#58140C","#052B51","#511749","#3F2B5B", //6 - "#E0F9D7","#FCEACA","#CFFAFF","#F9E2D2","#FCE2DE","#BADFF4","#F9D9F9","#DEDAF7" //7 + "#7EB26D","#EAB839","#6ED0E0","#EF843C","#E24D42","#1F78C1","#BA43A9","#705DA0", + "#508642","#CCA300","#447EBC","#C15C17","#890F02","#0A437C","#6D1F62","#584477", + "#B7DBAB","#F4D598","#70DBED","#F9BA8F","#F29191","#82B5D8","#E5A8E2","#AEA2E0", + "#629E51","#E5AC0E","#64B0C8","#E0752D","#BF1B00","#0A50A1","#962D82","#614D93", + "#9AC48A","#F2C96D","#65C5DB","#F9934E","#EA6460","#5195CE","#D683CE","#806EB7", + "#3F6833","#967302","#2F575E","#99440A","#58140C","#052B51","#511749","#3F2B5B", + "#E0F9D7","#FCEACA","#CFFAFF","#F9E2D2","#FCE2DE","#BADFF4","#F9D9F9","#DEDAF7" ]; $scope.getTotalWatcherCount = function() { @@ -85,6 +85,7 @@ coreModule.controller('GrafanaCtrl', function($scope, alertSrv, utilSrv, $rootSc $scope.$watch(function digestCounter() { count++; }, function() { + // something }); $rootScope.performance.panels = []; diff --git a/public/app/core/controllers/signup_ctrl.ts b/public/app/core/controllers/signup_ctrl.ts index 7b11e0b72c4..36544586a31 100644 --- a/public/app/core/controllers/signup_ctrl.ts +++ b/public/app/core/controllers/signup_ctrl.ts @@ -1,6 +1,5 @@ /// -import angular from 'angular'; import config from 'app/core/config'; import coreModule from '../core_module'; @@ -8,10 +7,10 @@ export class SignUpCtrl { /** @ngInject */ constructor( - private $scope : any, - private $location : any, - private contextSrv : any, - private backendSrv : any) { + private $scope: any, + private $location: any, + private contextSrv: any, + private backendSrv: any) { contextSrv.sidemenu = false; $scope.ctrl = this; diff --git a/public/app/core/core.ts b/public/app/core/core.ts index d50f330ad53..2580fc18e96 100644 --- a/public/app/core/core.ts +++ b/public/app/core/core.ts @@ -21,11 +21,9 @@ import './jquery_extended'; import './partials'; import {arrayJoin} from './directives/array_join'; -import * as controllers from 'app/core/controllers/all'; -import * as services from 'app/core/services/all'; -import * as routes from 'app/core/routes/all'; +import 'app/core/controllers/all'; +import 'app/core/services/all'; +import 'app/core/routes/all'; import './filters/filters'; -// export * from './directives/give_focus' - -export {arrayJoin, controllers, services, routes}; +export {arrayJoin}; diff --git a/public/app/core/directives/array_join.ts b/public/app/core/directives/array_join.ts index 538780e0695..6eb1cc0dd65 100644 --- a/public/app/core/directives/array_join.ts +++ b/public/app/core/directives/array_join.ts @@ -1,7 +1,6 @@ /// import _ from 'lodash'; -import angular from 'angular'; import coreModule from '../core_module'; export function arrayJoin() { diff --git a/public/app/core/directives/give_focus.ts b/public/app/core/directives/give_focus.ts index 16d0df3fc33..2d43b1c7d39 100644 --- a/public/app/core/directives/give_focus.ts +++ b/public/app/core/directives/give_focus.ts @@ -1,6 +1,5 @@ /// -import angular = require('angular'); import coreModule from '../core_module'; coreModule.default.directive('giveFocus', function() { diff --git a/public/app/core/filters/filters.ts b/public/app/core/filters/filters.ts index 7ac7ba6b01a..57b2b1bd9ba 100644 --- a/public/app/core/filters/filters.ts +++ b/public/app/core/filters/filters.ts @@ -1,6 +1,5 @@ /// -import jquery from 'jquery'; import _ from 'lodash'; import angular from 'angular'; import moment from 'moment'; @@ -59,7 +58,7 @@ coreModule.filter('noXml', function() { }); coreModule.filter('interpolateTemplateVars', function (templateSrv) { - var filterFunc : any = function (text, scope) { + var filterFunc: any = function(text, scope) { if (scope.panel) { return templateSrv.replaceWithText(text, scope.panel.scopedVars); } else { diff --git a/public/app/core/services/dynamic_directive_srv.ts b/public/app/core/services/dynamic_directive_srv.ts index a38f8e79716..cb7bad5b75a 100644 --- a/public/app/core/services/dynamic_directive_srv.ts +++ b/public/app/core/services/dynamic_directive_srv.ts @@ -1,14 +1,12 @@ /// -import _ from 'lodash'; import angular from 'angular'; import coreModule from '../core_module'; class DynamicDirectiveSrv { /** @ngInject */ - constructor(private $compile, private $parse, private datasourceSrv) { - } + constructor(private $compile, private $parse) {} addDirective(element, name, scope) { element.empty(); @@ -16,19 +14,25 @@ class DynamicDirectiveSrv { this.$compile(element)(scope); } - define(options) { - var editorScope; - options.scope.$watch(options.datasourceProperty, newVal => { - if (editorScope) { - editorScope.$destroy(); - options.parentElem.empty(); - } + create(options) { + let directiveDef = { + restrict: 'E', + scope: options.scope, + link: function(scope, elem) { + options.directive(scope).then(directiveInfo => { + if (!directiveInfo) { + return; + } - editorScope = options.scope.$new(); - this.datasourceSrv.get(newVal).then(ds => { - this.addDirective(options.parentElem, options.name + '-' + ds.meta.id, editorScope); - }); - }); + if (directiveInfo.fn.hasBeenRegistered) { + coreModule.directive(directiveInfo.name, directiveInfo.fn); + directiveInfo.fn.hasBeenRegistered = true; + } + }); + } + }; + + return directiveDef; } } diff --git a/public/app/core/time_series2.ts b/public/app/core/time_series2.ts index 1bc6dc93854..c8384b5b40a 100644 --- a/public/app/core/time_series2.ts +++ b/public/app/core/time_series2.ts @@ -132,7 +132,7 @@ export default class TimeSeries { } } - if (currentValue != 0) { + if (currentValue !== 0) { this.allIsZero = false; } diff --git a/public/app/core/utils/datemath.ts b/public/app/core/utils/datemath.ts index 55da5b42b30..b66325c71a8 100644 --- a/public/app/core/utils/datemath.ts +++ b/public/app/core/utils/datemath.ts @@ -4,11 +4,6 @@ import _ from 'lodash'; import moment from 'moment'; var units = ['y', 'M', 'w', 'd', 'h', 'm', 's']; -var unitsAsc = _.sortBy(units, function (unit) { - return moment.duration(1, unit).valueOf(); -}); - -var unitsDesc = unitsAsc.reverse(); export function parse(text, roundUp?) { if (!text) { return undefined; } @@ -104,8 +99,7 @@ export function parseDateMath(mathString, time, roundUp?) { if (type === 0) { if (roundUp) { dateTime.endOf(unit); - } - else { + } else { dateTime.startOf(unit); } } else if (type === 1) { diff --git a/public/app/core/utils/rangeutil.ts b/public/app/core/utils/rangeutil.ts index 5647056e2a1..7f2f2fd72b1 100644 --- a/public/app/core/utils/rangeutil.ts +++ b/public/app/core/utils/rangeutil.ts @@ -1,7 +1,6 @@ /// import _ from 'lodash'; -import angular from 'angular'; import moment from 'moment'; import * as dateMath from './datemath'; diff --git a/public/app/features/apps/config_loader.ts b/public/app/features/apps/config_loader.ts index d2128778707..f37d0145046 100644 --- a/public/app/features/apps/config_loader.ts +++ b/public/app/features/apps/config_loader.ts @@ -1,35 +1,22 @@ /// -import _ from 'lodash'; import angular from 'angular'; -function appConfigLoader($compile, $parse) { - return { - restrict: 'E', +/** @ngInject */ +function appConfigLoader(dynamicDirectiveSrv) { + return dynamicDirectiveSrv.create({ scope: { appModel: "=" }, - link: function(scope, elem, attr) { - debugger; - System.import(scope.appModel.module).then(function(appModule) { - var directive = appModule.directives.configView; - if (!directive) { - return; - } - if (!directive.hasBeenRegistered) { - angular.module('grafana.directives').directive('nginxConfig', directive); - directive.hasBeenRegistered = true; - } - - var panelEl = angular.element(document.createElement('nginx-config')); - elem.append(panelEl); - $compile(panelEl)(scope); - }).catch(function(err) { - console.log('Failed to load panel:', err); - scope.appEvent('alert-error', ['App Error', err.toString()]); + directive: scope => { + return System.import(scope.appModel.module).then(function(appModule) { + return { + name: 'appConfigLoader' + scope.appModel.appId, + fn: scope.appModel.directives.configView, + }; }); - } - }; + }, + }); } diff --git a/public/app/features/apps/edit_ctrl.ts b/public/app/features/apps/edit_ctrl.ts index fe77c0a6797..2cbeb4a2ae1 100644 --- a/public/app/features/apps/edit_ctrl.ts +++ b/public/app/features/apps/edit_ctrl.ts @@ -1,6 +1,5 @@ /// -import config from 'app/core/config'; import angular from 'angular'; import _ from 'lodash'; diff --git a/public/app/features/apps/list_ctrl.ts b/public/app/features/apps/list_ctrl.ts index 3f195536ae4..142f0e12b0a 100644 --- a/public/app/features/apps/list_ctrl.ts +++ b/public/app/features/apps/list_ctrl.ts @@ -1,6 +1,5 @@ /// -import config = require('app/core/config'); import angular from 'angular'; export class AppListCtrl { diff --git a/public/app/features/apps/partials/edit.html b/public/app/features/apps/partials/edit.html index 50ebf9ab5af..79373c56fe6 100644 --- a/public/app/features/apps/partials/edit.html +++ b/public/app/features/apps/partials/edit.html @@ -29,7 +29,6 @@ Version: {{ctrl.appModel.info.version}}     Updated: {{ctrl.appModel.info.updated}} -

diff --git a/public/app/features/dashboard/timepicker/input_date.ts b/public/app/features/dashboard/timepicker/input_date.ts index 66173ffd1b9..cf215b9e25e 100644 --- a/public/app/features/dashboard/timepicker/input_date.ts +++ b/public/app/features/dashboard/timepicker/input_date.ts @@ -1,7 +1,5 @@ /// -import _ from 'lodash'; -import angular from 'angular'; import moment from 'moment'; export function inputDateDirective() { diff --git a/public/app/features/dashboard/timepicker/timepicker.ts b/public/app/features/dashboard/timepicker/timepicker.ts index b44f6ed8a9a..8fb0427bba3 100644 --- a/public/app/features/dashboard/timepicker/timepicker.ts +++ b/public/app/features/dashboard/timepicker/timepicker.ts @@ -1,19 +1,17 @@ /// import _ from 'lodash'; -import kbn from 'app/core/utils/kbn'; import angular from 'angular'; -import moment from 'moment'; +import moment from 'moment' -import * as dateMath from 'app/core/utils/datemath'; import * as rangeUtil from 'app/core/utils/rangeutil'; export class TimePickerCtrl { static tooltipFormat = 'MMM D, YYYY HH:mm:ss'; static defaults = { - time_options : ['5m','15m','1h','6h','12h','24h','2d','7d','30d'], - refresh_intervals : ['5s','10s','30s','1m','5m','15m','30m','1h','2h','1d'], + time_options: ['5m', '15m', '1h', '6h', '12h', '24h', '2d', '7d', '30d'], + refresh_intervals: ['5s', '10s', '30s', '1m', '5m', '15m', '30m', '1h', '2h', '1d'], }; dashboard: any; diff --git a/public/app/features/playlist/specs/playlist-edit-ctrl-specs.ts b/public/app/features/playlist/specs/playlist-edit-ctrl-specs.ts index e0ffdd49893..4a71979b8ab 100644 --- a/public/app/features/playlist/specs/playlist-edit-ctrl-specs.ts +++ b/public/app/features/playlist/specs/playlist-edit-ctrl-specs.ts @@ -1,5 +1,5 @@ import '../playlist_edit_ctrl'; -import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common'; +import {describe, beforeEach, it, expect, angularMocks} from 'test/lib/common'; import helpers from 'test/specs/helpers'; describe('PlaylistEditCtrl', function() { @@ -83,4 +83,4 @@ describe('PlaylistEditCtrl', function() { }); }); }); -}); \ No newline at end of file +}); diff --git a/tasks/options/tslint.js b/tasks/options/tslint.js index 0b76e623e95..c9658b32f8f 100644 --- a/tasks/options/tslint.js +++ b/tasks/options/tslint.js @@ -6,18 +6,19 @@ module.exports = function(config) { } }, options: { - configuration: { - rules: { - curly: true, - align: [true, "parameters", "statements"], - indent: [true, "spaces"], - "class-name": true, - "interface-name": true, - "semicolon": true, - "use-strict": [false, "check-module", "check-function"], - "whitespace": [true, "check-branch", "check-decl", "check-type"], - } - } + configuration: 'tslint.json' + // { + // rules: { + // curly: true, + // align: [true, "parameters", "statements"], + // indent: [true, "spaces"], + // "class-name": true, + // "interface-name": true, + // "semicolon": true, + // "use-strict": [false, "check-module", "check-function"], + // "whitespace": [true, "check-branch", "check-decl", "check-type"], + // } + // } } }; }; diff --git a/tslint.json b/tslint.json new file mode 100644 index 00000000000..8a8379e009f --- /dev/null +++ b/tslint.json @@ -0,0 +1,67 @@ +{ + "rules": { + "class-name": true, + "comment-format": [true, "check-space"], + "curly": true, + "eofline": true, + "forin": true, + "indent": [true, "spaces"], + "label-position": true, + "label-undefined": true, + "max-line-length": [true, 140], + "member-access": false, + "member-ordering": [true, + "public-before-private", + "static-before-instance", + "variables-before-functions" + ], + "no-arg": true, + "no-bitwise": true, + "no-console": [true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-debugger": true, + "no-duplicate-key": true, + "no-duplicate-variable": true, + "no-empty": true, + "no-eval": true, + "no-inferrable-types": true, + "no-shadowed-variable": true, + "no-string-literal": true, + "no-switch-case-fall-through": true, + "no-trailing-comma": true, + "no-trailing-whitespace": true, + "no-unused-expression": true, + "no-unused-variable": true, + "no-unreachable": true, + "no-use-before-declare": true, + "no-var-keyword": false, + "object-literal-sort-keys": false, + "one-line": [true, + "check-open-brace", + "check-catch", + "check-else" + ], + "radix": false, + "semicolon": true, + "triple-equals": [true, "allow-null-check"], + "typedef-whitespace": [true, { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }], + "variable-name": false, + "whitespace": [true, + "check-branch", + "check-decl", + "check-type" + ] + } +}