mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
noImplicitAny: Fix basic errors (#17668)
* Fix basic noImplicitAny errors * noImplicitAny HeatmapCtrl * Update error limit
This commit is contained in:
parent
433e5ac049
commit
c9ad411d8e
@ -190,6 +190,7 @@
|
||||
"@babel/polyfill": "7.2.5",
|
||||
"@torkelo/react-select": "2.4.1",
|
||||
"@types/angular-route": "1.7.0",
|
||||
"@types/enzyme-adapter-react-16": "1.0.5",
|
||||
"@types/react-redux": "^7.0.8",
|
||||
"@types/reselect": "2.2.0",
|
||||
"angular": "1.6.6",
|
||||
|
@ -3,7 +3,7 @@ export class HeatmapDisplayEditorCtrl {
|
||||
panelCtrl: any;
|
||||
|
||||
/** @ngInject */
|
||||
constructor($scope) {
|
||||
constructor($scope: any) {
|
||||
$scope.editor = this;
|
||||
this.panelCtrl = $scope.ctrl;
|
||||
this.panel = this.panelCtrl.panel;
|
||||
|
@ -12,11 +12,13 @@ import {
|
||||
calculateBucketSize,
|
||||
sortSeriesByLabel,
|
||||
} from './heatmap_data_converter';
|
||||
import { auto } from 'angular';
|
||||
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||
|
||||
const X_BUCKET_NUMBER_DEFAULT = 30;
|
||||
const Y_BUCKET_NUMBER_DEFAULT = 10;
|
||||
|
||||
const panelDefaults = {
|
||||
const panelDefaults: any = {
|
||||
heatmap: {},
|
||||
cards: {
|
||||
cardPadding: null,
|
||||
@ -117,7 +119,7 @@ export class HeatmapCtrl extends MetricsPanelCtrl {
|
||||
scaledDecimals: number;
|
||||
|
||||
/** @ngInject */
|
||||
constructor($scope, $injector, timeSrv) {
|
||||
constructor($scope: any, $injector: auto.IInjectorService, timeSrv: TimeSrv) {
|
||||
super($scope, $injector);
|
||||
this.timeSrv = timeSrv;
|
||||
this.selectionActivated = false;
|
||||
@ -143,7 +145,7 @@ export class HeatmapCtrl extends MetricsPanelCtrl {
|
||||
this.unitFormats = kbn.getUnitFormats();
|
||||
}
|
||||
|
||||
zoomOut(evt) {
|
||||
zoomOut(evt: any) {
|
||||
this.publishAppEvent('zoom-out', 2);
|
||||
}
|
||||
|
||||
@ -275,7 +277,7 @@ export class HeatmapCtrl extends MetricsPanelCtrl {
|
||||
}
|
||||
}
|
||||
|
||||
onDataReceived(dataList) {
|
||||
onDataReceived(dataList: any) {
|
||||
this.series = dataList.map(this.seriesHandler.bind(this));
|
||||
|
||||
this.dataWarning = null;
|
||||
@ -312,12 +314,12 @@ export class HeatmapCtrl extends MetricsPanelCtrl {
|
||||
this.render();
|
||||
}
|
||||
|
||||
onCardColorChange(newColor) {
|
||||
onCardColorChange(newColor: any) {
|
||||
this.panel.color.cardColor = newColor;
|
||||
this.render();
|
||||
}
|
||||
|
||||
seriesHandler(seriesData) {
|
||||
seriesHandler(seriesData: any) {
|
||||
if (seriesData.datapoints === undefined) {
|
||||
throw new Error('Heatmap error: data should be a time series');
|
||||
}
|
||||
@ -341,19 +343,19 @@ export class HeatmapCtrl extends MetricsPanelCtrl {
|
||||
return series;
|
||||
}
|
||||
|
||||
parseSeries(series) {
|
||||
parseSeries(series: any[]) {
|
||||
const min = _.min(_.map(series, s => s.stats.min));
|
||||
const minLog = _.min(_.map(series, s => s.stats.logmin));
|
||||
const max = _.max(_.map(series, s => s.stats.max));
|
||||
|
||||
return {
|
||||
max: max,
|
||||
min: min,
|
||||
minLog: minLog,
|
||||
max,
|
||||
min,
|
||||
minLog,
|
||||
};
|
||||
}
|
||||
|
||||
parseHistogramSeries(series) {
|
||||
parseHistogramSeries(series: any[]) {
|
||||
const bounds = _.map(series, s => Number(s.alias));
|
||||
const min = _.min(bounds);
|
||||
const minLog = _.min(bounds);
|
||||
@ -366,7 +368,7 @@ export class HeatmapCtrl extends MetricsPanelCtrl {
|
||||
};
|
||||
}
|
||||
|
||||
link(scope, elem, attrs, ctrl) {
|
||||
link(scope: any, elem: any, attrs: any, ctrl: any) {
|
||||
rendering(scope, elem, attrs, ctrl);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ export class HeatmapTooltip {
|
||||
mouseOverBucket: boolean;
|
||||
originalFillColor: any;
|
||||
|
||||
constructor(elem, scope) {
|
||||
constructor(elem: JQuery, scope: any) {
|
||||
this.scope = scope;
|
||||
this.dashboard = scope.ctrl.dashboard;
|
||||
this.panelCtrl = scope.ctrl;
|
||||
@ -35,7 +35,7 @@ export class HeatmapTooltip {
|
||||
this.destroy();
|
||||
}
|
||||
|
||||
onMouseMove(e) {
|
||||
onMouseMove(e: any) {
|
||||
if (!this.panel.tooltip.show) {
|
||||
return;
|
||||
}
|
||||
@ -58,7 +58,7 @@ export class HeatmapTooltip {
|
||||
this.tooltip = null;
|
||||
}
|
||||
|
||||
show(pos, data) {
|
||||
show(pos: { panelRelY: any }, data: any) {
|
||||
if (!this.panel.tooltip.show || !data) {
|
||||
return;
|
||||
}
|
||||
@ -109,7 +109,7 @@ export class HeatmapTooltip {
|
||||
if (yData.bounds) {
|
||||
if (data.tsBuckets) {
|
||||
// Use Y-axis labels
|
||||
const tickFormatter = valIndex => {
|
||||
const tickFormatter = (valIndex: string | number) => {
|
||||
return data.tsBucketsFormatted ? data.tsBucketsFormatted[valIndex] : data.tsBuckets[valIndex];
|
||||
};
|
||||
|
||||
@ -152,13 +152,13 @@ export class HeatmapTooltip {
|
||||
this.move(pos);
|
||||
}
|
||||
|
||||
getBucketIndexes(pos, data) {
|
||||
getBucketIndexes(pos: { panelRelY?: any; x?: any; y?: any }, data: any) {
|
||||
const xBucketIndex = this.getXBucketIndex(pos.x, data);
|
||||
const yBucketIndex = this.getYBucketIndex(pos.y, data);
|
||||
return { xBucketIndex, yBucketIndex };
|
||||
}
|
||||
|
||||
getXBucketIndex(x, data) {
|
||||
getXBucketIndex(x: number, data: { buckets: any; xBucketSize: number }) {
|
||||
// First try to find X bucket by checking x pos is in the
|
||||
// [bucket.x, bucket.x + xBucketSize] interval
|
||||
const xBucket: any = _.find(data.buckets, bucket => {
|
||||
@ -167,7 +167,7 @@ export class HeatmapTooltip {
|
||||
return xBucket ? xBucket.x : getValueBucketBound(x, data.xBucketSize, 1);
|
||||
}
|
||||
|
||||
getYBucketIndex(y, data) {
|
||||
getYBucketIndex(y: number, data: { tsBuckets: any; yBucketSize: number }) {
|
||||
if (data.tsBuckets) {
|
||||
return Math.floor(y);
|
||||
}
|
||||
@ -175,17 +175,17 @@ export class HeatmapTooltip {
|
||||
return yBucketIndex;
|
||||
}
|
||||
|
||||
getSharedTooltipPos(pos) {
|
||||
getSharedTooltipPos(pos: { pageX: any; x: any; pageY: any; panelRelY: number }) {
|
||||
// get pageX from position on x axis and pageY from relative position in original panel
|
||||
pos.pageX = this.heatmapPanel.offset().left + this.scope.xScale(pos.x);
|
||||
pos.pageY = this.heatmapPanel.offset().top + this.scope.chartHeight * pos.panelRelY;
|
||||
return pos;
|
||||
}
|
||||
|
||||
addHistogram(data) {
|
||||
addHistogram(data: { x: string | number }) {
|
||||
const xBucket = this.scope.ctrl.data.buckets[data.x];
|
||||
const yBucketSize = this.scope.ctrl.data.yBucketSize;
|
||||
let min, max, ticks;
|
||||
let min: number, max: number, ticks: number;
|
||||
if (this.scope.ctrl.data.tsBuckets) {
|
||||
min = 0;
|
||||
max = this.scope.ctrl.data.tsBuckets.length - 1;
|
||||
@ -206,7 +206,7 @@ export class HeatmapTooltip {
|
||||
const scale = this.scope.yScale.copy();
|
||||
const histXScale = scale.domain([min, max]).range([0, HISTOGRAM_WIDTH]);
|
||||
|
||||
let barWidth;
|
||||
let barWidth: number;
|
||||
if (this.panel.yAxis.logBase === 1) {
|
||||
barWidth = Math.floor((HISTOGRAM_WIDTH / (max - min)) * yBucketSize * 0.9);
|
||||
} else {
|
||||
@ -233,19 +233,19 @@ export class HeatmapTooltip {
|
||||
.data(histogramData)
|
||||
.enter()
|
||||
.append('rect')
|
||||
.attr('x', d => {
|
||||
.attr('x', (d: any[]) => {
|
||||
return histXScale(d[0]);
|
||||
})
|
||||
.attr('width', barWidth)
|
||||
.attr('y', d => {
|
||||
.attr('y', (d: any[]) => {
|
||||
return HISTOGRAM_HEIGHT - histYScale(d[1]);
|
||||
})
|
||||
.attr('height', d => {
|
||||
.attr('height', (d: any[]) => {
|
||||
return histYScale(d[1]);
|
||||
});
|
||||
}
|
||||
|
||||
move(pos) {
|
||||
move(pos: { panelRelY?: any; pageX?: any; pageY?: any }) {
|
||||
if (!this.tooltip) {
|
||||
return;
|
||||
}
|
||||
@ -268,9 +268,9 @@ export class HeatmapTooltip {
|
||||
return this.tooltip.style('left', left + 'px').style('top', top + 'px');
|
||||
}
|
||||
|
||||
countValueFormatter(decimals, scaledDecimals = null) {
|
||||
countValueFormatter(decimals: number, scaledDecimals: any = null) {
|
||||
const format = 'short';
|
||||
return value => {
|
||||
return (value: number) => {
|
||||
return getValueFormat(format)(value, decimals, scaledDecimals);
|
||||
};
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { HeatmapCtrl } from '../heatmap_ctrl';
|
||||
import { dateTime } from '@grafana/ui/src/utils/moment_wrapper';
|
||||
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||
|
||||
describe('HeatmapCtrl', () => {
|
||||
const ctx = {} as any;
|
||||
@ -20,7 +21,8 @@ describe('HeatmapCtrl', () => {
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
ctx.ctrl = new HeatmapCtrl($scope, $injector, {});
|
||||
//@ts-ignore
|
||||
ctx.ctrl = new HeatmapCtrl($scope, $injector, {} as TimeSrv);
|
||||
});
|
||||
|
||||
describe('when time series are outside range', () => {
|
||||
|
@ -14,8 +14,8 @@ const labelWidth = 8;
|
||||
const pieChartOptions = [{ value: PieChartType.PIE, label: 'Pie' }, { value: PieChartType.DONUT, label: 'Donut' }];
|
||||
|
||||
export class PieChartOptionsBox extends PureComponent<PanelEditorProps<PieChartOptions>> {
|
||||
onPieTypeChange = pieType => this.props.onOptionsChange({ ...this.props.options, pieType: pieType.value });
|
||||
onStrokeWidthChange = ({ target }) =>
|
||||
onPieTypeChange = (pieType: any) => this.props.onOptionsChange({ ...this.props.options, pieType: pieType.value });
|
||||
onStrokeWidthChange = ({ target }: any) =>
|
||||
this.props.onOptionsChange({ ...this.props.options, strokeWidth: target.value });
|
||||
|
||||
render() {
|
||||
|
@ -1,5 +1,7 @@
|
||||
import _ from 'lodash';
|
||||
import { PanelCtrl } from '../../../features/panel/panel_ctrl';
|
||||
import { auto } from 'angular';
|
||||
import { BackendSrv } from '@grafana/runtime';
|
||||
|
||||
class PluginListCtrl extends PanelCtrl {
|
||||
static templateUrl = 'module.html';
|
||||
@ -12,7 +14,7 @@ class PluginListCtrl extends PanelCtrl {
|
||||
panelDefaults = {};
|
||||
|
||||
/** @ngInject */
|
||||
constructor($scope, $injector, private backendSrv) {
|
||||
constructor($scope: any, $injector: auto.IInjectorService, private backendSrv: BackendSrv) {
|
||||
super($scope, $injector);
|
||||
|
||||
_.defaults(this.panel, this.panelDefaults);
|
||||
@ -32,14 +34,14 @@ class PluginListCtrl extends PanelCtrl {
|
||||
this.addEditorTab('Options', 'public/app/plugins/panel/pluginlist/editor.html');
|
||||
}
|
||||
|
||||
gotoPlugin(plugin, evt) {
|
||||
gotoPlugin(plugin: { id: any }, evt: any) {
|
||||
if (evt) {
|
||||
evt.stopPropagation();
|
||||
}
|
||||
this.$location.url(`plugins/${plugin.id}/edit`);
|
||||
}
|
||||
|
||||
updateAvailable(plugin, $event) {
|
||||
updateAvailable(plugin: any, $event: any) {
|
||||
$event.stopPropagation();
|
||||
$event.preventDefault();
|
||||
|
||||
|
@ -67,7 +67,7 @@ export class ColumnOptionsCtrl {
|
||||
}
|
||||
|
||||
addColumnStyle() {
|
||||
const newStyleRule = {
|
||||
const newStyleRule: object = {
|
||||
unit: 'short',
|
||||
type: 'number',
|
||||
alias: '',
|
||||
|
@ -22,12 +22,12 @@ const global = window as any;
|
||||
global.$ = global.jQuery = $;
|
||||
|
||||
const localStorageMock = (() => {
|
||||
let store = {};
|
||||
let store: any = {};
|
||||
return {
|
||||
getItem: (key: string) => {
|
||||
return store[key];
|
||||
},
|
||||
setItem: (key: string, value) => {
|
||||
setItem: (key: string, value: any) => {
|
||||
store[key] = value.toString();
|
||||
},
|
||||
clear: () => {
|
||||
|
@ -1,15 +1,15 @@
|
||||
declare var global: NodeJS.Global;
|
||||
|
||||
(global as any).requestAnimationFrame = callback => {
|
||||
(global as any).requestAnimationFrame = (callback: any) => {
|
||||
setTimeout(callback, 0);
|
||||
};
|
||||
|
||||
(Promise.prototype as any).finally = function(onFinally) {
|
||||
(Promise.prototype as any).finally = function(onFinally: any) {
|
||||
return this.then(
|
||||
/* onFulfilled */
|
||||
res => Promise.resolve(onFinally()).then(() => res),
|
||||
(res: any) => Promise.resolve(onFinally()).then(() => res),
|
||||
/* onRejected */
|
||||
err =>
|
||||
(err: any) =>
|
||||
Promise.resolve(onFinally()).then(() => {
|
||||
throw err;
|
||||
})
|
||||
|
@ -8,11 +8,11 @@ export const backendSrv = {
|
||||
post: jest.fn(),
|
||||
};
|
||||
|
||||
export function createNavTree(...args) {
|
||||
const root = [];
|
||||
export function createNavTree(...args: any[]) {
|
||||
const root: any[] = [];
|
||||
let node = root;
|
||||
for (const arg of args) {
|
||||
const child = { id: arg, url: `/url/${arg}`, text: `${arg}-Text`, children: [] };
|
||||
const child: any = { id: arg, url: `/url/${arg}`, text: `${arg}-Text`, children: [] };
|
||||
node.push(child);
|
||||
node = child.children;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import { StoreState } from 'app/types';
|
||||
|
||||
export const mockExploreState = (options: any = {}) => {
|
||||
const isLive = options.isLive || false;
|
||||
const history = [];
|
||||
const history: any[] = [];
|
||||
const eventBridge = {
|
||||
emit: jest.fn(),
|
||||
};
|
||||
|
@ -14,12 +14,12 @@ export function ControllerTestContext(this: any) {
|
||||
this.annotationsSrv = {};
|
||||
this.contextSrv = {};
|
||||
this.timeSrv = new TimeSrvStub();
|
||||
this.templateSrv = new TemplateSrvStub();
|
||||
this.templateSrv = TemplateSrvStub();
|
||||
this.datasourceSrv = {
|
||||
getMetricSources: () => {},
|
||||
get: () => {
|
||||
return {
|
||||
then: callback => {
|
||||
then: (callback: (a: any) => void) => {
|
||||
callback(self.datasource);
|
||||
},
|
||||
};
|
||||
@ -84,7 +84,7 @@ export function ControllerTestContext(this: any) {
|
||||
self.scope.panel = {};
|
||||
self.scope.dashboard = { meta: {} };
|
||||
self.scope.dashboardMeta = {};
|
||||
self.scope.dashboardViewState = new DashboardViewStateStub();
|
||||
self.scope.dashboardViewState = DashboardViewStateStub();
|
||||
self.scope.appEvent = sinon.spy();
|
||||
self.scope.onAppEvent = sinon.spy();
|
||||
|
||||
@ -102,14 +102,14 @@ export function ControllerTestContext(this: any) {
|
||||
});
|
||||
};
|
||||
|
||||
this.setIsUtc = (isUtc = false) => {
|
||||
this.setIsUtc = (isUtc: any = false) => {
|
||||
self.isUtc = isUtc;
|
||||
};
|
||||
}
|
||||
|
||||
export function ServiceTestContext(this: any) {
|
||||
const self = this;
|
||||
self.templateSrv = new TemplateSrvStub();
|
||||
self.templateSrv = TemplateSrvStub();
|
||||
self.timeSrv = new TimeSrvStub();
|
||||
self.datasourceSrv = {};
|
||||
self.backendSrv = {};
|
||||
|
@ -3,7 +3,7 @@
|
||||
echo -e "Collecting code stats (typescript errors & more)"
|
||||
|
||||
|
||||
ERROR_COUNT_LIMIT=4599
|
||||
ERROR_COUNT_LIMIT=4400
|
||||
DIRECTIVES_LIMIT=172
|
||||
CONTROLLERS_LIMIT=139
|
||||
|
||||
|
15
yarn.lock
15
yarn.lock
@ -1965,6 +1965,21 @@
|
||||
"@types/d3-voronoi" "*"
|
||||
"@types/d3-zoom" "*"
|
||||
|
||||
"@types/enzyme-adapter-react-16@^1.0.5":
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/enzyme-adapter-react-16/-/enzyme-adapter-react-16-1.0.5.tgz#1bf30a166f49be69eeda4b81e3f24113c8b4e9d5"
|
||||
integrity sha512-K7HLFTkBDN5RyRmU90JuYt8OWEY2iKUn43SDWEoBOXd/PowUWjLZ3Q6qMBiQuZeFYK/TOstaZxsnI0fXoAfLpg==
|
||||
dependencies:
|
||||
"@types/enzyme" "*"
|
||||
|
||||
"@types/enzyme@*":
|
||||
version "3.9.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/enzyme/-/enzyme-3.9.3.tgz#d1029c0edd353d7b00f3924803eb88216460beed"
|
||||
integrity sha512-jDKoZiiMA3lGO3skSO7dfqEHNvmiTLLV+PHD9EBQVlJANJvpY6qq1zzjRI24ZOtG7F+CS7BVWDXKewRmN8PjHQ==
|
||||
dependencies:
|
||||
"@types/cheerio" "*"
|
||||
"@types/react" "*"
|
||||
|
||||
"@types/enzyme@3.9.0":
|
||||
version "3.9.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/enzyme/-/enzyme-3.9.0.tgz#a81c91e2dfd2d70e67f013f2c0e5efed6df05489"
|
||||
|
Loading…
Reference in New Issue
Block a user