Skip to content

Commit 076da95

Browse files
committed
use grafana eslint config
1 parent b621e70 commit 076da95

File tree

8 files changed

+35
-34
lines changed

8 files changed

+35
-34
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ module.exports = {
77
extends: [
88
'eslint:recommended',
99
'plugin:@typescript-eslint/recommended',
10+
'@grafana/eslint-config',
1011
],
1112
};

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>) : void => {
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>) : void => {
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>) : void => {
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>) : void => {
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 = () : void => {
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() : JSX.Element {
68+
render(): JSX.Element {
6969
const { options } = this.props;
7070
const { jsonData, secureJsonFields } = options;
7171
const secureJsonData = options.secureJsonData || {};

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) : JSX.Element => {
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) : JSX.Element => {
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) : JSX.Element => {
4444
);
4545
};
4646

47-
export const FilterEditor = (props: EditorProps) : JSX.Element => {
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) : null | JSX.Element => {
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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const update = (x: MyQuery, path: string, func: () => SelectableValue<string> |
1515

1616
export const vsAutocomplete =
1717
(datasource: DataSource, autocompleteConfig: AutoCompleteConfig) =>
18-
(inputValue: string): Promise<{ value: string; label: string; isDisabled: boolean }[]> =>
18+
(inputValue: string): Promise<Array<{ value: string; label: string; isDisabled: boolean }>> =>
1919
datasource
2020
.restRequest<ResponseDataAutocomplete>('ajax_vs_autocomplete.py', {
2121
...autocompleteConfig,
@@ -35,7 +35,7 @@ export const AsyncAutocomplete = ({
3535
onRunQuery,
3636
query,
3737
contextPath,
38-
}: AutoCompleteEditorProps) : JSX.Element => {
38+
}: AutoCompleteEditorProps): JSX.Element => {
3939
const onSelection = (value: SelectableValue<string>) => {
4040
let newQuery = update(query, contextPath, () => value.value);
4141
newQuery = update(newQuery, 'params.selections.' + contextPath, () => value);
@@ -62,9 +62,9 @@ export const AsyncAutocomplete = ({
6262
);
6363
};
6464

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

67-
export const GraphType = ({ query, onChange, onRunQuery, contextPath }: AutoCompleteEditorProps) : JSX.Element => {
67+
export const GraphType = ({ query, onChange, onRunQuery, contextPath }: AutoCompleteEditorProps): JSX.Element => {
6868
const graphTypes = [
6969
{ value: 'template', label: 'Template' },
7070
{ value: 'metric', label: 'Single metric' },
@@ -86,7 +86,7 @@ export const GraphType = ({ query, onChange, onRunQuery, contextPath }: AutoComp
8686
);
8787
};
8888

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

src/components/filters.tsx

Lines changed: 11 additions & 11 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) : JSX.Element => {
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) : JSX.Element => {
3030
);
3131
};
3232

33-
export const HostFilter = (props: EditorProps) : JSX.Element => {
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) : JSX.Element => {
4646
);
4747
};
4848

49-
export const HostRegExFilter = (props: EditorProps) : JSX.Element => {
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) : JSX.Element => {
7070
);
7171
};
7272

73-
export const ServiceFilter = (props: EditorProps) : JSX.Element => {
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) : JSX.Element => {
8787
);
8888
};
8989

90-
export const ServiceRegExFilter = (props: EditorProps) : JSX.Element => {
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) : JSX.Element => {
111111
);
112112
};
113113

114-
export const HostLabelsFilter = ({ datasource, onChange, query, onRunQuery }: EditorProps) : JSX.Element => {
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

@@ -128,7 +128,7 @@ export const HostLabelsFilter = ({ datasource, onChange, query, onRunQuery }: Ed
128128
.then(valueListToSelect);
129129
};
130130

131-
const onLabelsChange = (values: SelectableValue<string>[]) => {
131+
const onLabelsChange = (values: Array<SelectableValue<string>>) => {
132132
update(query, 'context.host_labels.host_label', () => JSON.stringify(values.map((l) => ({ value: l.value }))));
133133
onChange(query);
134134
onRunQuery();
@@ -150,7 +150,7 @@ export const HostLabelsFilter = ({ datasource, onChange, query, onRunQuery }: Ed
150150
);
151151
};
152152

153-
export const HostGroupFilter = (props: EditorProps) : JSX.Element => {
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) : JSX.Element => {
181181
);
182182
};
183183

184-
export const ServiceGroupFilter = (props: EditorProps) : JSX.Element => {
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) : JSX.Element => {
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) : JSX.Element =>
270270
);
271271
};
272272

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

src/components/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface EditorProps {
1111
}
1212

1313
export interface AutoCompleteEditorProps extends EditorProps {
14-
autocompleter: (inputValue: string) => Promise<SelectableValue<string>[]>;
14+
autocompleter: (inputValue: string) => Promise<Array<SelectableValue<string>>>;
1515
contextPath: string;
1616
}
1717

src/types.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,24 @@ export interface MySecureJsonData {
4545
}
4646

4747
export interface ResponseDataAutocomplete {
48-
choices: [string, string][];
48+
choices: Array<[string, string]>;
4949
}
5050

51-
export type ResponseDataAutocompleteLabel = {
51+
export type ResponseDataAutocompleteLabel = Array<{
5252
value: string;
53-
}[];
53+
}>;
5454

5555
export interface ResponseDataCurves {
5656
filter: unknown;
5757
start_time: number;
5858
step: number;
59-
curves: {
59+
curves: Array<{
6060
title: string;
61-
rrddata: {
61+
rrddata: Array<{
6262
i: number;
6363
d: Record<string, unknown>;
64-
}[];
65-
}[];
64+
}>;
65+
}>;
6666
}
6767

6868
export interface ResponseData<T> {

0 commit comments

Comments
 (0)