Commit 491fa6ca by Torkel Ödegaard

tech: more tslint rules

parent b8d9722b
import * as React from 'react';
// import from 'react-dom';
import 'react-dom';
import coreModule from '../core_module';
export interface IProps {
......
......@@ -60,7 +60,7 @@ export function getValuePreview (object: Object, value: string): string {
if (type === 'string') {
value = '"' + escapeString(value) + '"';
}
if (type === 'function'){
if (type === 'function') {
// Remove content of the function
return object.toString()
......
......@@ -190,7 +190,7 @@ export class JsonExplorer {
if (this.element) {
if (this.isOpen) {
this.appendChildren(this.config.animateOpen);
} else{
} else {
this.removeChildren(this.config.animateClose);
}
this.element.classList.toggle(cssClass('open'));
......
......@@ -76,7 +76,7 @@ export class SideMenuCtrl {
});
}
loadOrgsItems(){
loadOrgsItems() {
this.orgItems = [];
this.orgs.forEach(org => {
if (org.orgId === this.contextSrv.user.orgId) {
......
......@@ -168,15 +168,16 @@ export default class TimeSeries {
if (currentValue < this.stats.min) {
this.stats.min = currentValue;
}
if (this.stats.first === null){
if (this.stats.first === null) {
this.stats.first = currentValue;
}else{
} else {
if (previousValue > currentValue) { // counter reset
previousDeltaUp = false;
if (i === this.datapoints.length-1) { // reset on last
this.stats.delta += currentValue;
}
}else{
} else {
if (previousDeltaUp) {
this.stats.delta += currentValue - previousValue; // normal increment
} else {
......
......@@ -38,7 +38,7 @@ export class DashboardExporter {
var templateizeDatasourceUsage = obj => {
// ignore data source properties that contain a variable
if (obj.datasource && obj.datasource.indexOf('$') === 0) {
if (variableLookup[obj.datasource.substring(1)]){
if (variableLookup[obj.datasource.substring(1)]) {
return;
}
}
......
......@@ -64,7 +64,7 @@ export class QueryVariable implements Variable {
return this.model;
}
setValue(option){
setValue(option) {
return this.variableSrv.setOptionAsCurrent(this, option);
}
......
......@@ -82,7 +82,7 @@ export class VariableSrv {
createVariableFromModel(model) {
var ctor = variableTypes[model.type].ctor;
if (!ctor) {
throw "Unable to find variable constructor for " + model.type;
throw {message: "Unable to find variable constructor for " + model.type};
}
var variable = this.$injector.instantiate(ctor, {model: model});
......
// Type definitions for mocha 2.0.1
// Project: http://mochajs.org/
// Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid/>, otiai10 <https://github.com/otiai10>, jt000 <https://github.com/jt000>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface Mocha {
// Setup mocha with the given setting options.
setup(options: MochaSetupOptions): Mocha;
//Run tests and invoke `fn()` when complete.
run(callback?: () => void): void;
// Set reporter as function
reporter(reporter: () => void): Mocha;
// Set reporter, defaults to "dot"
reporter(reporter: string): Mocha;
// Enable growl support.
growl(): Mocha
}
interface MochaSetupOptions {
//milliseconds to wait before considering a test slow
slow?: number;
// timeout in milliseconds
timeout?: number;
// ui name "bdd", "tdd", "exports" etc
ui?: string;
//array of accepted globals
globals?: any[];
// reporter instance (function or string), defaults to `mocha.reporters.Dot`
reporter?: any;
// bail on the first test failure
bail?: boolean;
// ignore global leaks
ignoreLeaks?: boolean;
// grep string or regexp to filter tests with
grep?: any;
}
interface MochaDone {
(error?: Error): void;
}
declare var mocha: Mocha;
declare var describe : {
(description: string, spec: () => void): void;
only(description: string, spec: () => void): void;
skip(description: string, spec: () => void): void;
timeout(ms: number): void;
}
// alias for `describe`
declare var context : {
(contextTitle: string, spec: () => void): void;
only(contextTitle: string, spec: () => void): void;
skip(contextTitle: string, spec: () => void): void;
timeout(ms: number): void;
}
declare var it: {
(expectation: string, assertion?: () => void): void;
(expectation: string, assertion?: (done: MochaDone) => void): void;
only(expectation: string, assertion?: () => void): void;
only(expectation: string, assertion?: (done: MochaDone) => void): void;
skip(expectation: string, assertion?: () => void): void;
skip(expectation: string, assertion?: (done: MochaDone) => void): void;
timeout(ms: number): void;
};
declare function before(action: () => void): void;
declare function before(action: (done: MochaDone) => void): void;
declare function setup(action: () => void): void;
declare function setup(action: (done: MochaDone) => void): void;
declare function after(action: () => void): void;
declare function after(action: (done: MochaDone) => void): void;
declare function teardown(action: () => void): void;
declare function teardown(action: (done: MochaDone) => void): void;
declare function beforeEach(action: () => void): void;
declare function beforeEach(action: (done: MochaDone) => void): void;
declare function suiteSetup(action: () => void): void;
declare function suiteSetup(action: (done: MochaDone) => void): void;
declare function afterEach(action: () => void): void;
declare function afterEach(action: (done: MochaDone) => void): void;
declare function suiteTeardown(action: () => void): void;
declare function suiteTeardown(action: (done: MochaDone) => void): void;
declare module "mocha" {
class Mocha {
constructor(options?: {
grep?: RegExp;
ui?: string;
reporter?: string;
timeout?: number;
bail?: boolean;
});
bail(value?: boolean): Mocha;
addFile(file: string): Mocha;
reporter(value: string): Mocha;
ui(value: string): Mocha;
grep(value: string): Mocha;
grep(value: RegExp): Mocha;
invert(): Mocha;
ignoreLeaks(value: boolean): Mocha;
checkLeaks(): Mocha;
growl(): Mocha;
globals(value: string): Mocha;
globals(values: string[]): Mocha;
useColors(value: boolean): Mocha;
useInlineDiffs(value: boolean): Mocha;
timeout(value: number): Mocha;
slow(value: number): Mocha;
enableTimeouts(value: boolean): Mocha;
asyncOnly(value: boolean): Mocha;
noHighlighting(value: boolean): Mocha;
run(onComplete?: (failures: number) => void): void;
}
export = Mocha;
}
declare module Zone {
export class Stacktrace {
constructor(e: Error);
get(): string;
}
}
declare class Zone {
constructor(parentZone: Zone, data: any);
fork(locals: any): Zone;
bind(fn, skipEnqueue): void;
bindOnce(fn): any;
run(fn, applyTo?, applyWith?): void;
beforeTask(): void;
onZoneCreated(): void;
afterTask(): void;
enqueueTask(): void;
dequeueTask(): void;
static patchSetClearFn(obj, fnNames): string;
static patchPrototype(obj, fnNames): any;
static bindArguments(args: any[]): any;
static bindArgumentsOnce(args: any[]): any;
static patchableFn(obj, fnNames): any
static patchProperty(obj, prop): void;
static patchProperties(obj, properties): void;
static patchEventTargetMethods(obj): void;
static patch(): void;
static canPatchViaPropertyDescriptor(): boolean;
static patchViaPropertyDescriptor(): void;
static patchViaCapturingAllTheEvents(): void;
static patchWebSocket(): void;
static patchClass(className: string): void;
static patchMutationObserverClass(className: string): void;
static patchDefineProperty(): void;
static patchRegisterElement(): void;
static eventNames: string;
static onEventNames: string;
static init(): void;
static exceptZone: {
boringZone: Zone;
interestingZone: Zone,
beforeTask: () => void;
afterTask: () => void;
fork: (ops: any) => Zone;
};
static longStackTraceZone: {
getLongStacktrace(exception: any): string;
stackFramesFilter(line: string): boolean;
onError(exception): void;
fork(locals): Zone;
};
static getStacktrace(): Zone.Stacktrace;
static countingZone: {
'+enqueueTask': () => void;
'-dequeueTask': () => void;
'+afterTask': () => void;
counter: () => void;
data: {
count: number;
flushed: boolean;
};
onFlush: () => void;
};
}
......@@ -3,7 +3,7 @@
import _ from 'lodash';
export default class ResponseParser {
constructor(private $q){}
constructor(private $q) {}
processQueryResult(res) {
var data = [];
......@@ -47,7 +47,7 @@ export default class ResponseParser {
const textColIndex = this.findColIndex(columns, '__text');
const valueColIndex = this.findColIndex(columns, '__value');
if (columns.length === 2 && textColIndex !== -1 && valueColIndex !== -1){
if (columns.length === 2 && textColIndex !== -1 && valueColIndex !== -1) {
return this.transformToKeyValueList(rows, textColIndex, valueColIndex);
}
......
......@@ -156,7 +156,7 @@ export class DataProcessor {
});
fieldParts.pop();
}
if (firstItem.type === 'docs'){
if (firstItem.type === 'docs') {
if (firstItem.datapoints.length === 0) {
return [];
}
......
......@@ -113,7 +113,7 @@ class SingleStatCtrl extends MetricsPanelCtrl {
onDataReceived(dataList) {
const data: any = {};
if (dataList.length > 0 && dataList[0].type === 'table'){
if (dataList.length > 0 && dataList[0].type === 'table') {
this.dataType = 'table';
const tableData = dataList.map(this.tableHandler.bind(this));
this.setTableValues(tableData, data);
......
......@@ -47,7 +47,7 @@ describe("Emitter", () => {
events.on('test', () => {
sub1Called++;
throw "hello";
throw {message: "hello"};
});
events.on('test', () => {
......
{
"rules": {
"no-string-throw": true,
"no-unused-expression": true,
"no-duplicate-variable": true,
"no-unused-variable": true,
"curly": true,
"class-name": true,
"semicolon": ["always"],
"triple-equals": [true, "allow-null-check"],
"comment-format": [false, "check-space"],
"curly": true,
"eofline": true,
"forin": false,
"indent": [true, "spaces"],
"indent": [true, "spaces", 2],
"label-position": true,
"max-line-length": [true, 140],
"member-access": false,
......@@ -40,8 +43,6 @@
"check-else"
],
"radix": false,
"semicolon": true,
"triple-equals": [true, "allow-null-check"],
"typedef-whitespace": [true, {
"call-signature": "nospace",
"index-signature": "nospace",
......@@ -53,7 +54,8 @@
"whitespace": [true,
"check-branch",
"check-decl",
"check-type"
"check-type",
"check-preblock"
]
}
}
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