Skip to content

New eslint rules #925

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 7 commits into from
Sep 12, 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
11 changes: 9 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"extends": [
"eslint:recommended"
],
"parserOptions": {
"ecmaVersion": 5,
},
"env": {
"commonjs": true
},
Expand All @@ -14,7 +17,7 @@
"indent": [2, 4, {"SwitchCase": 1}],
"max-len": [0, 80],
"brace-style": [0, "stroustrup", {"allowSingleLine": true}],
"curly": [0, "multi"],
"curly": [2, "multi-line"],
"camelcase": [0, {"properties": "never"}],
"comma-spacing": [2, {"before": false, "after": true}],
"comma-style": [2, "last"],
Expand All @@ -32,20 +35,24 @@
"space-in-parens": [2, "never"],
"space-before-function-paren": [2, "never"],
"space-before-blocks": [2],
"spaced-comment": [2, "always"],
"no-tabs": [2],
"no-multi-spaces": [2],
"no-whitespace-before-property": [2],
"no-unexpected-multiline": [2],
"no-floating-decimal": [2],
"space-infix-ops": [2, {"int32Hint": true}],
"quotes": [2, "single"],
"dot-notation": [2],
"dot-location": [2, "property"],
"operator-linebreak": [2, "after"],
"eqeqeq": [2],
"new-cap": [0],
"new-cap": [2, { "capIsNewExceptionPattern": "^MathJax\\.." }],
"no-redeclare": [2, {"builtinGlobals": true}],
"no-shadow": [0, {"builtinGlobals": true}],
"block-scoped-var": [2],
"no-unused-vars": [2],
"no-undef-init": [2],
"no-use-before-define": [2, "nofunc"],
"no-loop-func": [2],
"no-console": [0],
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"build": "npm run preprocess && npm run bundle && npm run header && npm run stats",
"cibuild": "npm run preprocess && node tasks/cibundle.js",
"watch": "node tasks/watch.js",
"lint": "eslint . || true",
"lint": "eslint --version && eslint . || true",
"lint-fix": "eslint . --fix",
"pretest": "node tasks/pretest.js",
"test-jasmine": "karma start test/jasmine/karma.conf.js",
Expand Down Expand Up @@ -92,7 +92,7 @@
"browserify": "^13.0.0",
"browserify-transform-tools": "^1.5.1",
"ecstatic": "^1.4.0",
"eslint": "^3.0.0",
"eslint": "^3.5.0",
"falafel": "^1.2.0",
"fs-extra": "^0.30.0",
"fuse.js": "^2.2.0",
Expand Down
8 changes: 4 additions & 4 deletions src/components/annotations/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,16 +409,16 @@ function drawOne(gd, index, opt, value) {
// and the annotation center are visible
if(options.showarrow) {
if(options.axref === options.xref) {
//we don't want to constrain if the tail is absolute
//or the slope (which is meaningful) will change.
// we don't want to constrain if the tail is absolute
// or the slope (which is meaningful) will change.
arrowX = annPosPx.x;
} else {
arrowX = Lib.constrain(annPosPx.x - options.ax, 1, fullLayout.width - 1);
}

if(options.ayref === options.yref) {
//we don't want to constrain if the tail is absolute
//or the slope (which is meaningful) will change.
// we don't want to constrain if the tail is absolute
// or the slope (which is meaningful) will change.
arrowY = annPosPx.y;
} else {
arrowY = Lib.constrain(annPosPx.y - options.ay, 1, fullLayout.height - 1);
Expand Down
2 changes: 1 addition & 1 deletion src/components/colorbar/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ module.exports = function draw(gd, id) {
container.attr('transform',
'translate(' + (gs.l - xoffset) + ',' + gs.t + ')');

//auto margin adjustment
// auto margin adjustment
Plots.autoMargin(gd, id, {
x: opts.x,
y: opts.y,
Expand Down
4 changes: 3 additions & 1 deletion src/components/drawing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,10 @@ function singlePointStyle(d, sel, trace, markerScale, lineScale, marker, markerL

// handle multi-trace graph edit case
if(d.ms === 'various' || marker.size === 'various') r = 3;
else r = subTypes.isBubble(trace) ?
else {
r = subTypes.isBubble(trace) ?
sizeFn(d.ms) : (marker.size || 6) / 2;
}

// store the calculated size so hover can use it
d.mrc = r;
Expand Down
6 changes: 3 additions & 3 deletions src/components/legend/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ function computeLegendDimensions(gd, groups, traces) {
maxTraceWidth = 0,
offsetX = 0;

//calculate largest width for traces and use for width of all legend items
// calculate largest width for traces and use for width of all legend items
traces.each(function(d) {
maxTraceWidth = Math.max(40 + d[0].width, maxTraceWidth);
});
Expand All @@ -604,7 +604,7 @@ function computeLegendDimensions(gd, groups, traces) {
offsetX = 0;
rowHeight = rowHeight + maxTraceHeight;
opts.height = opts.height + maxTraceHeight;
//reset for next row
// reset for next row
maxTraceHeight = 0;
}

Expand All @@ -615,7 +615,7 @@ function computeLegendDimensions(gd, groups, traces) {
opts.width += traceGap + traceWidth;
opts.height = Math.max(opts.height, legendItem.height);

//keep track of tallest trace in group
// keep track of tallest trace in group
offsetX += traceGap + traceWidth;
maxTraceHeight = Math.max(legendItem.height, maxTraceHeight);
});
Expand Down
2 changes: 1 addition & 1 deletion src/lib/matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ exports.apply2DTransform = function(transform) {
var args = arguments;
if(args.length === 3) {
args = args[0];
}//from map
}// from map
var xy = arguments.length === 1 ? args[0] : [args[0], args[1]];
return exports.dot(transform, [xy[0], xy[1], 1]).slice(0, 2);
};
Expand Down
8 changes: 4 additions & 4 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ function setPlotContext(gd, config) {
}
}

//staticPlot forces a bunch of others:
// staticPlot forces a bunch of others:
if(context.staticPlot) {
context.editable = false;
context.autosizable = false;
Expand Down Expand Up @@ -418,8 +418,8 @@ function plotPolar(gd, data, layout) {

var titleLayout = function() {
this.call(svgTextUtils.convertToTspans);
//TODO: html/mathjax
//TODO: center title
// TODO: html/mathjax
// TODO: center title
};

var title = polarPlotSVG.select('.title-group text')
Expand Down Expand Up @@ -1490,7 +1490,7 @@ function _restyle(gd, aobj, _traces) {
} else if(Registry.traceIs(cont, 'cartesian')) {
Lib.nestedProperty(cont, 'marker.colors')
.set(Lib.nestedProperty(cont, 'marker.color').get());
//look for axes that are no longer in use and delete them
// look for axes that are no longer in use and delete them
flagAxForDelete[cont.xaxis || 'x'] = true;
flagAxForDelete[cont.yaxis || 'y'] = true;
}
Expand Down
6 changes: 3 additions & 3 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ axes.coerceRef = function(containerIn, containerOut, gd, axLetter, dflt) {
return Lib.coerce(containerIn, containerOut, attrDef, refAttr);
};

//todo: duplicated per github PR 610. Should be consolidated with axes.coerceRef.
// todo: duplicated per github PR 610. Should be consolidated with axes.coerceRef.
// find the list of possible axes to reference with an axref or ayref attribute
// and coerce it to that list
axes.coerceARef = function(containerIn, containerOut, gd, axLetter, dflt) {
Expand Down Expand Up @@ -689,15 +689,15 @@ axes.autoTicks = function(ax, roughDTick) {
ax.dtick = roundDTick(roughDTick, 1000, roundBase60);
}
else {
//milliseconds
// milliseconds
base = Math.pow(10, Math.floor(Math.log(roughDTick) / Math.LN10));
ax.dtick = roundDTick(roughDTick, base, roundBase10);
}
}
else if(ax.type === 'log') {
ax.tick0 = 0;

//only show powers of 10
// only show powers of 10
if(roughDTick > 0.7) ax.dtick = Math.ceil(roughDTick);
else if(Math.abs(ax.range[1] - ax.range[0]) < 1) {
// span is less than one power of 10
Expand Down
2 changes: 1 addition & 1 deletion src/plots/cartesian/graph_interact.js
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ function hoverAvoidOverlaps(hoverData, ax) {
p1 = g1[0];
topOverlap = p0.pos + p0.dp + p0.size - p1.pos - p1.dp + p1.size;

//Only group points that lie on the same axes
// Only group points that lie on the same axes
if(topOverlap > 0.01 && (p0.pmin === p1.pmin) && (p0.pmax === p1.pmax)) {
// push the new point(s) added to this group out of the way
for(j = g1.length - 1; j >= 0; j--) g1[j].dp += topOverlap;
Expand Down
4 changes: 2 additions & 2 deletions src/plots/cartesian/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ module.exports = {
valType: 'enumerated',
values: [
'trace', 'category ascending', 'category descending', 'array'
/*, 'value ascending', 'value descending'*/ // value ascending / descending to be implemented later
/* , 'value ascending', 'value descending'*/ // value ascending / descending to be implemented later
],
dflt: 'trace',
role: 'info',
Expand All @@ -484,7 +484,7 @@ module.exports = {
'By default, plotly uses *trace*, which specifies the order that is present in the data supplied.',
'Set `categoryorder` to *category ascending* or *category descending* if order should be determined by',
'the alphanumerical order of the category names.',
/*'Set `categoryorder` to *value ascending* or *value descending* if order should be determined by the',
/* 'Set `categoryorder` to *value ascending* or *value descending* if order should be determined by the',
'numerical order of the values.',*/ // // value ascending / descending to be implemented later
'Set `categoryorder` to *array* to derive the ordering from the attribute `categoryarray`. If a category',
'is not found in the `categoryarray` array, the sorting behavior for that attribute will be identical to',
Expand Down
8 changes: 4 additions & 4 deletions src/plots/gl3d/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function createCamera(element, options) {
var curCenter = view.computedCenter.slice();
view.setMode(mode);
if(mode === 'turntable') {
//Hacky time warping stuff to generate smooth animation
// Hacky time warping stuff to generate smooth animation
var t0 = now();
view._active.lookAt(t0, curEye, curCenter, curUp);
view._active.lookAt(t0 + 500, curEye, curCenter, [0, 0, 1]);
Expand Down Expand Up @@ -204,17 +204,17 @@ function createCamera(element, options) {
var drot = Math.PI * camera.rotateSpeed;

if((rotate && left && !ctrl && !alt && !shift) || (left && !ctrl && !alt && shift)) {
//Rotate
// Rotate
view.rotate(t, flipX * drot * dx, -flipY * drot * dy, 0);
}

if((pan && left && !ctrl && !alt && !shift) || right || (left && ctrl && !alt && !shift)) {
//Pan
// Pan
view.pan(t, -camera.translateSpeed * dx * distance, camera.translateSpeed * dy * distance, 0);
}

if((zoom && left && !ctrl && !alt && !shift) || middle || (left && !ctrl && alt && !shift)) {
//Zoom
// Zoom
var kzoom = -camera.zoomSpeed * dy / window.innerHeight * (t - view.lastT()) * 100;
view.pan(t, 0, 0, distance * (Math.exp(kzoom) - 1));
}
Expand Down
7 changes: 3 additions & 4 deletions src/plots/gl3d/layout/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ proto.merge = function(sceneLayout) {
for(var i = 0; i < 3; ++i) {
var axes = sceneLayout[AXES_NAMES[i]];

/////// Axes labels //
// Axes labels
opts.labels[i] = convertHTMLToUnicode(axes.title);
if('titlefont' in axes) {
if(axes.titlefont.color) opts.labelColor[i] = str2RgbaArray(axes.titlefont.color);
if(axes.titlefont.family) opts.labelFont[i] = axes.titlefont.family;
if(axes.titlefont.size) opts.labelSize[i] = axes.titlefont.size;
}

/////// LINES ////////
// Lines
if('showline' in axes) opts.lineEnable[i] = axes.showline;
if('linecolor' in axes) opts.lineColor[i] = str2RgbaArray(axes.linecolor);
if('linewidth' in axes) opts.lineWidth[i] = axes.linewidth;
Expand All @@ -100,8 +100,7 @@ proto.merge = function(sceneLayout) {
if('zerolinecolor' in axes) opts.zeroLineColor[i] = str2RgbaArray(axes.zerolinecolor);
if('zerolinewidth' in axes) opts.zeroLineWidth[i] = axes.zerolinewidth;

//////// TICKS /////////
/// tick lines
// tick lines
if('ticks' in axes && !!axes.ticks) opts.lineTickEnable[i] = true;
else opts.lineTickEnable[i] = false;

Expand Down
6 changes: 3 additions & 3 deletions src/plots/gl3d/layout/tick_marks.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* LICENSE file in the root directory of this source tree.
*/

/*eslint block-scoped-var: 0*/
/*eslint no-redeclare: 0*/
/* eslint block-scoped-var: 0*/
/* eslint no-redeclare: 0*/

'use strict';

Expand Down Expand Up @@ -82,7 +82,7 @@ function computeTickMarks(scene) {

axesOptions.ticks = ticks;

//Calculate tick lengths dynamically
// Calculate tick lengths dynamically
for(var i = 0; i < 3; ++i) {
centerPoint[i] = 0.5 * (scene.glplot.bounds[0][i] + scene.glplot.bounds[1][i]);
for(var j = 0; j < 2; ++j) {
Expand Down
Loading