Skip to content

Commit e3d23e9

Browse files
committed
enforce "camelcase": [2, {"properties": "never"}] eslint rule
1 parent 18c70a4 commit e3d23e9

16 files changed

+102
-105
lines changed

.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"max-len": [0, 80],
3030
"brace-style": [0, "stroustrup", {"allowSingleLine": true}],
3131
"curly": [2, "multi-line"],
32-
"camelcase": [0, {"properties": "never"}],
32+
"camelcase": [2, {"properties": "never"}],
3333
"comma-spacing": [2, {"before": false, "after": true}],
3434
"comma-style": [2, "last"],
3535
"semi": [2],

src/lib/geometry2d.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ exports.segmentDistance = function segmentDistance(x1, y1, x2, y2, x3, y3, x4, y
4545
var y12 = y2 - y1;
4646
var x34 = x4 - x3;
4747
var y34 = y4 - y3;
48-
var l2_12 = x12 * x12 + y12 * y12;
49-
var l2_34 = x34 * x34 + y34 * y34;
48+
var ll12 = x12 * x12 + y12 * y12;
49+
var ll34 = x34 * x34 + y34 * y34;
5050

5151
// calculate distance squared, then take the sqrt at the very end
5252
var dist2 = Math.min(
53-
perpDistance2(x12, y12, l2_12, x3 - x1, y3 - y1),
54-
perpDistance2(x12, y12, l2_12, x4 - x1, y4 - y1),
55-
perpDistance2(x34, y34, l2_34, x1 - x3, y1 - y3),
56-
perpDistance2(x34, y34, l2_34, x2 - x3, y2 - y3)
53+
perpDistance2(x12, y12, ll12, x3 - x1, y3 - y1),
54+
perpDistance2(x12, y12, ll12, x4 - x1, y4 - y1),
55+
perpDistance2(x34, y34, ll34, x1 - x3, y1 - y3),
56+
perpDistance2(x34, y34, ll34, x2 - x3, y2 - y3)
5757
);
5858

5959
return Math.sqrt(dist2);
@@ -63,15 +63,15 @@ exports.segmentDistance = function segmentDistance(x1, y1, x2, y2, x3, y3, x4, y
6363
* distance squared from segment ab to point c
6464
* [xab, yab] is the vector b-a
6565
* [xac, yac] is the vector c-a
66-
* l2_ab is the length squared of (b-a), just to simplify calculation
66+
* llab is the length squared of (b-a), just to simplify calculation
6767
*/
68-
function perpDistance2(xab, yab, l2_ab, xac, yac) {
69-
var fc_ab = (xac * xab + yac * yab);
70-
if(fc_ab < 0) {
68+
function perpDistance2(xab, yab, llab, xac, yac) {
69+
var fcAB = (xac * xab + yac * yab);
70+
if(fcAB < 0) {
7171
// point c is closer to point a
7272
return xac * xac + yac * yac;
7373
}
74-
else if(fc_ab > l2_ab) {
74+
else if(fcAB > llab) {
7575
// point c is closer to point b
7676
var xbc = xac - xab;
7777
var ybc = yac - yab;
@@ -80,7 +80,7 @@ function perpDistance2(xab, yab, l2_ab, xac, yac) {
8080
else {
8181
// perpendicular distance is the shortest
8282
var crossProduct = xac * yab - yac * xab;
83-
return crossProduct * crossProduct / l2_ab;
83+
return crossProduct * crossProduct / llab;
8484
}
8585
}
8686

src/plots/cartesian/layout_defaults.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
102102

103103
// plot_bgcolor only makes sense if there's a (2D) plot!
104104
// TODO: bgcolor for each subplot, to inherit from the main one
105-
var plot_bgcolor = Color.background;
105+
var plotBgColor = Color.background;
106106
if(xIds.length && yIds.length) {
107-
plot_bgcolor = Lib.coerce(layoutIn, layoutOut, basePlotLayoutAttributes, 'plot_bgcolor');
107+
plotBgColor = Lib.coerce(layoutIn, layoutOut, basePlotLayoutAttributes, 'plot_bgcolor');
108108
}
109109

110-
var bgColor = Color.combine(plot_bgcolor, layoutOut.paper_bgcolor);
110+
var bgColor = Color.combine(plotBgColor, layoutOut.paper_bgcolor);
111111

112112
var axName, axLetter, axLayoutIn, axLayoutOut;
113113

src/plots/geo/zoom.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ function zoomNonClipped(geo, projection) {
192192
function zoomClipped(geo, projection) {
193193
var view = {r: projection.rotate(), k: projection.scale()},
194194
zoom = initZoom(geo, projection),
195-
event = d3_eventDispatch(zoom, 'zoomstart', 'zoom', 'zoomend'),
195+
event = d3eventDispatch(zoom, 'zoomstart', 'zoom', 'zoomend'),
196196
zooming = 0,
197197
zoomOn = zoom.on;
198198

@@ -440,7 +440,7 @@ function cross(a, b) {
440440
// events have a target component (such as a brush), a target element (such as
441441
// the svg:g element containing the brush) and the standard arguments `d` (the
442442
// target element's data) and `i` (the selection index of the target element).
443-
function d3_eventDispatch(target) {
443+
function d3eventDispatch(target) {
444444
var i = 0,
445445
n = arguments.length,
446446
argumentz = [];

src/plots/gl2d/scene2d.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ proto.updateTraces = function(fullData, calcData) {
489489
this.fullData = fullData;
490490

491491
// remove empty traces
492-
trace_id_loop:
492+
traceIdLoop:
493493
for(i = 0; i < traceIds.length; i++) {
494494
var oldUid = traceIds[i],
495495
oldTrace = this.traces[oldUid];
@@ -498,7 +498,7 @@ proto.updateTraces = function(fullData, calcData) {
498498
fullTrace = fullData[j];
499499

500500
if(fullTrace.uid === oldUid && fullTrace.type === oldTrace.type) {
501-
continue trace_id_loop;
501+
continue traceIdLoop;
502502
}
503503
}
504504

src/plots/gl3d/scene.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -474,11 +474,11 @@ proto.plot = function(sceneData, fullLayout, layout) {
474474
// Remove empty traces
475475
var traceIds = Object.keys(this.traces);
476476

477-
trace_id_loop:
477+
traceIdLoop:
478478
for(i = 0; i < traceIds.length; ++i) {
479479
for(j = 0; j < sceneData.length; ++j) {
480480
if(sceneData[j].uid === traceIds[i] && sceneData[j].visible === true) {
481-
continue trace_id_loop;
481+
continue traceIdLoop;
482482
}
483483
}
484484
trace = this.traces[traceIds[i]];

src/plots/mapbox/mapbox.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,13 @@ proto.updateData = function(calcData) {
292292

293293
// remove empty trace objects
294294
var ids = Object.keys(traceHash);
295-
id_loop:
295+
idLoop:
296296
for(i = 0; i < ids.length; i++) {
297297
var id = ids[i];
298298

299299
for(j = 0; j < calcData.length; j++) {
300300
trace = calcData[j][0].trace;
301-
if(id === trace.uid) continue id_loop;
301+
if(id === trace.uid) continue idLoop;
302302
}
303303

304304
traceObj = traceHash[id];

src/plots/ternary/ternary.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ proto.updateLayers = function(ternaryLayout) {
166166
toplevel.order();
167167
};
168168

169-
var w_over_h = Math.sqrt(4 / 3);
169+
var whRatio = Math.sqrt(4 / 3);
170170

171171
proto.adjustLayout = function(ternaryLayout, graphSize) {
172172
var _this = this,
@@ -184,13 +184,13 @@ proto.adjustLayout = function(ternaryLayout, graphSize) {
184184

185185
var x0, y0, w, h, xDomainFinal, yDomainFinal;
186186

187-
if(wmax > w_over_h * hmax) {
187+
if(wmax > whRatio * hmax) {
188188
h = hmax;
189-
w = h * w_over_h;
189+
w = h * whRatio;
190190
}
191191
else {
192192
w = wmax;
193-
h = w / w_over_h;
193+
h = w / whRatio;
194194
}
195195

196196
xDomainFinal = xDomain * w / wmax;
@@ -253,7 +253,7 @@ proto.adjustLayout = function(ternaryLayout, graphSize) {
253253
// tickangle = 'auto' means 0 anyway for a y axis, need to coerce to 0 here
254254
// so we can shift by 30.
255255
tickangle: (+ternaryLayout.aaxis.tickangle || 0) - 30,
256-
domain: [yDomain0, yDomain0 + yDomainFinal * w_over_h],
256+
domain: [yDomain0, yDomain0 + yDomainFinal * whRatio],
257257
anchor: 'free',
258258
position: 0,
259259
_id: 'y',
@@ -282,7 +282,7 @@ proto.adjustLayout = function(ternaryLayout, graphSize) {
282282
range: [sum - amin - bmin, cmin],
283283
side: 'right',
284284
tickangle: (+ternaryLayout.caxis.tickangle || 0) + 30,
285-
domain: [yDomain0, yDomain0 + yDomainFinal * w_over_h],
285+
domain: [yDomain0, yDomain0 + yDomainFinal * whRatio],
286286
anchor: 'free',
287287
position: 0,
288288
_id: 'y',
@@ -620,7 +620,7 @@ proto.initInteractions = function() {
620620
xCenter = (xLeft + xRight) / 2,
621621
xSpan = xRight - xLeft,
622622
yBottom = (1 - afrac) * _this.h,
623-
yTop = yBottom - xSpan / w_over_h;
623+
yTop = yBottom - xSpan / whRatio;
624624

625625
if(xSpan < constants.MINZOOM) {
626626
mins = mins0;

tasks/util/pull_font_svg.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ module.exports = function pullFontSVG(data, pathOut) {
88
parser.parseString(data, function(err, result) {
99
if(err) throw err;
1010

11-
var font_obj = result.svg.defs[0].font[0],
12-
default_width = Number(font_obj.$['horiz-adv-x']),
13-
ascent = Number(font_obj['font-face'][0].$.ascent),
14-
descent = Number(font_obj['font-face'][0].$.descent),
11+
var fontObj = result.svg.defs[0].font[0],
12+
defaultWidth = Number(fontObj.$['horiz-adv-x']),
13+
ascent = Number(fontObj['font-face'][0].$.ascent),
14+
descent = Number(fontObj['font-face'][0].$.descent),
1515
chars = {};
1616

17-
font_obj.glyph.forEach(function(glyph) {
17+
fontObj.glyph.forEach(function(glyph) {
1818
var name = glyph.$['glyph-name'],
1919
transform = name === 'spikeline' ?
2020
'matrix(1.5 0 0 -1.5 0 ' + ascent + ')' :
2121
'matrix(1 0 0 -1 0 ' + ascent + ')';
2222

2323
chars[name] = {
24-
width: Number(glyph.$['horiz-adv-x']) || default_width,
24+
width: Number(glyph.$['horiz-adv-x']) || defaultWidth,
2525
height: ascent - descent,
2626
path: glyph.$.d,
2727
transform: transform,

tasks/util/wrap_locale.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var moduleMarker = 'module.exports = ';
1818
*
1919
* Logs basename of bundle when completed.
2020
*/
21-
module.exports = function wrap_locale(pathToInput, pathToOutput) {
21+
module.exports = function wrapLocale(pathToInput, pathToOutput) {
2222
fs.readFile(pathToInput, 'utf8', function(err, data) {
2323
var moduleStart = data.indexOf(moduleMarker) + moduleMarker.length;
2424
var moduleEnd = data.indexOf(';', moduleStart);

test/jasmine/tests/histogram_test.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -1043,11 +1043,11 @@ describe('getBinSpanLabelRound', function() {
10431043
var cn8i = Lib.dateTime2ms('1995-08i-01', cn);
10441044
var cn9 = Lib.dateTime2ms('1995-09-01', cn);
10451045

1046-
var cn1_00 = Lib.dateTime2ms('2000-01-01', cn);
1047-
var cn1_01 = Lib.dateTime2ms('2001-01-01', cn);
1048-
var cn1_02 = Lib.dateTime2ms('2002-01-01', cn);
1049-
var cn1_10 = Lib.dateTime2ms('2010-01-01', cn);
1050-
var cn1_20 = Lib.dateTime2ms('2020-01-01', cn);
1046+
var cn1x00 = Lib.dateTime2ms('2000-01-01', cn);
1047+
var cn1x01 = Lib.dateTime2ms('2001-01-01', cn);
1048+
var cn1x02 = Lib.dateTime2ms('2002-01-01', cn);
1049+
var cn1x10 = Lib.dateTime2ms('2010-01-01', cn);
1050+
var cn1x20 = Lib.dateTime2ms('2020-01-01', cn);
10511051

10521052
_test(100, 2000, [cn8i, cn8i + 10000, cn8i + 20000], cn,
10531053
[cn8i, cn8i + 9000, cn8i + 10000, cn8i + 19000]);
@@ -1059,17 +1059,17 @@ describe('getBinSpanLabelRound', function() {
10591059
_test(12 * hr, 12 * hr, [cn8 - 12 * hr, cn8i - 12 * hr, cn9 - 12 * hr], cn,
10601060
[cn8, cn8i - day, cn8i, cn9 - day]);
10611061

1062-
_test(0, 28 * day, [cn1_00, cn1_01, cn1_02], cn,
1063-
[cn1_00, Lib.dateTime2ms('2000-12-01', cn), cn1_01, Lib.dateTime2ms('2001-12-01', cn)]);
1064-
_test(14 * day, 14 * day, [cn1_00 - 14 * day, cn1_01 - 14 * day, cn1_02 - 14 * day], cn,
1065-
[cn1_00, Lib.dateTime2ms('2000-12-01', cn), cn1_01, Lib.dateTime2ms('2001-12-01', cn)]);
1062+
_test(0, 28 * day, [cn1x00, cn1x01, cn1x02], cn,
1063+
[cn1x00, Lib.dateTime2ms('2000-12-01', cn), cn1x01, Lib.dateTime2ms('2001-12-01', cn)]);
1064+
_test(14 * day, 14 * day, [cn1x00 - 14 * day, cn1x01 - 14 * day, cn1x02 - 14 * day], cn,
1065+
[cn1x00, Lib.dateTime2ms('2000-12-01', cn), cn1x01, Lib.dateTime2ms('2001-12-01', cn)]);
10661066

1067-
_test(0, 353 * day, [cn1_00, cn1_10, cn1_20], cn,
1068-
[cn1_00, Lib.dateTime2ms('2009-01-01', cn), cn1_10, Lib.dateTime2ms('2019-01-01', cn)]);
1067+
_test(0, 353 * day, [cn1x00, cn1x10, cn1x20], cn,
1068+
[cn1x00, Lib.dateTime2ms('2009-01-01', cn), cn1x10, Lib.dateTime2ms('2019-01-01', cn)]);
10691069
// occasionally we give extra precision for world dates (month when it should be year
10701070
// or day when it should be month). That's better than doing the opposite... not going
10711071
// to fix now, too many edge cases, better not to complicate the logic for them all.
1072-
_test(176 * day, 177 * day, [cn1_00 - 176 * day, cn1_10 - 176 * day, cn1_20 - 176 * day], cn, [
1072+
_test(176 * day, 177 * day, [cn1x00 - 176 * day, cn1x10 - 176 * day, cn1x20 - 176 * day], cn, [
10731073
Lib.dateTime2ms('1999-08-01', cn), Lib.dateTime2ms('2009-07-01', cn),
10741074
Lib.dateTime2ms('2009-08-01', cn), Lib.dateTime2ms('2019-07-01', cn)
10751075
]);

test/jasmine/tests/hover_spikeline_test.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ describe('spikeline hover', function() {
3737
Lib.clearThrottle();
3838
}
3939

40-
function _set_hovermode(hovermode) {
40+
function _setHovermode(hovermode) {
4141
return Plotly.relayout(gd, 'hovermode', hovermode);
4242
}
4343

44-
function _set_spikedistance(spikedistance) {
44+
function _setSpikedistance(spikedistance) {
4545
return Plotly.relayout(gd, 'spikedistance', spikedistance);
4646
}
4747

@@ -165,7 +165,7 @@ describe('spikeline hover', function() {
165165

166166
Plotly.plot(gd, _mock)
167167
.then(function() {
168-
_set_spikedistance(200);
168+
_setSpikedistance(200);
169169
})
170170
.then(function() {
171171
_hover({xpx: 120, ypx: 180});
@@ -200,7 +200,7 @@ describe('spikeline hover', function() {
200200
[]
201201
);
202202

203-
_set_hovermode('x');
203+
_setHovermode('x');
204204
})
205205
.then(function() {
206206
_hover({xval: 2, yval: 3});
@@ -235,7 +235,7 @@ describe('spikeline hover', function() {
235235
[]
236236
);
237237

238-
_set_spikedistance(200);
238+
_setSpikedistance(200);
239239
})
240240
.then(function() {
241241
_hover({xval: 1.6, yval: 2.6});
@@ -271,7 +271,7 @@ describe('spikeline hover', function() {
271271
[]
272272
);
273273

274-
_set_spikedistance(-1);
274+
_setSpikedistance(-1);
275275
})
276276
.then(function() {
277277
_hover({xval: 1.6, yval: 2.6});
@@ -307,7 +307,7 @@ describe('spikeline hover', function() {
307307
[]
308308
);
309309

310-
_set_spikedistance(0);
310+
_setSpikedistance(0);
311311
})
312312
.then(function() {
313313
_hover({xval: 2, yval: 3});
@@ -365,7 +365,7 @@ describe('spikeline hover', function() {
365365
type: 'bar', y: [2, 1]
366366
}], spikeLayout())
367367
.then(_assertBarSpikes)
368-
.then(function() { _set_hovermode('closest'); })
368+
.then(function() { _setHovermode('closest'); })
369369
.then(_assertBarSpikes)
370370
.catch(failTest)
371371
.then(done);

0 commit comments

Comments
 (0)