Skip to content

Commit e183a98

Browse files
committed
enforce space-before-blocks,
- so that: if() { / for() { and function() { not: if(){ / for(){ and function(){ are the norm
1 parent 33255f1 commit e183a98

Some content is hidden

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

50 files changed

+312
-311
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"no-spaced-func": [2],
3131
"space-in-parens": [2, "never"],
3232
"space-before-function-paren": [2, "never"],
33+
"space-before-blocks": [2],
3334
"no-multi-spaces": [2],
3435
"space-infix-ops": [0, {"int32Hint": false}],
3536
"quotes": [2, "single"],

src/components/annotations/index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ annotations.draw = function(gd, index, opt, value) {
363363
.attr('data-unformatted', options.text)
364364
.text(options.text);
365365

366-
function textLayout(s){
366+
function textLayout(s) {
367367
s.call(Plotly.Drawing.font, font)
368368
.attr({
369369
'text-anchor': {
@@ -375,7 +375,7 @@ annotations.draw = function(gd, index, opt, value) {
375375
return s;
376376
}
377377

378-
function drawGraphicalElements(){
378+
function drawGraphicalElements() {
379379

380380
// make sure lines are aligned the way they will be
381381
// at the end, even if their position changes
@@ -395,8 +395,8 @@ annotations.draw = function(gd, index, opt, value) {
395395
options._w = annwidth;
396396
options._h = annheight;
397397

398-
function shiftFraction(v, anchor){
399-
if(anchor==='auto'){
398+
function shiftFraction(v, anchor) {
399+
if(anchor==='auto') {
400400
if(v < 1/3) anchor = 'left';
401401
else if(v > 2/3) anchor = 'right';
402402
else anchor = 'center';
@@ -469,7 +469,7 @@ annotations.draw = function(gd, index, opt, value) {
469469

470470
// make sure the arrowhead (if there is one)
471471
// and the annotation center are visible
472-
if(options.showarrow){
472+
if(options.showarrow) {
473473
arrowX = Plotly.Lib.constrain(annPosPx.x - options.ax, 1, fullLayout.width - 1);
474474
arrowY = Plotly.Lib.constrain(annPosPx.y - options.ay, 1, fullLayout.height - 1);
475475
}
@@ -498,7 +498,7 @@ annotations.draw = function(gd, index, opt, value) {
498498

499499
// add the arrow
500500
// uses options[arrowwidth,arrowcolor,arrowhead] for styling
501-
var drawArrow = function(dx, dy){
501+
var drawArrow = function(dx, dy) {
502502
d3.select(gd)
503503
.selectAll('.annotation-arrow-g[data-index="' + index + '"]')
504504
.remove();
@@ -541,7 +541,7 @@ annotations.draw = function(gd, index, opt, value) {
541541
return;
542542
}
543543

544-
edges.forEach(function(x){
544+
edges.forEach(function(x) {
545545
var p = lineIntersect(arrowX0, arrowY0, arrowX, arrowY,
546546
x[0], x[1], x[2], x[3]);
547547
if(p) {
@@ -711,7 +711,7 @@ annotations.draw = function(gd, index, opt, value) {
711711
if(gd._context.editable) {
712712
anntext.call(Plotly.util.makeEditable, ann)
713713
.call(textLayout)
714-
.on('edit', function(_text){
714+
.on('edit', function(_text) {
715715
options.text = _text;
716716
this.attr({'data-unformatted': options.text});
717717
this.call(textLayout);
@@ -839,7 +839,7 @@ annotations.calcAutorange = function(gd) {
839839
if(!annotationList.length || !gd._fullData.length) return;
840840

841841
var annotationAxes = {};
842-
annotationList.forEach(function(ann){
842+
annotationList.forEach(function(ann) {
843843
annotationAxes[ann.xref] = true;
844844
annotationAxes[ann.yref] = true;
845845
});
@@ -863,7 +863,7 @@ function annAutorange(gd) {
863863
// relative to their anchor points
864864
// use the arrow and the text bg rectangle,
865865
// as the whole anno may include hidden text in its bbox
866-
fullLayout.annotations.forEach(function(ann){
866+
fullLayout.annotations.forEach(function(ann) {
867867
var xa = Plotly.Axes.getFromId(gd, ann.xref),
868868
ya = Plotly.Axes.getFromId(gd, ann.yref);
869869
if(!(xa || ya)) return;

src/components/color/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ color.addOpacity = function(cstr, op) {
3939
// combine two colors into one apparent color
4040
// if back has transparency or is missing,
4141
// color.background is assumed behind it
42-
color.combine = function(front, back){
42+
color.combine = function(front, back) {
4343
var fc = tinycolor(front).toRgb();
4444
if(fc.a===1) return tinycolor(front).toRgbString();
4545

src/components/colorbar/draw.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module.exports = function draw(gd, id) {
5050
// evaluated halfway between levels
5151
opts.filllevels = null;
5252

53-
function component(){
53+
function component() {
5454
var fullLayout = gd._fullLayout;
5555
if((typeof opts.fillcolor !== 'function') &&
5656
(typeof opts.line.color !== 'function')) {
@@ -63,9 +63,9 @@ module.exports = function draw(gd, id) {
6363
filllevels = [],
6464
l,
6565
linecolormap = typeof opts.line.color === 'function' ?
66-
opts.line.color : function(){ return opts.line.color; },
66+
opts.line.color : function() { return opts.line.color; },
6767
fillcolormap = typeof opts.fillcolor === 'function' ?
68-
opts.fillcolor : function(){ return opts.fillcolor; };
68+
opts.fillcolor : function() { return opts.fillcolor; };
6969

7070
var l0 = opts.levels.end + opts.levels.size/100,
7171
ls = opts.levels.size,
@@ -84,7 +84,7 @@ module.exports = function draw(gd, id) {
8484
}
8585
}
8686
else {
87-
filllevels = linelevels.map(function(v){
87+
filllevels = linelevels.map(function(v) {
8888
return v-opts.levels.size / 2;
8989
});
9090
filllevels.push(filllevels[filllevels.length - 1] +
@@ -233,7 +233,7 @@ module.exports = function draw(gd, id) {
233233
// now draw the elements
234234
var container = fullLayout._infolayer.selectAll('g.'+id).data([0]);
235235
container.enter().append('g').classed(id,true)
236-
.each(function(){
236+
.each(function() {
237237
var s = d3.select(this);
238238
s.append('rect').classed('cbbg',true);
239239
s.append('g').classed('cbfills',true);
@@ -260,7 +260,7 @@ module.exports = function draw(gd, id) {
260260
Titles.draw(gd, cbAxisOut._id + 'title');
261261
}
262262

263-
function drawAxis(){
263+
function drawAxis() {
264264
if(['top','bottom'].indexOf(opts.titleside)!==-1) {
265265
// squish the axis top to make room for the title
266266
var titleGroup = container.select('.cbtitle'),
@@ -373,7 +373,7 @@ module.exports = function draw(gd, id) {
373373
return Axes.doTicks(gd, cbAxisOut);
374374
}
375375

376-
function positionCB(){
376+
function positionCB() {
377377
// wait for the axis & title to finish rendering before
378378
// continuing positioning
379379
// TODO: why are we redrawing multiple times now with this?

src/components/drawing/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ drawing.setRect = function(s, x, y, w, h) {
4141
s.call(drawing.setPosition, x, y).call(drawing.setSize, w, h);
4242
};
4343

44-
drawing.translatePoints = function(s, xa, ya){
45-
s.each(function(d){
44+
drawing.translatePoints = function(s, xa, ya) {
45+
s.each(function(d) {
4646
// put xp and yp into d if pixel scaling is already done
4747
var x = d.xp || xa.c2p(d.x),
4848
y = d.yp || ya.c2p(d.y),
@@ -77,7 +77,7 @@ drawing.crispRound = function(td, lineWidth, dflt) {
7777

7878
drawing.lineGroupStyle = function(s, lw, lc, ld) {
7979
s.style('fill','none')
80-
.each(function(d){
80+
.each(function(d) {
8181
var line = (((d||[])[0]||{}).trace||{}).line||{},
8282
lw1 = lw||line.width||0,
8383
dash = ld||line.dash||'';
@@ -111,7 +111,7 @@ drawing.dashLine = function(s, dash, lineWidth) {
111111

112112
drawing.fillGroupStyle = function(s) {
113113
s.style('stroke-width',0)
114-
.each(function(d){
114+
.each(function(d) {
115115
var shape = d3.select(this);
116116
try {
117117
shape.call(Plotly.Color.fill, d[0].trace.fillcolor);
@@ -203,7 +203,7 @@ drawing.pointStyle = function(s, trace) {
203203
return drawing.symbolFuncs[xBase](r) +
204204
(x >= 200 ? DOTPATH : '');
205205
})
206-
.style('opacity',function(d){
206+
.style('opacity',function(d) {
207207
return (d.mo+1 || marker.opacity+1) - 1;
208208
});
209209
}
@@ -213,7 +213,7 @@ drawing.pointStyle = function(s, trace) {
213213
markerScale = drawing.tryColorscale(marker, markerIn, ''),
214214
lineScale = drawing.tryColorscale(marker, markerIn, 'line.');
215215

216-
s.each(function(d){
216+
s.each(function(d) {
217217
// 'so' is suspected outliers, for box plots
218218
var fillColor,
219219
lineColor,
@@ -299,7 +299,7 @@ drawing.tryColorscale = function(cont, contIn, prefix) {
299299
var TEXTOFFSETSIGN = {start: 1, end: -1, middle: 0, bottom: 1, top: -1},
300300
LINEEXPAND = 1.3;
301301
drawing.textPointStyle = function(s, trace) {
302-
s.each(function(d){
302+
s.each(function(d) {
303303
var p = d3.select(this),
304304
text = d.tx || trace.text;
305305
if(!text || Array.isArray(text)) {

src/components/errorbars/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ errorBars.plot = function(gd, plotinfo, cd) {
7070
.data(cd)
7171
.enter().append('g')
7272
.attr('class','errorbars')
73-
.each(function(d){
73+
.each(function(d) {
7474
var trace = d[0].trace,
7575
xObj = trace.error_x,
7676
yObj = trace.error_y,
@@ -82,15 +82,15 @@ errorBars.plot = function(gd, plotinfo, cd) {
8282
d3.select(this).selectAll('g')
8383
.data(Lib.identity)
8484
.enter().append('g')
85-
.each(function(d){
85+
.each(function(d) {
8686
coords = errorcoords(d, xa, ya);
8787
var eb = d3.select(this),
8888
path;
8989
if(sparse && !d.vis) return;
9090

9191
if(yObj.visible && isNumeric(coords.x) &&
9292
isNumeric(coords.yh) &&
93-
isNumeric(coords.ys)){
93+
isNumeric(coords.ys)) {
9494
var yw = yObj.width;
9595
path = 'M'+(coords.x-yw)+','+coords.yh+'h'+(2*yw) + // hat
9696
'm-'+yw+',0V'+coords.ys; // bar
@@ -102,7 +102,7 @@ errorBars.plot = function(gd, plotinfo, cd) {
102102
}
103103
if(xObj.visible && isNumeric(coords.y) &&
104104
isNumeric(coords.xh) &&
105-
isNumeric(coords.xs)){
105+
isNumeric(coords.xs)) {
106106
var xw = (xObj.copy_ystyle ? yObj : xObj).width;
107107
path = 'M'+coords.xh+','+(coords.y-xw)+'v'+(2*xw) + // hat
108108
'm0,-'+xw+'H'+coords.xs; // bar
@@ -116,8 +116,8 @@ errorBars.plot = function(gd, plotinfo, cd) {
116116
});
117117
};
118118

119-
errorBars.style = function(gd){
120-
d3.select(gd).selectAll('g.errorbars').each(function(d){
119+
errorBars.style = function(gd) {
120+
d3.select(gd).selectAll('g.errorbars').each(function(d) {
121121
var eb = d3.select(this),
122122
trace = d[0].trace,
123123
yObj = trace.error_y||{},

0 commit comments

Comments
 (0)