Commit 59c928ac by Torkel Ödegaard

feat(tslint): added more tslint rules

parent 534bc831
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
"grunt-ng-annotate": "^1.0.1", "grunt-ng-annotate": "^1.0.1",
"grunt-string-replace": "~1.2.1", "grunt-string-replace": "~1.2.1",
"grunt-systemjs-builder": "^0.2.5", "grunt-systemjs-builder": "^0.2.5",
"grunt-tslint": "^2.5.0", "grunt-tslint": "^3.0.1",
"grunt-typescript": "^0.8.0", "grunt-typescript": "^0.8.0",
"grunt-usemin": "3.0.0", "grunt-usemin": "3.0.0",
"jshint-stylish": "~0.1.5", "jshint-stylish": "~0.1.5",
......
...@@ -47,13 +47,13 @@ coreModule.controller('GrafanaCtrl', function($scope, alertSrv, utilSrv, $rootSc ...@@ -47,13 +47,13 @@ coreModule.controller('GrafanaCtrl', function($scope, alertSrv, utilSrv, $rootSc
}; };
$rootScope.colors = [ $rootScope.colors = [
"#7EB26D","#EAB839","#6ED0E0","#EF843C","#E24D42","#1F78C1","#BA43A9","#705DA0", //1 "#7EB26D","#EAB839","#6ED0E0","#EF843C","#E24D42","#1F78C1","#BA43A9","#705DA0",
"#508642","#CCA300","#447EBC","#C15C17","#890F02","#0A437C","#6D1F62","#584477", //2 "#508642","#CCA300","#447EBC","#C15C17","#890F02","#0A437C","#6D1F62","#584477",
"#B7DBAB","#F4D598","#70DBED","#F9BA8F","#F29191","#82B5D8","#E5A8E2","#AEA2E0", //3 "#B7DBAB","#F4D598","#70DBED","#F9BA8F","#F29191","#82B5D8","#E5A8E2","#AEA2E0",
"#629E51","#E5AC0E","#64B0C8","#E0752D","#BF1B00","#0A50A1","#962D82","#614D93", //4 "#629E51","#E5AC0E","#64B0C8","#E0752D","#BF1B00","#0A50A1","#962D82","#614D93",
"#9AC48A","#F2C96D","#65C5DB","#F9934E","#EA6460","#5195CE","#D683CE","#806EB7", //5 "#9AC48A","#F2C96D","#65C5DB","#F9934E","#EA6460","#5195CE","#D683CE","#806EB7",
"#3F6833","#967302","#2F575E","#99440A","#58140C","#052B51","#511749","#3F2B5B", //6 "#3F6833","#967302","#2F575E","#99440A","#58140C","#052B51","#511749","#3F2B5B",
"#E0F9D7","#FCEACA","#CFFAFF","#F9E2D2","#FCE2DE","#BADFF4","#F9D9F9","#DEDAF7" //7 "#E0F9D7","#FCEACA","#CFFAFF","#F9E2D2","#FCE2DE","#BADFF4","#F9D9F9","#DEDAF7"
]; ];
$scope.getTotalWatcherCount = function() { $scope.getTotalWatcherCount = function() {
...@@ -85,6 +85,7 @@ coreModule.controller('GrafanaCtrl', function($scope, alertSrv, utilSrv, $rootSc ...@@ -85,6 +85,7 @@ coreModule.controller('GrafanaCtrl', function($scope, alertSrv, utilSrv, $rootSc
$scope.$watch(function digestCounter() { $scope.$watch(function digestCounter() {
count++; count++;
}, function() { }, function() {
// something
}); });
$rootScope.performance.panels = []; $rootScope.performance.panels = [];
......
///<reference path="../../headers/common.d.ts" /> ///<reference path="../../headers/common.d.ts" />
import angular from 'angular';
import config from 'app/core/config'; import config from 'app/core/config';
import coreModule from '../core_module'; import coreModule from '../core_module';
...@@ -8,10 +7,10 @@ export class SignUpCtrl { ...@@ -8,10 +7,10 @@ export class SignUpCtrl {
/** @ngInject */ /** @ngInject */
constructor( constructor(
private $scope : any, private $scope: any,
private $location : any, private $location: any,
private contextSrv : any, private contextSrv: any,
private backendSrv : any) { private backendSrv: any) {
contextSrv.sidemenu = false; contextSrv.sidemenu = false;
$scope.ctrl = this; $scope.ctrl = this;
......
...@@ -21,11 +21,9 @@ import './jquery_extended'; ...@@ -21,11 +21,9 @@ import './jquery_extended';
import './partials'; import './partials';
import {arrayJoin} from './directives/array_join'; import {arrayJoin} from './directives/array_join';
import * as controllers from 'app/core/controllers/all'; import 'app/core/controllers/all';
import * as services from 'app/core/services/all'; import 'app/core/services/all';
import * as routes from 'app/core/routes/all'; import 'app/core/routes/all';
import './filters/filters'; import './filters/filters';
// export * from './directives/give_focus' export {arrayJoin};
export {arrayJoin, controllers, services, routes};
///<reference path="../../headers/common.d.ts" /> ///<reference path="../../headers/common.d.ts" />
import _ from 'lodash'; import _ from 'lodash';
import angular from 'angular';
import coreModule from '../core_module'; import coreModule from '../core_module';
export function arrayJoin() { export function arrayJoin() {
......
///<reference path="../../headers/common.d.ts" /> ///<reference path="../../headers/common.d.ts" />
import angular = require('angular');
import coreModule from '../core_module'; import coreModule from '../core_module';
coreModule.default.directive('giveFocus', function() { coreModule.default.directive('giveFocus', function() {
......
///<reference path="../../headers/common.d.ts" /> ///<reference path="../../headers/common.d.ts" />
import jquery from 'jquery';
import _ from 'lodash'; import _ from 'lodash';
import angular from 'angular'; import angular from 'angular';
import moment from 'moment'; import moment from 'moment';
...@@ -59,7 +58,7 @@ coreModule.filter('noXml', function() { ...@@ -59,7 +58,7 @@ coreModule.filter('noXml', function() {
}); });
coreModule.filter('interpolateTemplateVars', function (templateSrv) { coreModule.filter('interpolateTemplateVars', function (templateSrv) {
var filterFunc : any = function (text, scope) { var filterFunc: any = function(text, scope) {
if (scope.panel) { if (scope.panel) {
return templateSrv.replaceWithText(text, scope.panel.scopedVars); return templateSrv.replaceWithText(text, scope.panel.scopedVars);
} else { } else {
......
///<reference path="../../headers/common.d.ts" /> ///<reference path="../../headers/common.d.ts" />
import _ from 'lodash';
import angular from 'angular'; import angular from 'angular';
import coreModule from '../core_module'; import coreModule from '../core_module';
class DynamicDirectiveSrv { class DynamicDirectiveSrv {
/** @ngInject */ /** @ngInject */
constructor(private $compile, private $parse, private datasourceSrv) { constructor(private $compile, private $parse) {}
}
addDirective(element, name, scope) { addDirective(element, name, scope) {
element.empty(); element.empty();
...@@ -16,19 +14,25 @@ class DynamicDirectiveSrv { ...@@ -16,19 +14,25 @@ class DynamicDirectiveSrv {
this.$compile(element)(scope); this.$compile(element)(scope);
} }
define(options) { create(options) {
var editorScope; let directiveDef = {
options.scope.$watch(options.datasourceProperty, newVal => { restrict: 'E',
if (editorScope) { scope: options.scope,
editorScope.$destroy(); link: function(scope, elem) {
options.parentElem.empty(); options.directive(scope).then(directiveInfo => {
if (!directiveInfo) {
return;
}
if (directiveInfo.fn.hasBeenRegistered) {
coreModule.directive(directiveInfo.name, directiveInfo.fn);
directiveInfo.fn.hasBeenRegistered = true;
}
});
} }
};
editorScope = options.scope.$new(); return directiveDef;
this.datasourceSrv.get(newVal).then(ds => {
this.addDirective(options.parentElem, options.name + '-' + ds.meta.id, editorScope);
});
});
} }
} }
......
...@@ -132,7 +132,7 @@ export default class TimeSeries { ...@@ -132,7 +132,7 @@ export default class TimeSeries {
} }
} }
if (currentValue != 0) { if (currentValue !== 0) {
this.allIsZero = false; this.allIsZero = false;
} }
......
...@@ -4,11 +4,6 @@ import _ from 'lodash'; ...@@ -4,11 +4,6 @@ import _ from 'lodash';
import moment from 'moment'; import moment from 'moment';
var units = ['y', 'M', 'w', 'd', 'h', 'm', 's']; 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?) { export function parse(text, roundUp?) {
if (!text) { return undefined; } if (!text) { return undefined; }
...@@ -104,8 +99,7 @@ export function parseDateMath(mathString, time, roundUp?) { ...@@ -104,8 +99,7 @@ export function parseDateMath(mathString, time, roundUp?) {
if (type === 0) { if (type === 0) {
if (roundUp) { if (roundUp) {
dateTime.endOf(unit); dateTime.endOf(unit);
} } else {
else {
dateTime.startOf(unit); dateTime.startOf(unit);
} }
} else if (type === 1) { } else if (type === 1) {
......
///<reference path="../../headers/common.d.ts" /> ///<reference path="../../headers/common.d.ts" />
import _ from 'lodash'; import _ from 'lodash';
import angular from 'angular';
import moment from 'moment'; import moment from 'moment';
import * as dateMath from './datemath'; import * as dateMath from './datemath';
......
///<reference path="../../headers/common.d.ts" /> ///<reference path="../../headers/common.d.ts" />
import _ from 'lodash';
import angular from 'angular'; import angular from 'angular';
function appConfigLoader($compile, $parse) { /** @ngInject */
return { function appConfigLoader(dynamicDirectiveSrv) {
restrict: 'E', return dynamicDirectiveSrv.create({
scope: { scope: {
appModel: "=" appModel: "="
}, },
link: function(scope, elem, attr) { directive: scope => {
debugger; return System.import(scope.appModel.module).then(function(appModule) {
System.import(scope.appModel.module).then(function(appModule) { return {
var directive = appModule.directives.configView; name: 'appConfigLoader' + scope.appModel.appId,
if (!directive) { fn: scope.appModel.directives.configView,
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()]);
}); });
} },
}; });
} }
......
///<reference path="../../headers/common.d.ts" /> ///<reference path="../../headers/common.d.ts" />
import config from 'app/core/config';
import angular from 'angular'; import angular from 'angular';
import _ from 'lodash'; import _ from 'lodash';
......
///<reference path="../../headers/common.d.ts" /> ///<reference path="../../headers/common.d.ts" />
import config = require('app/core/config');
import angular from 'angular'; import angular from 'angular';
export class AppListCtrl { export class AppListCtrl {
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
<span style="small"> <span style="small">
Version: {{ctrl.appModel.info.version}} &nbsp; &nbsp; Updated: {{ctrl.appModel.info.updated}} Version: {{ctrl.appModel.info.version}} &nbsp; &nbsp; Updated: {{ctrl.appModel.info.updated}}
</span> </span>
</em> </em>
<br><br> <br><br>
......
///<reference path="../../../headers/common.d.ts" /> ///<reference path="../../../headers/common.d.ts" />
import _ from 'lodash';
import angular from 'angular';
import moment from 'moment'; import moment from 'moment';
export function inputDateDirective() { export function inputDateDirective() {
......
///<reference path="../../../headers/common.d.ts" /> ///<reference path="../../../headers/common.d.ts" />
import _ from 'lodash'; import _ from 'lodash';
import kbn from 'app/core/utils/kbn';
import angular from 'angular'; 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'; import * as rangeUtil from 'app/core/utils/rangeutil';
export class TimePickerCtrl { export class TimePickerCtrl {
static tooltipFormat = 'MMM D, YYYY HH:mm:ss'; static tooltipFormat = 'MMM D, YYYY HH:mm:ss';
static defaults = { static defaults = {
time_options : ['5m','15m','1h','6h','12h','24h','2d','7d','30d'], time_options: ['5m', '15m', '1h', '6h', '12h', '24h', '2d', '7d', '30d'],
refresh_intervals : ['5s','10s','30s','1m','5m','15m','30m','1h','2h','1d'], refresh_intervals: ['5s', '10s', '30s', '1m', '5m', '15m', '30m', '1h', '2h', '1d'],
}; };
dashboard: any; dashboard: any;
......
import '../playlist_edit_ctrl'; 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'; import helpers from 'test/specs/helpers';
describe('PlaylistEditCtrl', function() { describe('PlaylistEditCtrl', function() {
...@@ -83,4 +83,4 @@ describe('PlaylistEditCtrl', function() { ...@@ -83,4 +83,4 @@ describe('PlaylistEditCtrl', function() {
}); });
}); });
}); });
}); });
\ No newline at end of file
...@@ -6,18 +6,19 @@ module.exports = function(config) { ...@@ -6,18 +6,19 @@ module.exports = function(config) {
} }
}, },
options: { options: {
configuration: { configuration: 'tslint.json'
rules: { // {
curly: true, // rules: {
align: [true, "parameters", "statements"], // curly: true,
indent: [true, "spaces"], // align: [true, "parameters", "statements"],
"class-name": true, // indent: [true, "spaces"],
"interface-name": true, // "class-name": true,
"semicolon": true, // "interface-name": true,
"use-strict": [false, "check-module", "check-function"], // "semicolon": true,
"whitespace": [true, "check-branch", "check-decl", "check-type"], // "use-strict": [false, "check-module", "check-function"],
} // "whitespace": [true, "check-branch", "check-decl", "check-type"],
} // }
// }
} }
}; };
}; };
{
"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"
]
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment