Skip to content

enforce quote-props lint #6513

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 3 commits into from
Mar 8, 2023
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
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"no-floating-decimal": [2],
"space-infix-ops": [2, {"int32Hint": true}],
"quotes": [2, "single"],
"quote-props": ["error", "as-needed"],
"dot-notation": [2],
"dot-location": [2, "property"],
"operator-linebreak": [2, "after"],
Expand Down
12 changes: 10 additions & 2 deletions devtools/regl_codegen/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,17 @@ function handleCodegen(data) {
var pathToReglCodegenSrc = constants.pathToReglCodegenSrc;
var pathToReglPrecompiledSrc = path.join(constants.pathToSrc, 'traces', trace, 'regl_precompiled.js');

var header = '\'use strict\';\n';
var header = [
'\'use strict\';',
'',
].join('\n');
var imports = '';
var exports = '\nmodule.exports = {\n';
var exports = [
'',
'/* eslint-disable quote-props */',
'module.exports = {',
'',
].join('\n');
var varId = 0;

Object.entries(generated).forEach(function(kv) {
Expand Down
6 changes: 6 additions & 0 deletions lib/locales/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../.eslintrc",
"rules": {
"quote-props": ["error", "consistent"]
}
}
2 changes: 1 addition & 1 deletion src/components/annotations/draw_arrow_head.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ module.exports = function drawArrowHead(el3, ends, options) {

d3.select(el.parentNode).append('path')
.attr({
'class': el3.attr('class'),
class: el3.attr('class'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexcjohnson Do you recall if quotes around class are needed here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class is a reserved word, so it made me squeamish to leave it unquoted. But This note implies it's been fine for quite a long time:

Note: ECMAScript 3 didn’t allow the use of unquoted reserved words as property names. Here’s the full list of ES3 reserved words: abstract, boolean, break, byte, case, catch, char, class, const, continue, debugger, default, delete, do, double, else, enum, export, extends, false, final, finally, float, for, function, goto, if, implements, import, in, instanceof, int, interface, long, native, new, null, package, private, protected, public, return, short, static, super, switch, synchronized, this, throw, throws, transient, true, try, typeof, var, void, volatile, while, and with. Avoid using these as unquoted property names if backwards compatibility is a concern.

This is fine in ES5 and beyond 🎉

d: arrowHeadStyle.path,
transform:
strTranslate(p.x, p.y) +
Expand Down
30 changes: 15 additions & 15 deletions src/components/calendars/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,23 @@ var DFLTRANGE = {
*/
var UNKNOWN = '##';
var d3ToWorldCalendars = {
'd': {'0': 'dd', '-': 'd'}, // 2-digit or unpadded day of month
'e': {'0': 'd', '-': 'd'}, // alternate, always unpadded day of month
'a': {'0': 'D', '-': 'D'}, // short weekday name
'A': {'0': 'DD', '-': 'DD'}, // full weekday name
'j': {'0': 'oo', '-': 'o'}, // 3-digit or unpadded day of the year
'W': {'0': 'ww', '-': 'w'}, // 2-digit or unpadded week of the year (Monday first)
'm': {'0': 'mm', '-': 'm'}, // 2-digit or unpadded month number
'b': {'0': 'M', '-': 'M'}, // short month name
'B': {'0': 'MM', '-': 'MM'}, // full month name
'y': {'0': 'yy', '-': 'yy'}, // 2-digit year (map unpadded to zero-padded)
'Y': {'0': 'yyyy', '-': 'yyyy'}, // 4-digit year (map unpadded to zero-padded)
'U': UNKNOWN, // Sunday-first week of the year
'w': UNKNOWN, // day of the week [0(sunday),6]
d: {0: 'dd', '-': 'd'}, // 2-digit or unpadded day of month
e: {0: 'd', '-': 'd'}, // alternate, always unpadded day of month
a: {0: 'D', '-': 'D'}, // short weekday name
A: {0: 'DD', '-': 'DD'}, // full weekday name
j: {0: 'oo', '-': 'o'}, // 3-digit or unpadded day of the year
W: {0: 'ww', '-': 'w'}, // 2-digit or unpadded week of the year (Monday first)
m: {0: 'mm', '-': 'm'}, // 2-digit or unpadded month number
b: {0: 'M', '-': 'M'}, // short month name
B: {0: 'MM', '-': 'MM'}, // full month name
y: {0: 'yy', '-': 'yy'}, // 2-digit year (map unpadded to zero-padded)
Y: {0: 'yyyy', '-': 'yyyy'}, // 4-digit year (map unpadded to zero-padded)
U: UNKNOWN, // Sunday-first week of the year
w: UNKNOWN, // day of the week [0(sunday),6]
// combined format, we replace the date part with the world-calendar version
// and the %X stays there for d3 to handle with time parts
'c': {'0': 'D M d %X yyyy', '-': 'D M d %X yyyy'},
'x': {'0': 'mm/dd/yyyy', '-': 'mm/dd/yyyy'}
c: {0: 'D M d %X yyyy', '-': 'D M d %X yyyy'},
x: {0: 'mm/dd/yyyy', '-': 'mm/dd/yyyy'}
};

function worldCalFmt(fmt, x, calendar) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/color/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ color.contrast = function(cstr, lightAmount, darkAmount) {

color.stroke = function(s, c) {
var tc = tinycolor(c);
s.style({'stroke': color.tinyRGB(tc), 'stroke-opacity': tc.getAlpha()});
s.style({stroke: color.tinyRGB(tc), 'stroke-opacity': tc.getAlpha()});
};

color.fill = function(s, c) {
var tc = tinycolor(c);
s.style({
'fill': color.tinyRGB(tc),
fill: color.tinyRGB(tc),
'fill-opacity': tc.getAlpha()
});
};
Expand Down
36 changes: 18 additions & 18 deletions src/components/colorscale/scales.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,60 @@
var tinycolor = require('tinycolor2');

var scales = {
'Greys': [
Greys: [
[0, 'rgb(0,0,0)'], [1, 'rgb(255,255,255)']
],

'YlGnBu': [
YlGnBu: [
[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': [
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)']
],

'YlOrRd': [
YlOrRd: [
[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': [
Bluered: [
[0, 'rgb(0,0,255)'], [1, 'rgb(255,0,0)']
],

// modified RdBu based on
// http://www.kennethmoreland.com/color-maps/
'RdBu': [
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
'Reds': [
Reds: [
[0, 'rgb(220,220,220)'], [0.2, 'rgb(245,195,157)'],
[0.4, 'rgb(245,160,105)'], [1, 'rgb(178,10,28)']
],

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

'Picnic': [
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)'],
Expand All @@ -65,50 +65,50 @@ var scales = {
[1, 'rgb(255,0,0)']
],

'Rainbow': [
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': [
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': [
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': [
Hot: [
[0, 'rgb(0,0,0)'], [0.3, 'rgb(230,0,0)'],
[0.6, 'rgb(255,210,0)'], [1, 'rgb(255,255,255)']
],

'Blackbody': [
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': [
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': [
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)']
],

'Viridis': [
Viridis: [
[0, '#440154'], [0.06274509803921569, '#48186a'],
[0.12549019607843137, '#472d7b'], [0.18823529411764706, '#424086'],
[0.25098039215686274, '#3b528b'], [0.3137254901960784, '#33638d'],
Expand All @@ -120,7 +120,7 @@ var scales = {
[1, '#fde725']
],

'Cividis': [
Cividis: [
[0.000000, 'rgb(0,32,76)'], [0.058824, 'rgb(0,42,102)'],
[0.117647, 'rgb(0,52,110)'], [0.176471, 'rgb(39,63,108)'],
[0.235294, 'rgb(60,74,107)'], [0.294118, 'rgb(76,85,107)'],
Expand Down
62 changes: 31 additions & 31 deletions src/components/drawing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,9 @@ drawing.pattern = function(sel, calledBy, gd, patternID, shape, size, solidity,
linewidth = solidity * size;
patternTag = 'path';
patternAttrs = {
'd': path,
'opacity': opacity,
'stroke': fgRGB,
d: path,
opacity: opacity,
stroke: fgRGB,
'stroke-width': linewidth + 'px'
};
break;
Expand All @@ -443,9 +443,9 @@ drawing.pattern = function(sel, calledBy, gd, patternID, shape, size, solidity,
linewidth = solidity * size;
patternTag = 'path';
patternAttrs = {
'd': path,
'opacity': opacity,
'stroke': fgRGB,
d: path,
opacity: opacity,
stroke: fgRGB,
'stroke-width': linewidth + 'px'
};
break;
Expand All @@ -461,9 +461,9 @@ drawing.pattern = function(sel, calledBy, gd, patternID, shape, size, solidity,
linewidth = size - size * Math.sqrt(1.0 - solidity);
patternTag = 'path';
patternAttrs = {
'd': path,
'opacity': opacity,
'stroke': fgRGB,
d: path,
opacity: opacity,
stroke: fgRGB,
'stroke-width': linewidth + 'px'
};
break;
Expand All @@ -475,9 +475,9 @@ drawing.pattern = function(sel, calledBy, gd, patternID, shape, size, solidity,
linewidth = solidity * size;
patternTag = 'path';
patternAttrs = {
'd': path,
'opacity': opacity,
'stroke': fgRGB,
d: path,
opacity: opacity,
stroke: fgRGB,
'stroke-width': linewidth + 'px'
};
break;
Expand All @@ -489,9 +489,9 @@ drawing.pattern = function(sel, calledBy, gd, patternID, shape, size, solidity,
linewidth = solidity * size;
patternTag = 'path';
patternAttrs = {
'd': path,
'opacity': opacity,
'stroke': fgRGB,
d: path,
opacity: opacity,
stroke: fgRGB,
'stroke-width': linewidth + 'px'
};
break;
Expand All @@ -504,9 +504,9 @@ drawing.pattern = function(sel, calledBy, gd, patternID, shape, size, solidity,
linewidth = size - size * Math.sqrt(1.0 - solidity);
patternTag = 'path';
patternAttrs = {
'd': path,
'opacity': opacity,
'stroke': fgRGB,
d: path,
opacity: opacity,
stroke: fgRGB,
'stroke-width': linewidth + 'px'
};
break;
Expand All @@ -520,11 +520,11 @@ drawing.pattern = function(sel, calledBy, gd, patternID, shape, size, solidity,
}
patternTag = 'circle';
patternAttrs = {
'cx': width / 2,
'cy': height / 2,
'r': radius,
'opacity': opacity,
'fill': fgRGB
cx: width / 2,
cy: height / 2,
r: radius,
opacity: opacity,
fill: fgRGB
};
break;
}
Expand All @@ -549,12 +549,12 @@ drawing.pattern = function(sel, calledBy, gd, patternID, shape, size, solidity,
var el = d3.select(this);

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

if(bgcolor) {
Expand All @@ -567,9 +567,9 @@ drawing.pattern = function(sel, calledBy, gd, patternID, shape, size, solidity,
rects.enter()
.append('rect')
.attr({
'width': width + 'px',
'height': height + 'px',
'fill': bgRGB,
width: width + 'px',
height: height + 'px',
fill: bgRGB,
'fill-opacity': bgAlpha,
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/drawing/symbol_defs.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ module.exports = {
needLine: true,
noDot: true
},
'arrow': {
arrow: {
n: 53,
f: function(r, angle, standoff) {
if(skipAngle(angle)) return emptyPath;
Expand Down
4 changes: 2 additions & 2 deletions src/components/rangeselector/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ function drawButtonRect(button, selectorLayout, d) {
});

rect.attr({
'rx': constants.rx,
'ry': constants.ry
rx: constants.rx,
ry: constants.ry
});

rect.call(Color.stroke, selectorLayout.bordercolor)
Expand Down
2 changes: 1 addition & 1 deletion src/components/rangeslider/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = {
{valType: 'any', editType: 'calc', impliedEdits: {'^autorange': false}}
],
editType: 'calc',
impliedEdits: {'autorange': false},
impliedEdits: {autorange: false},
description: [
'Sets the range of the range slider.',
'If not set, defaults to the full xaxis range.',
Expand Down
Loading