Skip to content

Commit

Permalink
enforce "camelcase": [2, {"properties": "never"}] eslint rule
Browse files Browse the repository at this point in the history
  • Loading branch information
etpinard committed Dec 24, 2018
1 parent 18c70a4 commit e3d23e9
Show file tree
Hide file tree
Showing 16 changed files with 102 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"max-len": [0, 80],
"brace-style": [0, "stroustrup", {"allowSingleLine": true}],
"curly": [2, "multi-line"],
"camelcase": [0, {"properties": "never"}],
"camelcase": [2, {"properties": "never"}],
"comma-spacing": [2, {"before": false, "after": true}],
"comma-style": [2, "last"],
"semi": [2],
Expand Down
24 changes: 12 additions & 12 deletions src/lib/geometry2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ exports.segmentDistance = function segmentDistance(x1, y1, x2, y2, x3, y3, x4, y
var y12 = y2 - y1;
var x34 = x4 - x3;
var y34 = y4 - y3;
var l2_12 = x12 * x12 + y12 * y12;
var l2_34 = x34 * x34 + y34 * y34;
var ll12 = x12 * x12 + y12 * y12;
var ll34 = x34 * x34 + y34 * y34;

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

return Math.sqrt(dist2);
Expand All @@ -63,15 +63,15 @@ exports.segmentDistance = function segmentDistance(x1, y1, x2, y2, x3, y3, x4, y
* distance squared from segment ab to point c
* [xab, yab] is the vector b-a
* [xac, yac] is the vector c-a
* l2_ab is the length squared of (b-a), just to simplify calculation
* llab is the length squared of (b-a), just to simplify calculation
*/
function perpDistance2(xab, yab, l2_ab, xac, yac) {
var fc_ab = (xac * xab + yac * yab);
if(fc_ab < 0) {
function perpDistance2(xab, yab, llab, xac, yac) {
var fcAB = (xac * xab + yac * yab);
if(fcAB < 0) {
// point c is closer to point a
return xac * xac + yac * yac;
}
else if(fc_ab > l2_ab) {
else if(fcAB > llab) {
// point c is closer to point b
var xbc = xac - xab;
var ybc = yac - yab;
Expand All @@ -80,7 +80,7 @@ function perpDistance2(xab, yab, l2_ab, xac, yac) {
else {
// perpendicular distance is the shortest
var crossProduct = xac * yab - yac * xab;
return crossProduct * crossProduct / l2_ab;
return crossProduct * crossProduct / llab;
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/plots/cartesian/layout_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {

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

var bgColor = Color.combine(plot_bgcolor, layoutOut.paper_bgcolor);
var bgColor = Color.combine(plotBgColor, layoutOut.paper_bgcolor);

var axName, axLetter, axLayoutIn, axLayoutOut;

Expand Down
4 changes: 2 additions & 2 deletions src/plots/geo/zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ function zoomNonClipped(geo, projection) {
function zoomClipped(geo, projection) {
var view = {r: projection.rotate(), k: projection.scale()},
zoom = initZoom(geo, projection),
event = d3_eventDispatch(zoom, 'zoomstart', 'zoom', 'zoomend'),
event = d3eventDispatch(zoom, 'zoomstart', 'zoom', 'zoomend'),
zooming = 0,
zoomOn = zoom.on;

Expand Down Expand Up @@ -440,7 +440,7 @@ function cross(a, b) {
// events have a target component (such as a brush), a target element (such as
// the svg:g element containing the brush) and the standard arguments `d` (the
// target element's data) and `i` (the selection index of the target element).
function d3_eventDispatch(target) {
function d3eventDispatch(target) {
var i = 0,
n = arguments.length,
argumentz = [];
Expand Down
4 changes: 2 additions & 2 deletions src/plots/gl2d/scene2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ proto.updateTraces = function(fullData, calcData) {
this.fullData = fullData;

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

if(fullTrace.uid === oldUid && fullTrace.type === oldTrace.type) {
continue trace_id_loop;
continue traceIdLoop;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/plots/gl3d/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,11 @@ proto.plot = function(sceneData, fullLayout, layout) {
// Remove empty traces
var traceIds = Object.keys(this.traces);

trace_id_loop:
traceIdLoop:
for(i = 0; i < traceIds.length; ++i) {
for(j = 0; j < sceneData.length; ++j) {
if(sceneData[j].uid === traceIds[i] && sceneData[j].visible === true) {
continue trace_id_loop;
continue traceIdLoop;
}
}
trace = this.traces[traceIds[i]];
Expand Down
4 changes: 2 additions & 2 deletions src/plots/mapbox/mapbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,13 @@ proto.updateData = function(calcData) {

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

for(j = 0; j < calcData.length; j++) {
trace = calcData[j][0].trace;
if(id === trace.uid) continue id_loop;
if(id === trace.uid) continue idLoop;
}

traceObj = traceHash[id];
Expand Down
14 changes: 7 additions & 7 deletions src/plots/ternary/ternary.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ proto.updateLayers = function(ternaryLayout) {
toplevel.order();
};

var w_over_h = Math.sqrt(4 / 3);
var whRatio = Math.sqrt(4 / 3);

proto.adjustLayout = function(ternaryLayout, graphSize) {
var _this = this,
Expand All @@ -184,13 +184,13 @@ proto.adjustLayout = function(ternaryLayout, graphSize) {

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

if(wmax > w_over_h * hmax) {
if(wmax > whRatio * hmax) {
h = hmax;
w = h * w_over_h;
w = h * whRatio;
}
else {
w = wmax;
h = w / w_over_h;
h = w / whRatio;
}

xDomainFinal = xDomain * w / wmax;
Expand Down Expand Up @@ -253,7 +253,7 @@ proto.adjustLayout = function(ternaryLayout, graphSize) {
// tickangle = 'auto' means 0 anyway for a y axis, need to coerce to 0 here
// so we can shift by 30.
tickangle: (+ternaryLayout.aaxis.tickangle || 0) - 30,
domain: [yDomain0, yDomain0 + yDomainFinal * w_over_h],
domain: [yDomain0, yDomain0 + yDomainFinal * whRatio],
anchor: 'free',
position: 0,
_id: 'y',
Expand Down Expand Up @@ -282,7 +282,7 @@ proto.adjustLayout = function(ternaryLayout, graphSize) {
range: [sum - amin - bmin, cmin],
side: 'right',
tickangle: (+ternaryLayout.caxis.tickangle || 0) + 30,
domain: [yDomain0, yDomain0 + yDomainFinal * w_over_h],
domain: [yDomain0, yDomain0 + yDomainFinal * whRatio],
anchor: 'free',
position: 0,
_id: 'y',
Expand Down Expand Up @@ -620,7 +620,7 @@ proto.initInteractions = function() {
xCenter = (xLeft + xRight) / 2,
xSpan = xRight - xLeft,
yBottom = (1 - afrac) * _this.h,
yTop = yBottom - xSpan / w_over_h;
yTop = yBottom - xSpan / whRatio;

if(xSpan < constants.MINZOOM) {
mins = mins0;
Expand Down
12 changes: 6 additions & 6 deletions tasks/util/pull_font_svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ module.exports = function pullFontSVG(data, pathOut) {
parser.parseString(data, function(err, result) {
if(err) throw err;

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

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

chars[name] = {
width: Number(glyph.$['horiz-adv-x']) || default_width,
width: Number(glyph.$['horiz-adv-x']) || defaultWidth,
height: ascent - descent,
path: glyph.$.d,
transform: transform,
Expand Down
2 changes: 1 addition & 1 deletion tasks/util/wrap_locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var moduleMarker = 'module.exports = ';
*
* Logs basename of bundle when completed.
*/
module.exports = function wrap_locale(pathToInput, pathToOutput) {
module.exports = function wrapLocale(pathToInput, pathToOutput) {
fs.readFile(pathToInput, 'utf8', function(err, data) {
var moduleStart = data.indexOf(moduleMarker) + moduleMarker.length;
var moduleEnd = data.indexOf(';', moduleStart);
Expand Down
24 changes: 12 additions & 12 deletions test/jasmine/tests/histogram_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1043,11 +1043,11 @@ describe('getBinSpanLabelRound', function() {
var cn8i = Lib.dateTime2ms('1995-08i-01', cn);
var cn9 = Lib.dateTime2ms('1995-09-01', cn);

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

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

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

_test(0, 353 * day, [cn1_00, cn1_10, cn1_20], cn,
[cn1_00, Lib.dateTime2ms('2009-01-01', cn), cn1_10, Lib.dateTime2ms('2019-01-01', cn)]);
_test(0, 353 * day, [cn1x00, cn1x10, cn1x20], cn,
[cn1x00, Lib.dateTime2ms('2009-01-01', cn), cn1x10, Lib.dateTime2ms('2019-01-01', cn)]);
// occasionally we give extra precision for world dates (month when it should be year
// or day when it should be month). That's better than doing the opposite... not going
// to fix now, too many edge cases, better not to complicate the logic for them all.
_test(176 * day, 177 * day, [cn1_00 - 176 * day, cn1_10 - 176 * day, cn1_20 - 176 * day], cn, [
_test(176 * day, 177 * day, [cn1x00 - 176 * day, cn1x10 - 176 * day, cn1x20 - 176 * day], cn, [
Lib.dateTime2ms('1999-08-01', cn), Lib.dateTime2ms('2009-07-01', cn),
Lib.dateTime2ms('2009-08-01', cn), Lib.dateTime2ms('2019-07-01', cn)
]);
Expand Down
16 changes: 8 additions & 8 deletions test/jasmine/tests/hover_spikeline_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ describe('spikeline hover', function() {
Lib.clearThrottle();
}

function _set_hovermode(hovermode) {
function _setHovermode(hovermode) {
return Plotly.relayout(gd, 'hovermode', hovermode);
}

function _set_spikedistance(spikedistance) {
function _setSpikedistance(spikedistance) {
return Plotly.relayout(gd, 'spikedistance', spikedistance);
}

Expand Down Expand Up @@ -165,7 +165,7 @@ describe('spikeline hover', function() {

Plotly.plot(gd, _mock)
.then(function() {
_set_spikedistance(200);
_setSpikedistance(200);
})
.then(function() {
_hover({xpx: 120, ypx: 180});
Expand Down Expand Up @@ -200,7 +200,7 @@ describe('spikeline hover', function() {
[]
);

_set_hovermode('x');
_setHovermode('x');
})
.then(function() {
_hover({xval: 2, yval: 3});
Expand Down Expand Up @@ -235,7 +235,7 @@ describe('spikeline hover', function() {
[]
);

_set_spikedistance(200);
_setSpikedistance(200);
})
.then(function() {
_hover({xval: 1.6, yval: 2.6});
Expand Down Expand Up @@ -271,7 +271,7 @@ describe('spikeline hover', function() {
[]
);

_set_spikedistance(-1);
_setSpikedistance(-1);
})
.then(function() {
_hover({xval: 1.6, yval: 2.6});
Expand Down Expand Up @@ -307,7 +307,7 @@ describe('spikeline hover', function() {
[]
);

_set_spikedistance(0);
_setSpikedistance(0);
})
.then(function() {
_hover({xval: 2, yval: 3});
Expand Down Expand Up @@ -365,7 +365,7 @@ describe('spikeline hover', function() {
type: 'bar', y: [2, 1]
}], spikeLayout())
.then(_assertBarSpikes)
.then(function() { _set_hovermode('closest'); })
.then(function() { _setHovermode('closest'); })
.then(_assertBarSpikes)
.catch(failTest)
.then(done);
Expand Down
Loading

0 comments on commit e3d23e9

Please sign in to comment.