Skip to content

Linter enforcers #294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"rules": {
"no-trailing-spaces": [2],
"no-multiple-empty-lines": [2, {"max": 3, "maxEOF": 1}],
"no-multiple-empty-lines": [2, {"max": 2, "maxEOF": 1}],
"linebreak-style": [2, "unix"],
"indent": [2, 4, {"SwitchCase": 1}],
"max-len": [0, 80],
Expand All @@ -19,10 +19,18 @@
"comma-style": [2, "last"],
"semi": [2],
"semi-spacing": [2, {"before": false, "after": true}],
"key-spacing": [0, {"beforeColon": false, "afterColon": true}],
"key-spacing": [2, {"beforeColon": false, "afterColon": true}],
"keyword-spacing": [2, {"overrides": {
"if": {"after": false},
"for": {"after": false},
"while": {"after": false},
"switch": {"after": false},
"catch": {"after": false}
}}],
"no-spaced-func": [2],
"space-in-parens": [2, "never"],
"space-before-function-paren": [2, "never"],
"space-before-blocks": [2],
"no-multi-spaces": [2],
"space-infix-ops": [0, {"int32Hint": false}],
"quotes": [2, "single"],
Expand Down
4 changes: 2 additions & 2 deletions devtools/test_dashboard/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ function plotButtons(plots, figDir) {
/*
* Grab the currently loaded plot and make an image - replacing the plot.
*/
if (!gd) return;
if(!gd) return;

var layout = gd.layout;
var data = gd.data;

if (!layout || !data) return;
if(!layout || !data) return;

Plotly.Plots.getSubplotIds(gd._fullLayout, 'gl3d').forEach(function(key) {
var scene = gd._fullLayout[key]._scene;
Expand Down
24 changes: 12 additions & 12 deletions src/components/annotations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ annotations.draw = function(gd, index, opt, value) {
Plotly.Lib.extendFlat({}, value) :
{text: 'New text'};

if (layout.annotations) {
if(layout.annotations) {
layout.annotations.splice(index, 0, rule);
} else {
layout.annotations = [rule];
Expand Down Expand Up @@ -363,7 +363,7 @@ annotations.draw = function(gd, index, opt, value) {
.attr('data-unformatted', options.text)
.text(options.text);

function textLayout(s){
function textLayout(s) {
s.call(Plotly.Drawing.font, font)
.attr({
'text-anchor': {
Expand All @@ -375,7 +375,7 @@ annotations.draw = function(gd, index, opt, value) {
return s;
}

function drawGraphicalElements(){
function drawGraphicalElements() {

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

function shiftFraction(v, anchor){
if(anchor==='auto'){
function shiftFraction(v, anchor) {
if(anchor==='auto') {
if(v < 1/3) anchor = 'left';
else if(v > 2/3) anchor = 'right';
else anchor = 'center';
Expand Down Expand Up @@ -469,7 +469,7 @@ annotations.draw = function(gd, index, opt, value) {

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

// add the arrow
// uses options[arrowwidth,arrowcolor,arrowhead] for styling
var drawArrow = function(dx, dy){
var drawArrow = function(dx, dy) {
d3.select(gd)
.selectAll('.annotation-arrow-g[data-index="' + index + '"]')
.remove();
Expand Down Expand Up @@ -541,7 +541,7 @@ annotations.draw = function(gd, index, opt, value) {
return;
}

edges.forEach(function(x){
edges.forEach(function(x) {
var p = lineIntersect(arrowX0, arrowY0, arrowX, arrowY,
x[0], x[1], x[2], x[3]);
if(p) {
Expand Down Expand Up @@ -572,7 +572,7 @@ annotations.draw = function(gd, index, opt, value) {
.attr({
'data-index': String(index),
d: 'M3,3H-3V-3H3ZM0,0L' + (arrowX0-arrowX) + ',' + (arrowY0-arrowY),
transform:'translate('+arrowX+','+arrowY+')'
transform: 'translate('+arrowX+','+arrowY+')'
})
.style('stroke-width', (strokewidth+6)+'px')
.call(Plotly.Color.stroke, 'rgba(0,0,0,0)')
Expand Down Expand Up @@ -711,7 +711,7 @@ annotations.draw = function(gd, index, opt, value) {
if(gd._context.editable) {
anntext.call(Plotly.util.makeEditable, ann)
.call(textLayout)
.on('edit', function(_text){
.on('edit', function(_text) {
options.text = _text;
this.attr({'data-unformatted': options.text});
this.call(textLayout);
Expand Down Expand Up @@ -839,7 +839,7 @@ annotations.calcAutorange = function(gd) {
if(!annotationList.length || !gd._fullData.length) return;

var annotationAxes = {};
annotationList.forEach(function(ann){
annotationList.forEach(function(ann) {
annotationAxes[ann.xref] = true;
annotationAxes[ann.yref] = true;
});
Expand All @@ -863,7 +863,7 @@ function annAutorange(gd) {
// relative to their anchor points
// use the arrow and the text bg rectangle,
// as the whole anno may include hidden text in its bbox
fullLayout.annotations.forEach(function(ann){
fullLayout.annotations.forEach(function(ann) {
var xa = Plotly.Axes.getFromId(gd, ann.xref),
ya = Plotly.Axes.getFromId(gd, ann.yref);
if(!(xa || ya)) return;
Expand Down
14 changes: 7 additions & 7 deletions src/components/color/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ color.addOpacity = function(cstr, op) {
// combine two colors into one apparent color
// if back has transparency or is missing,
// color.background is assumed behind it
color.combine = function(front, back){
color.combine = function(front, back) {
var fc = tinycolor(front).toRgb();
if(fc.a===1) return tinycolor(front).toRgbString();

var bc = tinycolor(back||color.background).toRgb(),
bcflat = bc.a===1 ? bc : {
r:255*(1-bc.a) + bc.r*bc.a,
g:255*(1-bc.a) + bc.g*bc.a,
b:255*(1-bc.a) + bc.b*bc.a
r: 255 * (1-bc.a) + bc.r*bc.a,
g: 255 * (1-bc.a) + bc.g*bc.a,
b: 255 * (1-bc.a) + bc.b*bc.a
},
fcflat = {
r:bcflat.r*(1-fc.a) + fc.r*fc.a,
g:bcflat.g*(1-fc.a) + fc.g*fc.a,
b:bcflat.b*(1-fc.a) + fc.b*fc.a
r: bcflat.r*(1-fc.a) + fc.r*fc.a,
g: bcflat.g*(1-fc.a) + fc.g*fc.a,
b: bcflat.b*(1-fc.a) + fc.b*fc.a
};
return tinycolor(fcflat).toRgbString();
};
Expand Down
26 changes: 13 additions & 13 deletions src/components/colorbar/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = function draw(gd, id) {
// evaluated halfway between levels
opts.filllevels = null;

function component(){
function component() {
var fullLayout = gd._fullLayout;
if((typeof opts.fillcolor !== 'function') &&
(typeof opts.line.color !== 'function')) {
Expand All @@ -63,9 +63,9 @@ module.exports = function draw(gd, id) {
filllevels = [],
l,
linecolormap = typeof opts.line.color === 'function' ?
opts.line.color : function(){ return opts.line.color; },
opts.line.color : function() { return opts.line.color; },
fillcolormap = typeof opts.fillcolor === 'function' ?
opts.fillcolor : function(){ return opts.fillcolor; };
opts.fillcolor : function() { return opts.fillcolor; };

var l0 = opts.levels.end + opts.levels.size/100,
ls = opts.levels.size,
Expand All @@ -84,7 +84,7 @@ module.exports = function draw(gd, id) {
}
}
else {
filllevels = linelevels.map(function(v){
filllevels = linelevels.map(function(v) {
return v-opts.levels.size / 2;
});
filllevels.push(filllevels[filllevels.length - 1] +
Expand Down Expand Up @@ -132,7 +132,7 @@ module.exports = function draw(gd, id) {

// y positioning we can do correctly from the start
yBottomFrac = opts.y + lenFrac *
(({top:-0.5, bottom:0.5}[opts.yanchor]||0)-0.5),
(({top: -0.5, bottom: 0.5}[opts.yanchor] || 0) - 0.5),
yBottomPx = Math.round(fullLayout._size.h * (1-yBottomFrac)),
yTopPx = yBottomPx-lenPx,
titleEl,
Expand Down Expand Up @@ -233,7 +233,7 @@ module.exports = function draw(gd, id) {
// now draw the elements
var container = fullLayout._infolayer.selectAll('g.'+id).data([0]);
container.enter().append('g').classed(id,true)
.each(function(){
.each(function() {
var s = d3.select(this);
s.append('rect').classed('cbbg',true);
s.append('g').classed('cbfills',true);
Expand All @@ -260,7 +260,7 @@ module.exports = function draw(gd, id) {
Titles.draw(gd, cbAxisOut._id + 'title');
}

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

function positionCB(){
function positionCB() {
// wait for the axis & title to finish rendering before
// continuing positioning
// TODO: why are we redrawing multiple times now with this?
Expand Down Expand Up @@ -431,7 +431,7 @@ module.exports = function draw(gd, id) {
});

// fix positioning for xanchor!='left'
var xoffset = ({center:0.5, right:1}[opts.xanchor]||0) *
var xoffset = ({center: 0.5, right: 1}[opts.xanchor] || 0) *
outerwidth;
container.attr('transform',
'translate('+(fullLayout._size.l-xoffset)+','+fullLayout._size.t+')');
Expand All @@ -440,10 +440,10 @@ module.exports = function draw(gd, id) {
Plots.autoMargin(gd, id,{
x: opts.x,
y: opts.y,
l: outerwidth*({right:1, center:0.5}[opts.xanchor]||0),
r: outerwidth*({left:1, center:0.5}[opts.xanchor]||0),
t: outerheight*({bottom:1, middle:0.5}[opts.yanchor]||0),
b: outerheight*({top:1, middle:0.5}[opts.yanchor]||0)
l: outerwidth * ({right: 1, center: 0.5}[opts.xanchor] || 0),
r: outerwidth * ({left: 1, center: 0.5}[opts.xanchor] || 0),
t: outerheight * ({bottom: 1, middle: 0.5}[opts.yanchor] || 0),
b: outerheight * ({top: 1, middle: 0.5}[opts.yanchor] || 0)
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/colorscale/is_valid_scale_array.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = function isValidScaleArray(scl) {
if(!Array.isArray(scl)) return false;
else {
if(+scl[0][0]!==0 || +scl[scl.length-1][0]!==1) return false;
for (var i = 0; i < scl.length; i++) {
for(var i = 0; i < scl.length; i++) {
si = scl[i];
if(si.length!==2 || +si[0]<highestVal || !tinycolor(si[1]).isValid()) {
isValid = false;
Expand Down
28 changes: 14 additions & 14 deletions src/components/colorscale/scales.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@


module.exports = {
'Greys':[[0,'rgb(0,0,0)'],[1,'rgb(255,255,255)']],
'Greys': [[0,'rgb(0,0,0)'],[1,'rgb(255,255,255)']],

'YIGnBu':[[0,'rgb(8, 29, 88)'],[0.125,'rgb(37, 52, 148)'],
'YIGnBu': [[0,'rgb(8, 29, 88)'],[0.125,'rgb(37, 52, 148)'],
[0.25,'rgb(34, 94, 168)'],[0.375,'rgb(29, 145, 192)'],
[0.5,'rgb(65, 182, 196)'],[0.625,'rgb(127, 205, 187)'],
[0.75,'rgb(199, 233, 180)'],[0.875,'rgb(237, 248, 217)'],
[1,'rgb(255, 255, 217)']],

'Greens':[[0,'rgb(0, 68, 27)'],[0.125,'rgb(0, 109, 44)'],
'Greens': [[0,'rgb(0, 68, 27)'],[0.125,'rgb(0, 109, 44)'],
[0.25,'rgb(35, 139, 69)'],[0.375,'rgb(65, 171, 93)'],
[0.5,'rgb(116, 196, 118)'],[0.625,'rgb(161, 217, 155)'],
[0.75,'rgb(199, 233, 192)'],[0.875,'rgb(229, 245, 224)'],
[1,'rgb(247, 252, 245)']],

'YIOrRd':[[0,'rgb(128, 0, 38)'],[0.125,'rgb(189, 0, 38)'],
'YIOrRd': [[0,'rgb(128, 0, 38)'],[0.125,'rgb(189, 0, 38)'],
[0.25,'rgb(227, 26, 28)'],[0.375,'rgb(252, 78, 42)'],
[0.5,'rgb(253, 141, 60)'],[0.625,'rgb(254, 178, 76)'],
[0.75,'rgb(254, 217, 118)'],[0.875,'rgb(255, 237, 160)'],
[1,'rgb(255, 255, 204)']],

'Bluered':[[0,'rgb(0,0,255)'],[1,'rgb(255,0,0)']],
'Bluered': [[0,'rgb(0,0,255)'],[1,'rgb(255,0,0)']],

// modified RdBu based on
// www.sandia.gov/~kmorel/documents/ColorMaps/ColorMapsExpanded.pdf
'RdBu':[[0,'rgb(5, 10, 172)'],[0.35,'rgb(106, 137, 247)'],
'RdBu': [[0,'rgb(5, 10, 172)'],[0.35,'rgb(106, 137, 247)'],
[0.5,'rgb(190,190,190)'],[0.6,'rgb(220, 170, 132)'],
[0.7,'rgb(230, 145, 90)'],[1,'rgb(178, 10, 28)']],
// Scale for non-negative numeric values
Expand All @@ -45,39 +45,39 @@ module.exports = {
[0.5, 'rgb(70, 100, 245)'], [0.6, 'rgb(90, 120, 245)'],
[0.7, 'rgb(106, 137, 247)'], [1, 'rgb(220, 220, 220)']],

'Picnic':[[0,'rgb(0,0,255)'],[0.1,'rgb(51,153,255)'],
'Picnic': [[0,'rgb(0,0,255)'],[0.1,'rgb(51,153,255)'],
[0.2,'rgb(102,204,255)'],[0.3,'rgb(153,204,255)'],
[0.4,'rgb(204,204,255)'],[0.5,'rgb(255,255,255)'],
[0.6,'rgb(255,204,255)'],[0.7,'rgb(255,153,255)'],
[0.8,'rgb(255,102,204)'],[0.9,'rgb(255,102,102)'],
[1,'rgb(255,0,0)']],

'Rainbow':[[0,'rgb(150,0,90)'],[0.125,'rgb(0, 0, 200)'],
'Rainbow': [[0,'rgb(150,0,90)'],[0.125,'rgb(0, 0, 200)'],
[0.25,'rgb(0, 25, 255)'],[0.375,'rgb(0, 152, 255)'],
[0.5,'rgb(44, 255, 150)'],[0.625,'rgb(151, 255, 0)'],
[0.75,'rgb(255, 234, 0)'],[0.875,'rgb(255, 111, 0)'],
[1,'rgb(255, 0, 0)']],

'Portland':[[0,'rgb(12,51,131)'],[0.25,'rgb(10,136,186)'],
'Portland': [[0,'rgb(12,51,131)'],[0.25,'rgb(10,136,186)'],
[0.5,'rgb(242,211,56)'],[0.75,'rgb(242,143,56)'],
[1,'rgb(217,30,30)']],

'Jet':[[0,'rgb(0,0,131)'],[0.125,'rgb(0,60,170)'],
'Jet': [[0,'rgb(0,0,131)'],[0.125,'rgb(0,60,170)'],
[0.375,'rgb(5,255,255)'],[0.625,'rgb(255,255,0)'],
[0.875,'rgb(250,0,0)'],[1,'rgb(128,0,0)']],

'Hot':[[0,'rgb(0,0,0)'],[0.3,'rgb(230,0,0)'],
'Hot': [[0,'rgb(0,0,0)'],[0.3,'rgb(230,0,0)'],
[0.6,'rgb(255,210,0)'],[1,'rgb(255,255,255)']],

'Blackbody':[[0,'rgb(0,0,0)'],[0.2,'rgb(230,0,0)'],
'Blackbody': [[0,'rgb(0,0,0)'],[0.2,'rgb(230,0,0)'],
[0.4,'rgb(230,210,0)'],[0.7,'rgb(255,255,255)'],
[1,'rgb(160,200,255)']],

'Earth':[[0,'rgb(0,0,130)'],[0.1,'rgb(0,180,180)'],
'Earth': [[0,'rgb(0,0,130)'],[0.1,'rgb(0,180,180)'],
[0.2,'rgb(40,210,40)'],[0.4,'rgb(230,230,50)'],
[0.6,'rgb(120,70,20)'],[1,'rgb(255,255,255)']],

'Electric':[[0,'rgb(0,0,0)'],[0.15,'rgb(30,0,100)'],
'Electric': [[0,'rgb(0,0,0)'],[0.15,'rgb(30,0,100)'],
[0.4,'rgb(120,0,100)'],[0.6,'rgb(160,90,0)'],
[0.8,'rgb(230,200,0)'],[1,'rgb(255,250,220)']],

Expand Down
Loading