mirror of
https://github.com/grafana/grafana.git
synced 2025-02-09 23:16:16 -06:00
feat(tslint): added more tslint rules
This commit is contained in:
parent
534bc83173
commit
59c928acc2
@ -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",
|
||||
|
@ -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 = [];
|
||||
|
@ -1,6 +1,5 @@
|
||||
///<reference path="../../headers/common.d.ts" />
|
||||
|
||||
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;
|
||||
|
@ -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};
|
||||
|
@ -1,7 +1,6 @@
|
||||
///<reference path="../../headers/common.d.ts" />
|
||||
|
||||
import _ from 'lodash';
|
||||
import angular from 'angular';
|
||||
import coreModule from '../core_module';
|
||||
|
||||
export function arrayJoin() {
|
||||
|
@ -1,6 +1,5 @@
|
||||
///<reference path="../../headers/common.d.ts" />
|
||||
|
||||
import angular = require('angular');
|
||||
import coreModule from '../core_module';
|
||||
|
||||
coreModule.default.directive('giveFocus', function() {
|
||||
|
@ -1,6 +1,5 @@
|
||||
///<reference path="../../headers/common.d.ts" />
|
||||
|
||||
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 {
|
||||
|
@ -1,14 +1,12 @@
|
||||
///<reference path="../../headers/common.d.ts" />
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ export default class TimeSeries {
|
||||
}
|
||||
}
|
||||
|
||||
if (currentValue != 0) {
|
||||
if (currentValue !== 0) {
|
||||
this.allIsZero = false;
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
///<reference path="../../headers/common.d.ts" />
|
||||
|
||||
import _ from 'lodash';
|
||||
import angular from 'angular';
|
||||
import moment from 'moment';
|
||||
import * as dateMath from './datemath';
|
||||
|
||||
|
@ -1,35 +1,22 @@
|
||||
///<reference path="../../headers/common.d.ts" />
|
||||
|
||||
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,
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
///<reference path="../../headers/common.d.ts" />
|
||||
|
||||
import config from 'app/core/config';
|
||||
import angular from 'angular';
|
||||
import _ from 'lodash';
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
///<reference path="../../headers/common.d.ts" />
|
||||
|
||||
import config = require('app/core/config');
|
||||
import angular from 'angular';
|
||||
|
||||
export class AppListCtrl {
|
||||
|
@ -29,7 +29,6 @@
|
||||
<span style="small">
|
||||
Version: {{ctrl.appModel.info.version}} Updated: {{ctrl.appModel.info.updated}}
|
||||
</span>
|
||||
|
||||
</em>
|
||||
<br><br>
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
///<reference path="../../../headers/common.d.ts" />
|
||||
|
||||
import _ from 'lodash';
|
||||
import angular from 'angular';
|
||||
import moment from 'moment';
|
||||
|
||||
export function inputDateDirective() {
|
||||
|
@ -1,19 +1,17 @@
|
||||
///<reference path="../../../headers/common.d.ts" />
|
||||
|
||||
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;
|
||||
|
@ -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() {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -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"],
|
||||
// }
|
||||
// }
|
||||
}
|
||||
};
|
||||
};
|
||||
|
67
tslint.json
Normal file
67
tslint.json
Normal file
@ -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"
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user