Skip to content

Commit 3f26fa5

Browse files
committed
Add some new-line rules for TS files
Improves readability of the code. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent 8a7e6a9 commit 3f26fa5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1873
-64
lines changed

.eslintrc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,19 @@
1818
},
1919
"rules": {
2020
"array-bracket-spacing": "error",
21+
"array-bracket-newline": ["error", { "multiline": true }],
22+
"array-element-newline": ["error", "consistent"],
2123
"brace-style": "error",
2224
"camelcase": "error",
25+
"comma-dangle": ["error", "only-multiline"],
2326
"comma-style": ["error", "last"],
2427
"curly": "error",
2528
"dot-notation": "error",
2629
"eol-last": "error",
2730
"eqeqeq": "error",
2831
"indent": ["error", 4],
2932
"keyword-spacing": "error",
33+
"lines-between-class-members": "error",
3034
"new-cap": "error",
3135
"no-array-constructor": "error",
3236
"no-eval": "error",
@@ -44,6 +48,12 @@
4448
"object-curly-spacing": ["error", "always"],
4549
"one-var": ["error", "never"],
4650
"padded-blocks": ["error", "never"],
51+
"padding-line-between-statements": [
52+
"error",
53+
{ "blankLine": "always", "prev": "block-like", "next": "*" },
54+
{ "blankLine": "always", "prev": "multiline-expression", "next": "*" },
55+
{ "blankLine": "always", "prev": "*", "next": "return" }
56+
],
4757
"prefer-const": "off",
4858
"prefer-rest-params": "off",
4959
"prefer-spread": "off",

js/src/chart.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ window.ColumnType = ColumnType;
3131
*/
3232
var ChartFactory = function () {
3333
};
34+
3435
ChartFactory.prototype = {
3536
createChart: function () {
3637
throw new Error('createChart must be implemented by a subclass');
@@ -46,6 +47,7 @@ ChartFactory.prototype = {
4647
var Chart = function (elementId) {
4748
this.elementId = elementId;
4849
};
50+
4951
Chart.prototype = {
5052
draw: function () {
5153
throw new Error('draw must be implemented by a subclass');
@@ -76,18 +78,21 @@ Chart.prototype = {
7678
var BaseChart = function (elementId) {
7779
Chart.call(this, elementId);
7880
};
81+
7982
BaseChart.prototype = new Chart();
8083
BaseChart.prototype.constructor = BaseChart;
8184
BaseChart.prototype.validateColumns = function (dataTable) {
8285
var columns = dataTable.getColumns();
8386
if (columns.length < 2) {
8487
throw new Error('Minimum of two columns are required for this chart');
8588
}
89+
8690
for (var i = 1; i < columns.length; i++) {
8791
if (columns[i].type !== ColumnType.NUMBER) {
8892
throw new Error('Column ' + (i + 1) + ' should be of type \'Number\'');
8993
}
9094
}
95+
9196
return true;
9297
};
9398

@@ -100,13 +105,15 @@ BaseChart.prototype.validateColumns = function (dataTable) {
100105
var PieChart = function (elementId) {
101106
BaseChart.call(this, elementId);
102107
};
108+
103109
PieChart.prototype = new BaseChart();
104110
PieChart.prototype.constructor = PieChart;
105111
PieChart.prototype.validateColumns = function (dataTable) {
106112
var columns = dataTable.getColumns();
107113
if (columns.length > 2) {
108114
throw new Error('Pie charts can draw only one series');
109115
}
116+
110117
return BaseChart.prototype.validateColumns.call(this, dataTable);
111118
};
112119

@@ -119,6 +126,7 @@ PieChart.prototype.validateColumns = function (dataTable) {
119126
var TimelineChart = function (elementId) {
120127
BaseChart.call(this, elementId);
121128
};
129+
122130
TimelineChart.prototype = new BaseChart();
123131
TimelineChart.prototype.constructor = TimelineChart;
124132
TimelineChart.prototype.validateColumns = function (dataTable) {
@@ -129,6 +137,7 @@ TimelineChart.prototype.validateColumns = function (dataTable) {
129137
throw new Error('First column of timeline chart need to be a date column');
130138
}
131139
}
140+
132141
return result;
133142
};
134143

@@ -141,6 +150,7 @@ TimelineChart.prototype.validateColumns = function (dataTable) {
141150
var ScatterChart = function (elementId) {
142151
BaseChart.call(this, elementId);
143152
};
153+
144154
ScatterChart.prototype = new BaseChart();
145155
ScatterChart.prototype.constructor = ScatterChart;
146156
ScatterChart.prototype.validateColumns = function (dataTable) {
@@ -151,6 +161,7 @@ ScatterChart.prototype.validateColumns = function (dataTable) {
151161
throw new Error('First column of scatter chart need to be a numeric column');
152162
}
153163
}
164+
154165
return result;
155166
};
156167

@@ -185,6 +196,7 @@ var DataTable = function () {
185196
if (columns.length === 0) {
186197
throw new Error('Set columns first');
187198
}
199+
188200
var row;
189201
for (var i = 0; i < data.length; i++) {
190202
row = data[i];
@@ -198,6 +210,7 @@ var DataTable = function () {
198210
}
199211
};
200212
};
213+
201214
window.DataTable = DataTable;
202215

203216
/** *****************************************************************************
@@ -215,6 +228,7 @@ var JQPlotChart = function (elementId) {
215228
this.plot = null;
216229
this.validator = null;
217230
};
231+
218232
JQPlotChart.prototype = new Chart();
219233
JQPlotChart.prototype.constructor = JQPlotChart;
220234
JQPlotChart.prototype.draw = function (data, options) {
@@ -223,24 +237,29 @@ JQPlotChart.prototype.draw = function (data, options) {
223237
.populateOptions(data, options));
224238
}
225239
};
240+
226241
JQPlotChart.prototype.destroy = function () {
227242
if (this.plot !== null) {
228243
this.plot.destroy();
229244
}
230245
};
246+
231247
JQPlotChart.prototype.redraw = function (options) {
232248
if (this.plot !== null) {
233249
this.plot.replot(options);
234250
}
235251
};
252+
236253
JQPlotChart.prototype.toImageString = function () {
237254
if (this.plot !== null) {
238255
return $('#' + this.elementId).jqplotToImageStr({});
239256
}
240257
};
258+
241259
JQPlotChart.prototype.populateOptions = function () {
242260
throw new Error('populateOptions must be implemented by a subclass');
243261
};
262+
244263
JQPlotChart.prototype.prepareData = function () {
245264
throw new Error('prepareData must be implemented by a subclass');
246265
};
@@ -255,6 +274,7 @@ var JQPlotLineChart = function (elementId) {
255274
JQPlotChart.call(this, elementId);
256275
this.validator = BaseChart.prototype;
257276
};
277+
258278
JQPlotLineChart.prototype = new JQPlotChart();
259279
JQPlotLineChart.prototype.constructor = JQPlotLineChart;
260280

@@ -288,12 +308,14 @@ JQPlotLineChart.prototype.populateOptions = function (dataTable, options) {
288308
});
289309
}
290310
}
311+
291312
if (optional.axes.xaxis.ticks.length === 0) {
292313
var data = dataTable.getData();
293314
for (var j = 0; j < data.length; j++) {
294315
optional.axes.xaxis.ticks.push(data[j][0].toString());
295316
}
296317
}
318+
297319
return optional;
298320
};
299321

@@ -310,9 +332,11 @@ JQPlotLineChart.prototype.prepareData = function (dataTable) {
310332
retRow = [];
311333
retData[j - 1] = retRow;
312334
}
335+
313336
retRow.push(row[j]);
314337
}
315338
}
339+
316340
return retData;
317341
};
318342

@@ -325,6 +349,7 @@ JQPlotLineChart.prototype.prepareData = function (dataTable) {
325349
var JQPlotSplineChart = function (elementId) {
326350
JQPlotLineChart.call(this, elementId);
327351
};
352+
328353
JQPlotSplineChart.prototype = new JQPlotLineChart();
329354
JQPlotSplineChart.prototype.constructor = JQPlotSplineChart;
330355

@@ -340,6 +365,7 @@ JQPlotSplineChart.prototype.populateOptions = function (dataTable, options) {
340365
}
341366
};
342367
$.extend(true, optional, opt, compulsory);
368+
343369
return optional;
344370
};
345371

@@ -353,6 +379,7 @@ var JQPlotScatterChart = function (elementId) {
353379
JQPlotChart.call(this, elementId);
354380
this.validator = ScatterChart.prototype;
355381
};
382+
356383
JQPlotScatterChart.prototype = new JQPlotChart();
357384
JQPlotScatterChart.prototype.constructor = JQPlotScatterChart;
358385

@@ -392,6 +419,7 @@ JQPlotScatterChart.prototype.populateOptions = function (dataTable, options) {
392419
};
393420

394421
$.extend(true, optional, options, compulsory);
422+
395423
return optional;
396424
};
397425

@@ -409,10 +437,12 @@ JQPlotScatterChart.prototype.prepareData = function (dataTable) {
409437
retRow = [];
410438
retData[j - 1] = retRow;
411439
}
440+
412441
retRow.push([row[0], row[j]]);
413442
}
414443
}
415444
}
445+
416446
return retData;
417447
};
418448

@@ -426,6 +456,7 @@ var JQPlotTimelineChart = function (elementId) {
426456
JQPlotLineChart.call(this, elementId);
427457
this.validator = TimelineChart.prototype;
428458
};
459+
429460
JQPlotTimelineChart.prototype = new JQPlotLineChart();
430461
JQPlotTimelineChart.prototype.constructor = JQPlotTimelineChart;
431462

@@ -448,6 +479,7 @@ JQPlotTimelineChart.prototype.populateOptions = function (dataTable, options) {
448479
}
449480
};
450481
$.extend(true, optional, opt, compulsory);
482+
451483
return optional;
452484
};
453485

@@ -466,6 +498,7 @@ JQPlotTimelineChart.prototype.prepareData = function (dataTable) {
466498
retRow = [];
467499
retData[j - 1] = retRow;
468500
}
501+
469502
// See https://github.com/phpmyadmin/phpmyadmin/issues/14395 for the block
470503
if (d !== null && typeof d === 'object') {
471504
retRow.push([d.getTime(), row[j]]);
@@ -475,6 +508,7 @@ JQPlotTimelineChart.prototype.prepareData = function (dataTable) {
475508
}
476509
}
477510
}
511+
478512
return retData;
479513
};
480514

@@ -487,6 +521,7 @@ JQPlotTimelineChart.prototype.prepareData = function (dataTable) {
487521
var JQPlotAreaChart = function (elementId) {
488522
JQPlotLineChart.call(this, elementId);
489523
};
524+
490525
JQPlotAreaChart.prototype = new JQPlotLineChart();
491526
JQPlotAreaChart.prototype.constructor = JQPlotAreaChart;
492527

@@ -504,6 +539,7 @@ JQPlotAreaChart.prototype.populateOptions = function (dataTable, options) {
504539
}
505540
};
506541
$.extend(true, optional, opt, compulsory);
542+
507543
return optional;
508544
};
509545

@@ -516,6 +552,7 @@ JQPlotAreaChart.prototype.populateOptions = function (dataTable, options) {
516552
var JQPlotColumnChart = function (elementId) {
517553
JQPlotLineChart.call(this, elementId);
518554
};
555+
519556
JQPlotColumnChart.prototype = new JQPlotLineChart();
520557
JQPlotColumnChart.prototype.constructor = JQPlotColumnChart;
521558

@@ -533,6 +570,7 @@ JQPlotColumnChart.prototype.populateOptions = function (dataTable, options) {
533570
}
534571
};
535572
$.extend(true, optional, opt, compulsory);
573+
536574
return optional;
537575
};
538576

@@ -545,6 +583,7 @@ JQPlotColumnChart.prototype.populateOptions = function (dataTable, options) {
545583
var JQPlotBarChart = function (elementId) {
546584
JQPlotLineChart.call(this, elementId);
547585
};
586+
548587
JQPlotBarChart.prototype = new JQPlotLineChart();
549588
JQPlotBarChart.prototype.constructor = JQPlotBarChart;
550589

@@ -589,13 +628,15 @@ JQPlotBarChart.prototype.populateOptions = function (dataTable, options) {
589628
optional.axes.yaxis.ticks.push(data[i][0].toString());
590629
}
591630
}
631+
592632
if (optional.series.length === 0) {
593633
for (var j = 1; j < columns.length; j++) {
594634
optional.series.push({
595635
label: columns[j].name.toString()
596636
});
597637
}
598638
}
639+
599640
return optional;
600641
};
601642

@@ -609,6 +650,7 @@ var JQPlotPieChart = function (elementId) {
609650
JQPlotChart.call(this, elementId);
610651
this.validator = PieChart.prototype;
611652
};
653+
612654
JQPlotPieChart.prototype = new JQPlotChart();
613655
JQPlotPieChart.prototype.constructor = JQPlotPieChart;
614656

@@ -632,6 +674,7 @@ JQPlotPieChart.prototype.populateOptions = function (dataTable, options) {
632674
}
633675
};
634676
$.extend(true, optional, options, compulsory);
677+
635678
return optional;
636679
};
637680

@@ -643,6 +686,7 @@ JQPlotPieChart.prototype.prepareData = function (dataTable) {
643686
row = data[i];
644687
retData.push([row[0], row[1]]);
645688
}
689+
646690
return [retData];
647691
};
648692

@@ -651,6 +695,7 @@ JQPlotPieChart.prototype.prepareData = function (dataTable) {
651695
*/
652696
var JQPlotChartFactory = function () {
653697
};
698+
654699
JQPlotChartFactory.prototype = new ChartFactory();
655700
JQPlotChartFactory.prototype.createChart = function (type, elementId) {
656701
var chart = null;
@@ -683,4 +728,5 @@ JQPlotChartFactory.prototype.createChart = function (type, elementId) {
683728

684729
return chart;
685730
};
731+
686732
window.JQPlotChartFactory = JQPlotChartFactory;

js/src/codemirror/addon/lint/sql-lint.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ window.CodeMirror.sqlLint = function (text, updateLinting, options, cm) {
55
// Skipping check if text box is empty.
66
if (text.trim() === '') {
77
updateLinting(cm, []);
8+
89
return;
910
}
1011

0 commit comments

Comments
 (0)