Skip to content

Commit 1d21d64

Browse files
authored
Merge pull request #6513 from plotly/quote-props-as-needed
enforce `quote-props` lint
2 parents f1a6e4c + b8e0041 commit 1d21d64

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1253
-1234
lines changed

.eslintrc

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"no-floating-decimal": [2],
5656
"space-infix-ops": [2, {"int32Hint": true}],
5757
"quotes": [2, "single"],
58+
"quote-props": ["error", "as-needed"],
5859
"dot-notation": [2],
5960
"dot-location": [2, "property"],
6061
"operator-linebreak": [2, "after"],

devtools/regl_codegen/server.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,17 @@ function handleCodegen(data) {
207207
var pathToReglCodegenSrc = constants.pathToReglCodegenSrc;
208208
var pathToReglPrecompiledSrc = path.join(constants.pathToSrc, 'traces', trace, 'regl_precompiled.js');
209209

210-
var header = '\'use strict\';\n';
210+
var header = [
211+
'\'use strict\';',
212+
'',
213+
].join('\n');
211214
var imports = '';
212-
var exports = '\nmodule.exports = {\n';
215+
var exports = [
216+
'',
217+
'/* eslint-disable quote-props */',
218+
'module.exports = {',
219+
'',
220+
].join('\n');
213221
var varId = 0;
214222

215223
Object.entries(generated).forEach(function(kv) {

lib/locales/.eslintrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "../.eslintrc",
3+
"rules": {
4+
"quote-props": ["error", "consistent"]
5+
}
6+
}

src/components/annotations/draw_arrow_head.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ module.exports = function drawArrowHead(el3, ends, options) {
127127

128128
d3.select(el.parentNode).append('path')
129129
.attr({
130-
'class': el3.attr('class'),
130+
class: el3.attr('class'),
131131
d: arrowHeadStyle.path,
132132
transform:
133133
strTranslate(p.x, p.y) +

src/components/calendars/index.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,23 @@ var DFLTRANGE = {
9797
*/
9898
var UNKNOWN = '##';
9999
var d3ToWorldCalendars = {
100-
'd': {'0': 'dd', '-': 'd'}, // 2-digit or unpadded day of month
101-
'e': {'0': 'd', '-': 'd'}, // alternate, always unpadded day of month
102-
'a': {'0': 'D', '-': 'D'}, // short weekday name
103-
'A': {'0': 'DD', '-': 'DD'}, // full weekday name
104-
'j': {'0': 'oo', '-': 'o'}, // 3-digit or unpadded day of the year
105-
'W': {'0': 'ww', '-': 'w'}, // 2-digit or unpadded week of the year (Monday first)
106-
'm': {'0': 'mm', '-': 'm'}, // 2-digit or unpadded month number
107-
'b': {'0': 'M', '-': 'M'}, // short month name
108-
'B': {'0': 'MM', '-': 'MM'}, // full month name
109-
'y': {'0': 'yy', '-': 'yy'}, // 2-digit year (map unpadded to zero-padded)
110-
'Y': {'0': 'yyyy', '-': 'yyyy'}, // 4-digit year (map unpadded to zero-padded)
111-
'U': UNKNOWN, // Sunday-first week of the year
112-
'w': UNKNOWN, // day of the week [0(sunday),6]
100+
d: {0: 'dd', '-': 'd'}, // 2-digit or unpadded day of month
101+
e: {0: 'd', '-': 'd'}, // alternate, always unpadded day of month
102+
a: {0: 'D', '-': 'D'}, // short weekday name
103+
A: {0: 'DD', '-': 'DD'}, // full weekday name
104+
j: {0: 'oo', '-': 'o'}, // 3-digit or unpadded day of the year
105+
W: {0: 'ww', '-': 'w'}, // 2-digit or unpadded week of the year (Monday first)
106+
m: {0: 'mm', '-': 'm'}, // 2-digit or unpadded month number
107+
b: {0: 'M', '-': 'M'}, // short month name
108+
B: {0: 'MM', '-': 'MM'}, // full month name
109+
y: {0: 'yy', '-': 'yy'}, // 2-digit year (map unpadded to zero-padded)
110+
Y: {0: 'yyyy', '-': 'yyyy'}, // 4-digit year (map unpadded to zero-padded)
111+
U: UNKNOWN, // Sunday-first week of the year
112+
w: UNKNOWN, // day of the week [0(sunday),6]
113113
// combined format, we replace the date part with the world-calendar version
114114
// and the %X stays there for d3 to handle with time parts
115-
'c': {'0': 'D M d %X yyyy', '-': 'D M d %X yyyy'},
116-
'x': {'0': 'mm/dd/yyyy', '-': 'mm/dd/yyyy'}
115+
c: {0: 'D M d %X yyyy', '-': 'D M d %X yyyy'},
116+
x: {0: 'mm/dd/yyyy', '-': 'mm/dd/yyyy'}
117117
};
118118

119119
function worldCalFmt(fmt, x, calendar) {

src/components/color/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ color.contrast = function(cstr, lightAmount, darkAmount) {
7575

7676
color.stroke = function(s, c) {
7777
var tc = tinycolor(c);
78-
s.style({'stroke': color.tinyRGB(tc), 'stroke-opacity': tc.getAlpha()});
78+
s.style({stroke: color.tinyRGB(tc), 'stroke-opacity': tc.getAlpha()});
7979
};
8080

8181
color.fill = function(s, c) {
8282
var tc = tinycolor(c);
8383
s.style({
84-
'fill': color.tinyRGB(tc),
84+
fill: color.tinyRGB(tc),
8585
'fill-opacity': tc.getAlpha()
8686
});
8787
};

src/components/colorscale/scales.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -3,60 +3,60 @@
33
var tinycolor = require('tinycolor2');
44

55
var scales = {
6-
'Greys': [
6+
Greys: [
77
[0, 'rgb(0,0,0)'], [1, 'rgb(255,255,255)']
88
],
99

10-
'YlGnBu': [
10+
YlGnBu: [
1111
[0, 'rgb(8,29,88)'], [0.125, 'rgb(37,52,148)'],
1212
[0.25, 'rgb(34,94,168)'], [0.375, 'rgb(29,145,192)'],
1313
[0.5, 'rgb(65,182,196)'], [0.625, 'rgb(127,205,187)'],
1414
[0.75, 'rgb(199,233,180)'], [0.875, 'rgb(237,248,217)'],
1515
[1, 'rgb(255,255,217)']
1616
],
1717

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

26-
'YlOrRd': [
26+
YlOrRd: [
2727
[0, 'rgb(128,0,38)'], [0.125, 'rgb(189,0,38)'],
2828
[0.25, 'rgb(227,26,28)'], [0.375, 'rgb(252,78,42)'],
2929
[0.5, 'rgb(253,141,60)'], [0.625, 'rgb(254,178,76)'],
3030
[0.75, 'rgb(254,217,118)'], [0.875, 'rgb(255,237,160)'],
3131
[1, 'rgb(255,255,204)']
3232
],
3333

34-
'Bluered': [
34+
Bluered: [
3535
[0, 'rgb(0,0,255)'], [1, 'rgb(255,0,0)']
3636
],
3737

3838
// modified RdBu based on
3939
// http://www.kennethmoreland.com/color-maps/
40-
'RdBu': [
40+
RdBu: [
4141
[0, 'rgb(5,10,172)'], [0.35, 'rgb(106,137,247)'],
4242
[0.5, 'rgb(190,190,190)'], [0.6, 'rgb(220,170,132)'],
4343
[0.7, 'rgb(230,145,90)'], [1, 'rgb(178,10,28)']
4444
],
4545

4646
// Scale for non-negative numeric values
47-
'Reds': [
47+
Reds: [
4848
[0, 'rgb(220,220,220)'], [0.2, 'rgb(245,195,157)'],
4949
[0.4, 'rgb(245,160,105)'], [1, 'rgb(178,10,28)']
5050
],
5151

5252
// Scale for non-positive numeric values
53-
'Blues': [
53+
Blues: [
5454
[0, 'rgb(5,10,172)'], [0.35, 'rgb(40,60,190)'],
5555
[0.5, 'rgb(70,100,245)'], [0.6, 'rgb(90,120,245)'],
5656
[0.7, 'rgb(106,137,247)'], [1, 'rgb(220,220,220)']
5757
],
5858

59-
'Picnic': [
59+
Picnic: [
6060
[0, 'rgb(0,0,255)'], [0.1, 'rgb(51,153,255)'],
6161
[0.2, 'rgb(102,204,255)'], [0.3, 'rgb(153,204,255)'],
6262
[0.4, 'rgb(204,204,255)'], [0.5, 'rgb(255,255,255)'],
@@ -65,50 +65,50 @@ var scales = {
6565
[1, 'rgb(255,0,0)']
6666
],
6767

68-
'Rainbow': [
68+
Rainbow: [
6969
[0, 'rgb(150,0,90)'], [0.125, 'rgb(0,0,200)'],
7070
[0.25, 'rgb(0,25,255)'], [0.375, 'rgb(0,152,255)'],
7171
[0.5, 'rgb(44,255,150)'], [0.625, 'rgb(151,255,0)'],
7272
[0.75, 'rgb(255,234,0)'], [0.875, 'rgb(255,111,0)'],
7373
[1, 'rgb(255,0,0)']
7474
],
7575

76-
'Portland': [
76+
Portland: [
7777
[0, 'rgb(12,51,131)'], [0.25, 'rgb(10,136,186)'],
7878
[0.5, 'rgb(242,211,56)'], [0.75, 'rgb(242,143,56)'],
7979
[1, 'rgb(217,30,30)']
8080
],
8181

82-
'Jet': [
82+
Jet: [
8383
[0, 'rgb(0,0,131)'], [0.125, 'rgb(0,60,170)'],
8484
[0.375, 'rgb(5,255,255)'], [0.625, 'rgb(255,255,0)'],
8585
[0.875, 'rgb(250,0,0)'], [1, 'rgb(128,0,0)']
8686
],
8787

88-
'Hot': [
88+
Hot: [
8989
[0, 'rgb(0,0,0)'], [0.3, 'rgb(230,0,0)'],
9090
[0.6, 'rgb(255,210,0)'], [1, 'rgb(255,255,255)']
9191
],
9292

93-
'Blackbody': [
93+
Blackbody: [
9494
[0, 'rgb(0,0,0)'], [0.2, 'rgb(230,0,0)'],
9595
[0.4, 'rgb(230,210,0)'], [0.7, 'rgb(255,255,255)'],
9696
[1, 'rgb(160,200,255)']
9797
],
9898

99-
'Earth': [
99+
Earth: [
100100
[0, 'rgb(0,0,130)'], [0.1, 'rgb(0,180,180)'],
101101
[0.2, 'rgb(40,210,40)'], [0.4, 'rgb(230,230,50)'],
102102
[0.6, 'rgb(120,70,20)'], [1, 'rgb(255,255,255)']
103103
],
104104

105-
'Electric': [
105+
Electric: [
106106
[0, 'rgb(0,0,0)'], [0.15, 'rgb(30,0,100)'],
107107
[0.4, 'rgb(120,0,100)'], [0.6, 'rgb(160,90,0)'],
108108
[0.8, 'rgb(230,200,0)'], [1, 'rgb(255,250,220)']
109109
],
110110

111-
'Viridis': [
111+
Viridis: [
112112
[0, '#440154'], [0.06274509803921569, '#48186a'],
113113
[0.12549019607843137, '#472d7b'], [0.18823529411764706, '#424086'],
114114
[0.25098039215686274, '#3b528b'], [0.3137254901960784, '#33638d'],
@@ -120,7 +120,7 @@ var scales = {
120120
[1, '#fde725']
121121
],
122122

123-
'Cividis': [
123+
Cividis: [
124124
[0.000000, 'rgb(0,32,76)'], [0.058824, 'rgb(0,42,102)'],
125125
[0.117647, 'rgb(0,52,110)'], [0.176471, 'rgb(39,63,108)'],
126126
[0.235294, 'rgb(60,74,107)'], [0.294118, 'rgb(76,85,107)'],

src/components/drawing/index.js

+31-31
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,9 @@ drawing.pattern = function(sel, calledBy, gd, patternID, shape, size, solidity,
428428
linewidth = solidity * size;
429429
patternTag = 'path';
430430
patternAttrs = {
431-
'd': path,
432-
'opacity': opacity,
433-
'stroke': fgRGB,
431+
d: path,
432+
opacity: opacity,
433+
stroke: fgRGB,
434434
'stroke-width': linewidth + 'px'
435435
};
436436
break;
@@ -443,9 +443,9 @@ drawing.pattern = function(sel, calledBy, gd, patternID, shape, size, solidity,
443443
linewidth = solidity * size;
444444
patternTag = 'path';
445445
patternAttrs = {
446-
'd': path,
447-
'opacity': opacity,
448-
'stroke': fgRGB,
446+
d: path,
447+
opacity: opacity,
448+
stroke: fgRGB,
449449
'stroke-width': linewidth + 'px'
450450
};
451451
break;
@@ -461,9 +461,9 @@ drawing.pattern = function(sel, calledBy, gd, patternID, shape, size, solidity,
461461
linewidth = size - size * Math.sqrt(1.0 - solidity);
462462
patternTag = 'path';
463463
patternAttrs = {
464-
'd': path,
465-
'opacity': opacity,
466-
'stroke': fgRGB,
464+
d: path,
465+
opacity: opacity,
466+
stroke: fgRGB,
467467
'stroke-width': linewidth + 'px'
468468
};
469469
break;
@@ -475,9 +475,9 @@ drawing.pattern = function(sel, calledBy, gd, patternID, shape, size, solidity,
475475
linewidth = solidity * size;
476476
patternTag = 'path';
477477
patternAttrs = {
478-
'd': path,
479-
'opacity': opacity,
480-
'stroke': fgRGB,
478+
d: path,
479+
opacity: opacity,
480+
stroke: fgRGB,
481481
'stroke-width': linewidth + 'px'
482482
};
483483
break;
@@ -489,9 +489,9 @@ drawing.pattern = function(sel, calledBy, gd, patternID, shape, size, solidity,
489489
linewidth = solidity * size;
490490
patternTag = 'path';
491491
patternAttrs = {
492-
'd': path,
493-
'opacity': opacity,
494-
'stroke': fgRGB,
492+
d: path,
493+
opacity: opacity,
494+
stroke: fgRGB,
495495
'stroke-width': linewidth + 'px'
496496
};
497497
break;
@@ -504,9 +504,9 @@ drawing.pattern = function(sel, calledBy, gd, patternID, shape, size, solidity,
504504
linewidth = size - size * Math.sqrt(1.0 - solidity);
505505
patternTag = 'path';
506506
patternAttrs = {
507-
'd': path,
508-
'opacity': opacity,
509-
'stroke': fgRGB,
507+
d: path,
508+
opacity: opacity,
509+
stroke: fgRGB,
510510
'stroke-width': linewidth + 'px'
511511
};
512512
break;
@@ -520,11 +520,11 @@ drawing.pattern = function(sel, calledBy, gd, patternID, shape, size, solidity,
520520
}
521521
patternTag = 'circle';
522522
patternAttrs = {
523-
'cx': width / 2,
524-
'cy': height / 2,
525-
'r': radius,
526-
'opacity': opacity,
527-
'fill': fgRGB
523+
cx: width / 2,
524+
cy: height / 2,
525+
r: radius,
526+
opacity: opacity,
527+
fill: fgRGB
528528
};
529529
break;
530530
}
@@ -549,12 +549,12 @@ drawing.pattern = function(sel, calledBy, gd, patternID, shape, size, solidity,
549549
var el = d3.select(this);
550550

551551
el.attr({
552-
'id': fullID,
553-
'width': width + 'px',
554-
'height': height + 'px',
555-
'patternUnits': 'userSpaceOnUse',
552+
id: fullID,
553+
width: width + 'px',
554+
height: height + 'px',
555+
patternUnits: 'userSpaceOnUse',
556556
// for legends scale down patterns just a bit so that default size (i.e 8) nicely fit in small icons
557-
'patternTransform': isLegend ? 'scale(0.8)' : ''
557+
patternTransform: isLegend ? 'scale(0.8)' : ''
558558
});
559559

560560
if(bgcolor) {
@@ -567,9 +567,9 @@ drawing.pattern = function(sel, calledBy, gd, patternID, shape, size, solidity,
567567
rects.enter()
568568
.append('rect')
569569
.attr({
570-
'width': width + 'px',
571-
'height': height + 'px',
572-
'fill': bgRGB,
570+
width: width + 'px',
571+
height: height + 'px',
572+
fill: bgRGB,
573573
'fill-opacity': bgAlpha,
574574
});
575575
}

src/components/drawing/symbol_defs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ module.exports = {
668668
needLine: true,
669669
noDot: true
670670
},
671-
'arrow': {
671+
arrow: {
672672
n: 53,
673673
f: function(r, angle, standoff) {
674674
if(skipAngle(angle)) return emptyPath;

src/components/rangeselector/draw.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ function drawButtonRect(button, selectorLayout, d) {
116116
});
117117

118118
rect.attr({
119-
'rx': constants.rx,
120-
'ry': constants.ry
119+
rx: constants.rx,
120+
ry: constants.ry
121121
});
122122

123123
rect.call(Color.stroke, selectorLayout.bordercolor)

src/components/rangeslider/attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = {
4040
{valType: 'any', editType: 'calc', impliedEdits: {'^autorange': false}}
4141
],
4242
editType: 'calc',
43-
impliedEdits: {'autorange': false},
43+
impliedEdits: {autorange: false},
4444
description: [
4545
'Sets the range of the range slider.',
4646
'If not set, defaults to the full xaxis range.',

0 commit comments

Comments
 (0)