Skip to content

Commit 36b4773

Browse files
authored
Merge pull request #3792 from plotly/eslint-name-functions
New lint rule to disallow named function expressions
2 parents d2f8976 + 6d1609a commit 36b4773

File tree

13 files changed

+19
-18
lines changed

13 files changed

+19
-18
lines changed

Diff for: .eslintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"no-loop-func": [2],
7171
"no-console": [0],
7272
"no-unused-labels": [2],
73-
"no-useless-escape": [0]
73+
"no-useless-escape": [0],
74+
"func-name-matching": ["error", "always"]
7475
}
7576
}

Diff for: src/components/dragelement/unhover.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ unhover.wrapped = function(gd, evt, subplot) {
3232

3333

3434
// remove hover effects on mouse out, and emit unhover event
35-
unhover.raw = function unhoverRaw(gd, evt) {
35+
unhover.raw = function raw(gd, evt) {
3636
var fullLayout = gd._fullLayout;
3737
var oldhoverdata = gd._hoverdata;
3838

Diff for: src/components/fx/helpers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ exports.getSubplot = function getSubplot(trace) {
1818

1919
// is trace in given list of subplots?
2020
// does handle splom case
21-
exports.isTraceInSubplots = function isTraceInSubplot(trace, subplots) {
21+
exports.isTraceInSubplots = function isTraceInSubplots(trace, subplots) {
2222
if(trace.type === 'splom') {
2323
var xaxes = trace.xaxes || [];
2424
var yaxes = trace.yaxes || [];

Diff for: src/components/updatemenus/scrollbox.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ ScrollBox.prototype.disable = function disable() {
347347
*
348348
* @method
349349
*/
350-
ScrollBox.prototype._onBoxDrag = function onBarDrag() {
350+
ScrollBox.prototype._onBoxDrag = function _onBoxDrag() {
351351
var translateX = this.translateX;
352352
var translateY = this.translateY;
353353

@@ -367,7 +367,7 @@ ScrollBox.prototype._onBoxDrag = function onBarDrag() {
367367
*
368368
* @method
369369
*/
370-
ScrollBox.prototype._onBoxWheel = function onBarWheel() {
370+
ScrollBox.prototype._onBoxWheel = function _onBoxWheel() {
371371
var translateX = this.translateX;
372372
var translateY = this.translateY;
373373

@@ -387,7 +387,7 @@ ScrollBox.prototype._onBoxWheel = function onBarWheel() {
387387
*
388388
* @method
389389
*/
390-
ScrollBox.prototype._onBarDrag = function onBarDrag() {
390+
ScrollBox.prototype._onBarDrag = function _onBarDrag() {
391391
var translateX = this.translateX;
392392
var translateY = this.translateY;
393393

Diff for: src/lib/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ lib.pushUnique = require('./push_unique');
153153

154154
lib.cleanNumber = require('./clean_number');
155155

156-
lib.ensureNumber = function num(v) {
156+
lib.ensureNumber = function ensureNumber(v) {
157157
if(!isNumeric(v)) return BADNUM;
158158
v = Number(v);
159159
if(v < -FP_SAFE || v > FP_SAFE) return BADNUM;

Diff for: src/lib/polygon.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ polygon.tester = function tester(ptsIn) {
181181
* before the line counts as bent
182182
* @returns boolean: true means this segment is bent, false means straight
183183
*/
184-
var isBent = polygon.isSegmentBent = function isBent(pts, start, end, tolerance) {
184+
polygon.isSegmentBent = function isSegmentBent(pts, start, end, tolerance) {
185185
var startPt = pts[start];
186186
var segment = [pts[end][0] - startPt[0], pts[end][1] - startPt[1]];
187187
var segmentSquared = dot(segment, segment);
@@ -226,7 +226,7 @@ polygon.filter = function filter(pts, tolerance) {
226226
ptsFiltered.splice(doneFilteredIndex + 1);
227227

228228
for(var i = iLast + 1; i < pts.length; i++) {
229-
if(i === pts.length - 1 || isBent(pts, iLast, i + 1, tolerance)) {
229+
if(i === pts.length - 1 || polygon.isSegmentBent(pts, iLast, i + 1, tolerance)) {
230230
ptsFiltered.push(pts[i]);
231231
if(ptsFiltered.length < prevFilterLen - 2) {
232232
doneRawIndex = i;

Diff for: src/plots/cartesian/constraints.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ function updateConstraintGroups(constraintGroups, thisGroup, thisID, scaleanchor
188188
thisGroup[scaleanchor] = 1;
189189
}
190190

191-
exports.enforce = function enforceAxisConstraints(gd) {
191+
exports.enforce = function enforce(gd) {
192192
var fullLayout = gd._fullLayout;
193193
var constraintGroups = fullLayout._axisConstraintGroups || [];
194194

@@ -346,7 +346,7 @@ exports.enforce = function enforceAxisConstraints(gd) {
346346

347347
// For use before autoranging, check if this axis was previously constrained
348348
// by domain but no longer is
349-
exports.clean = function cleanConstraints(gd, ax) {
349+
exports.clean = function clean(gd, ax) {
350350
if(ax._inputDomain) {
351351
var isConstrained = false;
352352
var axId = ax._id;

Diff for: src/plots/gl2d/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ exports.baseLayoutAttrOverrides = overrideAll({
5252
// dragmode: fxAttrs.dragmode
5353
}, 'plot', 'nested');
5454

55-
exports.plot = function plotGl2d(gd) {
55+
exports.plot = function plot(gd) {
5656
var fullLayout = gd._fullLayout;
5757
var fullData = gd._fullData;
5858
var subplotIds = fullLayout._subplots.gl2d;

Diff for: src/plots/gl3d/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ exports.baseLayoutAttrOverrides = overrideAll({
3939

4040
exports.supplyLayoutDefaults = require('./layout/defaults');
4141

42-
exports.plot = function plotGl3d(gd) {
42+
exports.plot = function plot(gd) {
4343
var fullLayout = gd._fullLayout;
4444
var fullData = gd._fullData;
4545
var sceneIds = fullLayout._subplots[GL3D];

Diff for: src/plots/mapbox/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ exports.layoutAttributes = require('./layout_attributes');
5050

5151
exports.supplyLayoutDefaults = require('./layout_defaults');
5252

53-
exports.plot = function plotMapbox(gd) {
53+
exports.plot = function plot(gd) {
5454
var fullLayout = gd._fullLayout;
5555
var calcData = gd.calcdata;
5656
var mapboxIds = fullLayout._subplots[MAPBOX];

Diff for: src/plots/ternary/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ exports.layoutAttributes = require('./layout_attributes');
4141

4242
exports.supplyLayoutDefaults = require('./layout_defaults');
4343

44-
exports.plot = function plotTernary(gd) {
44+
exports.plot = function plot(gd) {
4545
var fullLayout = gd._fullLayout;
4646
var calcData = gd.calcdata;
4747
var ternaryIds = fullLayout._subplots[TERNARY];

Diff for: src/traces/bar/sieve.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Sieve.prototype.put = function put(position, value) {
8484
* (required if this.sepNegVal is true)
8585
* @returns {number} Current bin value
8686
*/
87-
Sieve.prototype.get = function put(position, value) {
87+
Sieve.prototype.get = function get(position, value) {
8888
var label = this.getLabel(position, value);
8989
return this.bins[label] || 0;
9090
};

Diff for: test/jasmine/assets/unpolyfill.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
configurable: true,
1212
enumerable: true,
1313
writable: true,
14-
value: function remove() {
14+
value: function() {
1515
throw Error([
1616
'test/jasmine/assets/unpolyfill.js error: calling ChildNode.remove()',
1717
'which is not available in IE.'
@@ -23,7 +23,7 @@
2323
configurable: true,
2424
enumerable: true,
2525
writable: true,
26-
value: function remove() {
26+
value: function() {
2727
throw Error([
2828
'test/jasmine/assets/unpolyfill.js error: calling ChildNode.prepend()',
2929
'which is not available in IE.'

0 commit comments

Comments
 (0)