Skip to content
This repository was archived by the owner on Dec 11, 2022. It is now read-only.

Commit dfbc059

Browse files
authored
Merge pull request #291 from doitintl/feature/lior/bqalert
Migrate to eslint
2 parents 756780e + 7f2eae7 commit dfbc059

File tree

9 files changed

+73
-85
lines changed

9 files changed

+73
-85
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,19 @@
3636
"@types/grafana": "https://git@github.com/CorpGlory/types-grafana.git",
3737
"@types/jest": "^24.0.11",
3838
"@types/lodash-es": "^4.17.3",
39+
"@typescript-eslint/eslint-plugin": "^4.10.0",
40+
"@typescript-eslint/parser": "^4.10.0",
3941
"babel-core": "^6.26.3",
4042
"babel-jest": "^24.5.0",
4143
"babel-loader": "^8.0.4",
4244
"babel-preset-env": "^1.7.0",
4345
"clean-webpack-plugin": "^1.0.1",
4446
"codecov": "^3.2.0",
4547
"copy-webpack-plugin": "^5.1.1",
48+
"eslint": "^7.15.0",
4649
"googleapis": "^49.0.0",
4750
"grafana-sdk-mocks": "github:grafana/grafana-sdk-mocks",
48-
"jest": "^26.0.1",
51+
"jest": "^24.0.1",
4952
"ng-annotate-webpack-plugin": "^0.3.0",
5053
"plugin-typescript": "^8.0.0",
5154
"prettier": "^1.19.1",

src/bigquery_query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ export default class BigQueryQuery {
323323
}
324324
overParts.push('ORDER BY ' + this.buildTimeColumn(false));
325325
const over = overParts.join(' ');
326-
let curr = query;
326+
const curr = query;
327327
let prev: string;
328328
const tmpval = query;
329329
switch (windows.type) {

src/datasource.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,8 @@ export class BigQueryDatasource {
478478
private setUpPartition(query, isPartitioned, partitionedField, options) {
479479
partitionedField = partitionedField ? partitionedField : '_PARTITIONTIME';
480480
if (isPartitioned && !query.match(partitionedField)) {
481-
let fromD = BigQueryQuery.convertToUtc(options.range.from._d);
482-
let toD = BigQueryQuery.convertToUtc(options.range.to._d);
481+
const fromD = BigQueryQuery.convertToUtc(options.range.from._d);
482+
const toD = BigQueryQuery.convertToUtc(options.range.to._d);
483483
const from = `${partitionedField} >= '${BigQueryQuery.formatDateToString(fromD, '-', true)}'`;
484484
const to = `${partitionedField} < '${BigQueryQuery.formatDateToString(toD, '-', true)}'`;
485485
const partition = `where ${from} AND ${to} AND `;

src/query_ctrl.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,7 @@ export class BigQueryQueryCtrl extends QueryCtrl {
345345
public async timeColumnChanged(refresh?: boolean) {
346346
this.target.timeColumn = this.timeColumnSegment.value;
347347
this.target.timeColumnType = await this._getDateFieldType();
348-
let partModel;
349-
partModel = sqlPart.create({
348+
const partModel = sqlPart.create({
350349
name: '$__timeFilter',
351350
params: [],
352351
type: 'macro',

src/response_parser.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ export default class ResponseParser {
197197
});
198198
}
199199
const rows = [];
200-
each(results.rows, (ser) => {
200+
each(results.rows, ser => {
201201
const r = [];
202-
each(ser, (v) => {
202+
each(ser, v => {
203203
for (let i = 0; i < v.length; i++) {
204204
const val = v[i].v ? ResponseParser._convertValues(v[i].v, columns[i].type) : '';
205205
r.push(val);
@@ -220,7 +220,7 @@ export default class ResponseParser {
220220
res.push(row.f[0].v);
221221
}
222222

223-
return _.map(res, (value) => {
223+
return _.map(res, value => {
224224
return { text: value };
225225
});
226226
}

src/specs/bigquery_query.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ describe('BigQueryQuery', () => {
4949
const query = new BigQueryQuery({}, templateSrv);
5050
expect(query.buildMetricColumn()).toBe('');
5151
query.target.metricColumn = 'host';
52-
expect(query.buildMetricColumn()).toBe('CAST (`host` AS String ) AS metric');
52+
expect(query.buildMetricColumn()).toBe('`host` AS metric');
5353
query.target.metricColumn = '"host"';
54-
expect(query.buildMetricColumn()).toBe('CAST (`"host"` AS String ) AS metric');
54+
expect(query.buildMetricColumn()).toBe('`"host"` AS metric');
5555
});
5656

5757
describe('When generating value column SQL', () => {
@@ -225,7 +225,7 @@ describe('BigQueryQuery', () => {
225225

226226
query.target.metricColumn = 'm';
227227
result =
228-
'#standardSQL\nSELECT\n `t` AS time,\n CAST (`m` AS String ) AS metric,\n `value`\nFROM `undefined.undefined.table`\nGROUP BY 1,2,3 \nORDER BY 1,2';
228+
'#standardSQL\nSELECT\n `t` AS time,\n `m` AS metric,\n `value`\nFROM `undefined.undefined.table`\nGROUP BY 1,2,3 \nORDER BY 1,2';
229229
expect(query.buildQuery()).toBe(result);
230230
});
231231

src/specs/datasource.test.ts

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,15 @@ describe('BigQueryDatasource', () => {
136136
});
137137

138138
it('should return expected data batch api', async () => {
139-
let priority = 'BATCH';
139+
const priority = 'BATCH';
140140
await ctx.ds.doQuery('select * from table', 'id-1', priority).then(data => {
141141
results = data;
142142
});
143143
expect(results.rows.length).toBe(3);
144144
expect(results.schema.fields.length).toBe(2);
145145
});
146146
it('should return expected data interactive', async () => {
147-
let priority = 'INTERACTIVE';
147+
const priority = 'INTERACTIVE';
148148
await ctx.ds.doQuery('select * from table', 'id-1', priority).then(data => {
149149
results = data;
150150
});
@@ -153,7 +153,7 @@ describe('BigQueryDatasource', () => {
153153
});
154154

155155
it('should return expected data interactive', async () => {
156-
let priority = 'INTERACTIVE';
156+
const priority = 'INTERACTIVE';
157157
await ctx.ds.doQueryRequest('select * from table', 'id-1', priority).then(data => {
158158
results = data;
159159
});
@@ -868,11 +868,11 @@ describe('BigQueryDatasource', () => {
868868
mode: 'NULLABLE',
869869
},
870870
];
871-
let options = { annotation: {} };
872-
let data = { data: { schema: { fields } } };
873-
let p = new Promise((reject, resolve) => {});
874-
let rp = new ResponseParser(p);
875-
let list = rp.transformAnnotationResponse(options, data);
871+
const options = { annotation: {} };
872+
const data = { data: { schema: { fields } } };
873+
const p = new Promise((reject, resolve) => { });
874+
const rp = new ResponseParser(p);
875+
const list = rp.transformAnnotationResponse(options, data);
876876
expect(list.length).toBe(0);
877877
});
878878
it('transformAnnotationResponse empty results without rows', () => {
@@ -893,55 +893,55 @@ describe('BigQueryDatasource', () => {
893893
mode: 'NULLABLE',
894894
},
895895
];
896-
let options = { annotation: {} };
897-
let data = { data: { schema: { fields } } };
898-
let p = new Promise((reject, resolve) => {});
899-
let rp = new ResponseParser(p);
900-
let list = rp.transformAnnotationResponse(options, data);
896+
const options = { annotation: {} };
897+
const data = { data: { schema: { fields } } };
898+
const p = new Promise((reject, resolve) => { });
899+
const rp = new ResponseParser(p);
900+
const list = rp.transformAnnotationResponse(options, data);
901901
expect(list.length).toBe(0);
902902
});
903903
it('transformAnnotationResponse results with 3 rows', () => {
904904
const rows = [
905-
{
906-
f: [
907-
{
908-
v: '1.521578851E9',
909-
},
910-
{
911-
v: '37.7753058',
912-
},
913-
{
914-
v: '42.7753058',
915-
},
916-
],
917-
},
918-
{
919-
f: [
920-
{
921-
v: '1.521578916E9',
922-
},
923-
{
924-
v: '37.3322326',
925-
},
926-
{
927-
v: '42.7753058',
928-
},
929-
],
930-
},
931-
{
932-
f: [
933-
{
934-
v: '1.521578927E9',
935-
},
936-
{
937-
v: '37.781752',
938-
},
939-
{
940-
v: '42.7753058',
941-
},
942-
],
943-
},
944-
],
905+
{
906+
f: [
907+
{
908+
v: '1.521578851E9',
909+
},
910+
{
911+
v: '37.7753058',
912+
},
913+
{
914+
v: '42.7753058',
915+
},
916+
],
917+
},
918+
{
919+
f: [
920+
{
921+
v: '1.521578916E9',
922+
},
923+
{
924+
v: '37.3322326',
925+
},
926+
{
927+
v: '42.7753058',
928+
},
929+
],
930+
},
931+
{
932+
f: [
933+
{
934+
v: '1.521578927E9',
935+
},
936+
{
937+
v: '37.781752',
938+
},
939+
{
940+
v: '42.7753058',
941+
},
942+
],
943+
},
944+
],
945945
fields = [
946946
{
947947
name: 'time',
@@ -959,11 +959,11 @@ describe('BigQueryDatasource', () => {
959959
mode: 'NULLABLE',
960960
},
961961
];
962-
let options = { annotation: {} };
963-
let data = { data: { schema: { fields }, rows } };
964-
let p = new Promise((reject, resolve) => {});
965-
let rp = new ResponseParser(p);
966-
let list = rp.transformAnnotationResponse(options, data);
962+
const options = { annotation: {} };
963+
const data = { data: { schema: { fields }, rows } };
964+
const p = new Promise((reject, resolve) => { });
965+
const rp = new ResponseParser(p);
966+
const list = rp.transformAnnotationResponse(options, data);
967967
expect(list.length).toBe(3);
968968
});
969969
});

src/sql_part.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export class SqlPartDef {
1717
} else {
1818
this.label = this.type[0].toUpperCase() + this.type.substring(1) + ':';
1919
}
20+
2021
this.style = options.style;
2122
if (this.style === 'function') {
2223
this.wrapOpen = '(';

tslint.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)