Skip to content

Commit c87853f

Browse files
committed
Fix warning typescript-eslint/explicit-module-boundary-types
1 parent 054571d commit c87853f

File tree

8 files changed

+39
-32
lines changed

8 files changed

+39
-32
lines changed

src/ConfigEditor.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface Props extends DataSourcePluginOptionsEditorProps<MyDataSourceOptions,
1212
interface State {}
1313

1414
export class ConfigEditor extends PureComponent<Props, State> {
15-
onUrlChange = (event: ChangeEvent<HTMLInputElement>) => {
15+
onUrlChange = (event: ChangeEvent<HTMLInputElement>) : void => {
1616
const { onOptionsChange, options } = this.props;
1717
const jsonData = {
1818
...options.jsonData,
@@ -21,7 +21,7 @@ export class ConfigEditor extends PureComponent<Props, State> {
2121
onOptionsChange({ ...options, jsonData });
2222
};
2323

24-
onEditionChange = ({ value }: SelectableValue<Edition>) => {
24+
onEditionChange = ({ value }: SelectableValue<Edition>) : void => {
2525
const { onOptionsChange, options } = this.props;
2626
const jsonData = {
2727
...options.jsonData,
@@ -30,7 +30,7 @@ export class ConfigEditor extends PureComponent<Props, State> {
3030
onOptionsChange({ ...options, jsonData });
3131
};
3232

33-
onUsernameChange = (event: ChangeEvent<HTMLInputElement>) => {
33+
onUsernameChange = (event: ChangeEvent<HTMLInputElement>) : void => {
3434
const { onOptionsChange, options } = this.props;
3535
const jsonData = {
3636
...options.jsonData,
@@ -40,7 +40,7 @@ export class ConfigEditor extends PureComponent<Props, State> {
4040
};
4141

4242
// Secure field (only sent to the backend)
43-
onSecretChange = (event: ChangeEvent<HTMLInputElement>) => {
43+
onSecretChange = (event: ChangeEvent<HTMLInputElement>) : void => {
4444
const { onOptionsChange, options } = this.props;
4545
onOptionsChange({
4646
...options,
@@ -50,7 +50,7 @@ export class ConfigEditor extends PureComponent<Props, State> {
5050
});
5151
};
5252

53-
onResetSecret = () => {
53+
onResetSecret = () : void => {
5454
const { onOptionsChange, options } = this.props;
5555
onOptionsChange({
5656
...options,
@@ -65,7 +65,7 @@ export class ConfigEditor extends PureComponent<Props, State> {
6565
});
6666
};
6767

68-
render() {
68+
render() : JSX.Element {
6969
const { options } = this.props;
7070
const { jsonData, secureJsonFields } = options;
7171
const secureJsonData = options.secureJsonData || {};

src/DataSource.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { FetchResponse, getBackendSrv, BackendSrvRequest } from '@grafana/runtim
1313
import { buildRequestBody, combinedDesc, graphDefinitionRequest } from './graphspecs';
1414
import { MyQuery, defaultQuery, MyDataSourceOptions, ResponseData, ResponseDataCurves } from './types';
1515

16-
export const buildUrlWithParams = (url: string, params: Record<string, string>) =>
16+
export const buildUrlWithParams = (url: string, params: Record<string, string>): string =>
1717
url + '?' + new URLSearchParams(params).toString();
1818

1919
function buildMetricDataFrame(response: FetchResponse<ResponseData<ResponseDataCurves>>, query: MyQuery) {
@@ -49,7 +49,7 @@ export class DataSource extends DataSourceApi<MyQuery> {
4949
return Promise.all(promises).then((data) => ({ data }));
5050
}
5151

52-
async getGraphQuery(range: number[], query: MyQuery) {
52+
async getGraphQuery(range: number[], query: MyQuery): Promise<MutableDataFrame<unknown>> {
5353
if (isEmpty(query.context) || !query.params.graph_name) {
5454
return new MutableDataFrame();
5555
}
@@ -62,7 +62,7 @@ export class DataSource extends DataSourceApi<MyQuery> {
6262
return buildMetricDataFrame(response, query);
6363
}
6464

65-
async testDatasource() {
65+
async testDatasource(): Promise<unknown | undefined> {
6666
return this.doRequest({
6767
refId: 'testDatasource',
6868
params: { action: 'get_combined_graph_identifications' },

src/QueryEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { GraphSelect } from 'components/fields';
1111

1212
type Props = QueryEditorProps<DataSource, MyQuery, MyDataSourceOptions>;
1313

14-
export const QueryEditor = (props: Props) => {
14+
export const QueryEditor = (props: Props) : JSX.Element => {
1515
defaults(props.query, defaultQuery); // mutate into default query
1616
const editionMode = get(props, 'datasource.instanceSettings.jsonData.edition', '');
1717

src/components/combinedgraphs.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
} from './filters';
1616
import { Presentation } from 'types';
1717

18-
export const SelectAggregation = (props: EditorProps) => {
18+
export const SelectAggregation = (props: EditorProps) : JSX.Element => {
1919
const combined_presentations = [
2020
{ value: 'lines', label: 'Lines' },
2121
// { value: 'stacked', label: 'Stacked' }, // no difference to line at request level
@@ -44,7 +44,7 @@ export const SelectAggregation = (props: EditorProps) => {
4444
);
4545
};
4646

47-
export const FilterEditor = (props: EditorProps) => {
47+
export const FilterEditor = (props: EditorProps) : JSX.Element => {
4848
const context = props.query.context || {};
4949
return (
5050
<>
@@ -60,7 +60,7 @@ interface FilterEditorProps extends EditorProps {
6060
filtername: string;
6161
}
6262

63-
export const SelectFilters = (props: FilterEditorProps) => {
63+
export const SelectFilters = (props: FilterEditorProps) : null | JSX.Element => {
6464
const all_filters = [
6565
{ value: 'siteopt', label: 'Site', render: SiteFilter },
6666
{ value: 'host', label: 'Hostname', render: HostFilter },

src/components/fields.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ const update = (x: MyQuery, path: string, func: () => SelectableValue<string> |
1414
};
1515

1616
export const vsAutocomplete =
17-
(datasource: DataSource, autocompleteConfig: AutoCompleteConfig) => (inputValue: string) =>
17+
(datasource: DataSource, autocompleteConfig: AutoCompleteConfig) =>
18+
(inputValue: string): Promise<{ value: string; label: string; isDisabled: boolean }[]> =>
1819
datasource
1920
.restRequest<ResponseDataAutocomplete>('ajax_vs_autocomplete.py', {
2021
...autocompleteConfig,
@@ -34,7 +35,7 @@ export const AsyncAutocomplete = ({
3435
onRunQuery,
3536
query,
3637
contextPath,
37-
}: AutoCompleteEditorProps) => {
38+
}: AutoCompleteEditorProps) : JSX.Element => {
3839
const onSelection = (value: SelectableValue<string>) => {
3940
let newQuery = update(query, contextPath, () => value.value);
4041
newQuery = update(newQuery, 'params.selections.' + contextPath, () => value);
@@ -61,9 +62,9 @@ export const AsyncAutocomplete = ({
6162
);
6263
};
6364

64-
export const titleCase = (str: string) => str[0].toUpperCase() + str.slice(1).toLowerCase();
65+
export const titleCase = (str: string) : string => str[0].toUpperCase() + str.slice(1).toLowerCase();
6566

66-
export const GraphType = ({ query, onChange, onRunQuery, contextPath }: AutoCompleteEditorProps) => {
67+
export const GraphType = ({ query, onChange, onRunQuery, contextPath }: AutoCompleteEditorProps) : JSX.Element => {
6768
const graphTypes = [
6869
{ value: 'template', label: 'Template' },
6970
{ value: 'metric', label: 'Single metric' },
@@ -85,7 +86,7 @@ export const GraphType = ({ query, onChange, onRunQuery, contextPath }: AutoComp
8586
);
8687
};
8788

88-
export const GraphSelect = (props: EditorProps) => {
89+
export const GraphSelect = (props: EditorProps) : JSX.Element => {
8990
const graphMode = get(props, 'query.params.graphMode', 'template');
9091
let completionVS;
9192
if (props.edition === 'CEE') {

src/components/filters.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { AsyncAutocomplete, vsAutocomplete } from './fields';
1616
import { get, update } from 'lodash';
1717
import { ResponseDataAutocompleteLabel } from 'types';
1818

19-
export const SiteFilter = (props: EditorProps) => {
19+
export const SiteFilter = (props: EditorProps) : JSX.Element => {
2020
const sitesVS = { ident: 'sites', params: { strict: false, context: props.query.context } };
2121

2222
return (
@@ -30,7 +30,7 @@ export const SiteFilter = (props: EditorProps) => {
3030
);
3131
};
3232

33-
export const HostFilter = (props: EditorProps) => {
33+
export const HostFilter = (props: EditorProps) : JSX.Element => {
3434
const hostVS = {
3535
ident: 'monitored_hostname',
3636
params: { strict: true, context: props.query.context },
@@ -46,7 +46,7 @@ export const HostFilter = (props: EditorProps) => {
4646
);
4747
};
4848

49-
export const HostRegExFilter = (props: EditorProps) => {
49+
export const HostRegExFilter = (props: EditorProps) : JSX.Element => {
5050
const onHostChange = (event: ChangeEvent<HTMLInputElement>) => {
5151
const { onChange, query } = props;
5252
update(query, 'context.hostregex.host_regex', () => event.target.value);
@@ -70,7 +70,7 @@ export const HostRegExFilter = (props: EditorProps) => {
7070
);
7171
};
7272

73-
export const ServiceFilter = (props: EditorProps) => {
73+
export const ServiceFilter = (props: EditorProps) : JSX.Element => {
7474
const serviceVS = {
7575
ident: 'monitored_service_description',
7676
params: { strict: true, host: get(props, 'query.context.host.host', ''), context: props.query.context },
@@ -87,7 +87,7 @@ export const ServiceFilter = (props: EditorProps) => {
8787
);
8888
};
8989

90-
export const ServiceRegExFilter = (props: EditorProps) => {
90+
export const ServiceRegExFilter = (props: EditorProps) : JSX.Element => {
9191
const onServiceChange = (event: ChangeEvent<HTMLInputElement>) => {
9292
const { onChange, query } = props;
9393
update(query, 'context.serviceregex.service_regex', () => event.target.value);
@@ -111,7 +111,7 @@ export const ServiceRegExFilter = (props: EditorProps) => {
111111
);
112112
};
113113

114-
export const HostLabelsFilter = ({ datasource, onChange, query, onRunQuery }: EditorProps) => {
114+
export const HostLabelsFilter = ({ datasource, onChange, query, onRunQuery }: EditorProps) : JSX.Element => {
115115
const valueListToSelect = (labels: Array<SelectableValue<string>>) =>
116116
labels.map(({ value }) => ({ label: value, value: value }));
117117

@@ -150,7 +150,7 @@ export const HostLabelsFilter = ({ datasource, onChange, query, onRunQuery }: Ed
150150
);
151151
};
152152

153-
export const HostGroupFilter = (props: EditorProps) => {
153+
export const HostGroupFilter = (props: EditorProps) : JSX.Element => {
154154
const onNegateChange = (event: ChangeEvent<HTMLInputElement>) => {
155155
const { onChange, query } = props;
156156
update(query, 'context.opthostgroup.neg_opthost_group', () => (event.target.checked ? 'on' : ''));
@@ -181,7 +181,7 @@ export const HostGroupFilter = (props: EditorProps) => {
181181
);
182182
};
183183

184-
export const ServiceGroupFilter = (props: EditorProps) => {
184+
export const ServiceGroupFilter = (props: EditorProps) : JSX.Element => {
185185
const onNegateChange = (event: ChangeEvent<HTMLInputElement>) => {
186186
const { onChange, query } = props;
187187
update(query, 'context.optservicegroup.neg_optservice_group', () => (event.target.checked ? 'on' : ''));
@@ -216,7 +216,7 @@ interface HostTagsEditorProps extends EditorProps {
216216
index: number;
217217
}
218218

219-
export const HostTagsItemFilter = (props: HostTagsEditorProps) => {
219+
export const HostTagsItemFilter = (props: HostTagsEditorProps) : JSX.Element => {
220220
const index = props.index;
221221

222222
const groupVS = {
@@ -270,7 +270,7 @@ export const HostTagsItemFilter = (props: HostTagsEditorProps) => {
270270
);
271271
};
272272

273-
export const HostTagsFilter = (props: EditorProps) => {
273+
export const HostTagsFilter = (props: EditorProps) : JSX.Element => {
274274
return (
275275
<>
276276
{Array.from({ length: 3 }).map((_, idx) => (

src/graphspecs.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { get } from 'lodash';
2-
import { Context, MyQuery, Presentation } from './types';
3-
export const buildRequestBody = (data: unknown) => `request=${JSON.stringify(data)}`;
2+
import { ContextHTTPVars, Context, MyQuery, Presentation } from './types';
3+
export const buildRequestBody = (data: unknown): string => `request=${JSON.stringify(data)}`;
44

55
interface CombinedGraphSpec {
66
graph_template: string;
@@ -14,6 +14,12 @@ interface TemplateGraphSpec {
1414
graph_id: string;
1515
}
1616

17+
interface SingleInfos {
18+
site: string | ContextHTTPVars;
19+
host_name: string | ContextHTTPVars;
20+
service_description: string | ContextHTTPVars;
21+
}
22+
1723
type GraphSpec = ['template', TemplateGraphSpec] | ['combined', CombinedGraphSpec];
1824

1925
export function graphDefinitionRequest(editionMode: string, query: MyQuery, range: number[]): string {
@@ -34,7 +40,7 @@ function graphSpecification(editionMode: string, query: MyQuery): GraphSpec {
3440
throw new Error('UNSUPORTED EDITION');
3541
}
3642

37-
export function extractSingleInfos(context: Context) {
43+
export function extractSingleInfos(context: Context): SingleInfos {
3844
return {
3945
site: get(context, 'siteopt.site', ''),
4046
host_name: get(context, 'host.host', ''),

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DataQuery, DataSourceJsonData } from '@grafana/data';
22

3-
interface ContextHTTPVars {
3+
export interface ContextHTTPVars {
44
[key: string]: string;
55
}
66
export interface Context {

0 commit comments

Comments
 (0)