mirror of
https://github.com/grafana/grafana.git
synced 2025-01-09 23:53:25 -06:00
added only-arrow-functions rule and changed files to follow new rule (#13154)
This commit is contained in:
parent
275f613050
commit
25f13bd3ad
@ -55,7 +55,7 @@ export function sqlPartEditorDirective($compile, templateSrv) {
|
||||
}
|
||||
|
||||
function inputBlur($input, paramIndex) {
|
||||
cancelBlur = setTimeout(function() {
|
||||
cancelBlur = setTimeout(() => {
|
||||
switchToLink($input, paramIndex);
|
||||
}, 200);
|
||||
}
|
||||
@ -95,20 +95,20 @@ export function sqlPartEditorDirective($compile, templateSrv) {
|
||||
return;
|
||||
}
|
||||
|
||||
const typeaheadSource = function(query, callback) {
|
||||
const typeaheadSource = (query, callback) => {
|
||||
if (param.options) {
|
||||
let options = param.options;
|
||||
if (param.type === 'int') {
|
||||
options = _.map(options, function(val) {
|
||||
options = _.map(options, val => {
|
||||
return val.toString();
|
||||
});
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
$scope.$apply(function() {
|
||||
$scope.handleEvent({ $event: { name: 'get-param-options', param: param } }).then(function(result) {
|
||||
const dynamicOptions = _.map(result, function(op) {
|
||||
$scope.$apply(() => {
|
||||
$scope.handleEvent({ $event: { name: 'get-param-options', param: param } }).then(result => {
|
||||
const dynamicOptions = _.map(result, op => {
|
||||
return op.value;
|
||||
});
|
||||
|
||||
@ -128,7 +128,7 @@ export function sqlPartEditorDirective($compile, templateSrv) {
|
||||
source: typeaheadSource,
|
||||
minLength: 0,
|
||||
items: 1000,
|
||||
updater: function(value) {
|
||||
updater: value => {
|
||||
if (value === part.params[paramIndex]) {
|
||||
clearTimeout(cancelBlur);
|
||||
$input.focus();
|
||||
@ -150,18 +150,18 @@ export function sqlPartEditorDirective($compile, templateSrv) {
|
||||
}
|
||||
}
|
||||
|
||||
$scope.showActionsMenu = function() {
|
||||
$scope.showActionsMenu = () => {
|
||||
$scope.handleEvent({ $event: { name: 'get-part-actions' } }).then(res => {
|
||||
$scope.partActions = res;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.triggerPartAction = function(action) {
|
||||
$scope.triggerPartAction = action => {
|
||||
$scope.handleEvent({ $event: { name: 'action', action: action } });
|
||||
};
|
||||
|
||||
function addElementsAndCompile() {
|
||||
_.each(partDef.params, function(param, index) {
|
||||
_.each(partDef.params, (param, index) => {
|
||||
if (param.optional && part.params.length <= index) {
|
||||
return;
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ export class Analytics {
|
||||
});
|
||||
const ga = ((window as any).ga =
|
||||
(window as any).ga ||
|
||||
//tslint:disable-next-line:only-arrow-functions
|
||||
function() {
|
||||
//tslint:disable-line:only-arrow-functions
|
||||
(ga.q = ga.q || []).push(arguments);
|
||||
});
|
||||
ga.l = +new Date();
|
||||
|
@ -52,8 +52,8 @@ function applied(fn, scope) {
|
||||
if (fn.wrappedInApply) {
|
||||
return fn;
|
||||
}
|
||||
//tslint:disable-next-line:only-arrow-functions
|
||||
const wrapped: any = function() {
|
||||
//tslint:disable-line:only-arrow-functions
|
||||
const args = arguments;
|
||||
const phase = scope.$root.$$phase;
|
||||
if (phase === '$apply' || phase === '$digest') {
|
||||
|
@ -96,7 +96,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
|
||||
}
|
||||
|
||||
updateProjection() {
|
||||
this.selectParts = _.map(this.target.select, function(parts: any) {
|
||||
this.selectParts = _.map(this.target.select, (parts: any) => {
|
||||
return _.map(parts, sqlPart.create).filter(n => n);
|
||||
});
|
||||
this.whereParts = _.map(this.target.where, sqlPart.create).filter(n => n);
|
||||
@ -104,15 +104,15 @@ export class PostgresQueryCtrl extends QueryCtrl {
|
||||
}
|
||||
|
||||
updatePersistedParts() {
|
||||
this.target.select = _.map(this.selectParts, function(selectParts) {
|
||||
return _.map(selectParts, function(part: any) {
|
||||
this.target.select = _.map(this.selectParts, selectParts => {
|
||||
return _.map(selectParts, (part: any) => {
|
||||
return { type: part.def.type, datatype: part.datatype, params: part.params };
|
||||
});
|
||||
});
|
||||
this.target.where = _.map(this.whereParts, function(part: any) {
|
||||
this.target.where = _.map(this.whereParts, (part: any) => {
|
||||
return { type: part.def.type, datatype: part.datatype, name: part.name, params: part.params };
|
||||
});
|
||||
this.target.group = _.map(this.groupParts, function(part: any) {
|
||||
this.target.group = _.map(this.groupParts, (part: any) => {
|
||||
return { type: part.def.type, datatype: part.datatype, params: part.params };
|
||||
});
|
||||
}
|
||||
@ -355,7 +355,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
|
||||
|
||||
switch (partType) {
|
||||
case 'column':
|
||||
const parts = _.map(selectParts, function(part: any) {
|
||||
const parts = _.map(selectParts, (part: any) => {
|
||||
return sqlPart.create({ type: part.def.type, params: _.clone(part.params) });
|
||||
});
|
||||
this.selectParts.push(parts);
|
||||
|
@ -1,22 +1,22 @@
|
||||
import PostgresQuery from '../postgres_query';
|
||||
|
||||
describe('PostgresQuery', function() {
|
||||
describe('PostgresQuery', () => {
|
||||
const templateSrv = {
|
||||
replace: jest.fn(text => text),
|
||||
};
|
||||
|
||||
describe('When initializing', function() {
|
||||
it('should not be in SQL mode', function() {
|
||||
describe('When initializing', () => {
|
||||
it('should not be in SQL mode', () => {
|
||||
const query = new PostgresQuery({}, templateSrv);
|
||||
expect(query.target.rawQuery).toBe(false);
|
||||
});
|
||||
it('should be in SQL mode for pre query builder queries', function() {
|
||||
it('should be in SQL mode for pre query builder queries', () => {
|
||||
const query = new PostgresQuery({ rawSql: 'SELECT 1' }, templateSrv);
|
||||
expect(query.target.rawQuery).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('When generating time column SQL', function() {
|
||||
describe('When generating time column SQL', () => {
|
||||
const query = new PostgresQuery({}, templateSrv);
|
||||
|
||||
query.target.timeColumn = 'time';
|
||||
@ -25,7 +25,7 @@ describe('PostgresQuery', function() {
|
||||
expect(query.buildTimeColumn()).toBe('"time" AS "time"');
|
||||
});
|
||||
|
||||
describe('When generating time column SQL with group by time', function() {
|
||||
describe('When generating time column SQL with group by time', () => {
|
||||
let query = new PostgresQuery(
|
||||
{ timeColumn: 'time', group: [{ type: 'time', params: ['5m', 'none'] }] },
|
||||
templateSrv
|
||||
@ -44,7 +44,7 @@ describe('PostgresQuery', function() {
|
||||
expect(query.buildTimeColumn(false)).toBe('$__unixEpochGroup(time,5m)');
|
||||
});
|
||||
|
||||
describe('When generating metric column SQL', function() {
|
||||
describe('When generating metric column SQL', () => {
|
||||
const query = new PostgresQuery({}, templateSrv);
|
||||
|
||||
query.target.metricColumn = 'host';
|
||||
@ -53,7 +53,7 @@ describe('PostgresQuery', function() {
|
||||
expect(query.buildMetricColumn()).toBe('"host" AS metric');
|
||||
});
|
||||
|
||||
describe('When generating value column SQL', function() {
|
||||
describe('When generating value column SQL', () => {
|
||||
const query = new PostgresQuery({}, templateSrv);
|
||||
|
||||
let column = [{ type: 'column', params: ['value'] }];
|
||||
@ -76,7 +76,7 @@ describe('PostgresQuery', function() {
|
||||
);
|
||||
});
|
||||
|
||||
describe('When generating value column SQL with metric column', function() {
|
||||
describe('When generating value column SQL with metric column', () => {
|
||||
const query = new PostgresQuery({}, templateSrv);
|
||||
query.target.metricColumn = 'host';
|
||||
|
||||
@ -110,7 +110,7 @@ describe('PostgresQuery', function() {
|
||||
);
|
||||
});
|
||||
|
||||
describe('When generating WHERE clause', function() {
|
||||
describe('When generating WHERE clause', () => {
|
||||
const query = new PostgresQuery({ where: [] }, templateSrv);
|
||||
|
||||
expect(query.buildWhereClause()).toBe('');
|
||||
@ -126,7 +126,7 @@ describe('PostgresQuery', function() {
|
||||
expect(query.buildWhereClause()).toBe('\nWHERE\n $__timeFilter(t) AND\n v = 1');
|
||||
});
|
||||
|
||||
describe('When generating GROUP BY clause', function() {
|
||||
describe('When generating GROUP BY clause', () => {
|
||||
const query = new PostgresQuery({ group: [], metricColumn: 'none' }, templateSrv);
|
||||
|
||||
expect(query.buildGroupClause()).toBe('');
|
||||
@ -136,7 +136,7 @@ describe('PostgresQuery', function() {
|
||||
expect(query.buildGroupClause()).toBe('\nGROUP BY 1,2');
|
||||
});
|
||||
|
||||
describe('When generating complete statement', function() {
|
||||
describe('When generating complete statement', () => {
|
||||
const target = {
|
||||
timeColumn: 't',
|
||||
table: 'table',
|
||||
|
@ -49,6 +49,7 @@
|
||||
"no-var-keyword": true,
|
||||
"object-literal-sort-keys": false,
|
||||
"one-line": [true, "check-open-brace", "check-catch", "check-else"],
|
||||
"only-arrow-functions": [true, "allow-declarations", "allow-named-functions"],
|
||||
"prefer-const": true,
|
||||
"radix": false,
|
||||
"typedef-whitespace": [
|
||||
|
Loading…
Reference in New Issue
Block a user