From 829196b5457b345ca0696a01d5a6f6c5128184e8 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 23 Mar 2020 23:02:07 +0000 Subject: [PATCH 1/3] Update dependency prettier to v2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d47537ade..2a78cc1c6 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "postcss-combine-duplicated-selectors": "8.1.0", "postcss-custom-properties": "8.0.11", "postcss-remove-root": "0.0.2", - "prettier": "1.19.1", + "prettier": "2.0.2", "react": "16.13.1", "react-ace": "7.0.5", "react-dom": "16.13.1", From c5c043010ab40650e336e02743814d78dbd80056 Mon Sep 17 00:00:00 2001 From: dmt0 Date: Wed, 25 Mar 2020 15:39:22 -0400 Subject: [PATCH 2/3] "trailingComma": "es5" is now default --- .prettierrc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.prettierrc b/.prettierrc index 4d40e22c7..de41e34cb 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,6 +1,5 @@ { - "singleQuote": true, - "bracketSpacing": false, - "trailingComma": "es5", - "printWidth": 100 + "singleQuote": true, + "bracketSpacing": false, + "printWidth": 100 } From 6cc24f919145285ea19006a08359e236c2f7f57c Mon Sep 17 00:00:00 2001 From: dmt0 Date: Wed, 25 Mar 2020 15:39:34 -0400 Subject: [PATCH 3/3] Prettier new rules --- src/DefaultEditor.js | 10 +++---- src/EditorControls.js | 8 ++--- src/__stories__/index.js | 6 ++-- src/__tests__/syntax-test.js | 8 ++--- src/components/PanelMenuWrapper.js | 4 +-- .../containers/MapboxLayersAccordion.js | 2 +- src/components/containers/PlotlyFold.js | 8 ++--- src/components/containers/PlotlyPanel.js | 6 ++-- src/components/containers/PlotlySection.js | 2 +- .../containers/RangeSelectorAccordion.js | 2 +- src/components/containers/SubplotAccordion.js | 16 +++++----- src/components/containers/TraceAccordion.js | 6 ++-- .../containers/TraceRequiredPanel.js | 2 +- .../containers/TransformAccordion.js | 17 ++++++----- .../containers/UpdateMenuAccordion.js | 2 +- .../__tests__/AnnotationAccordion-test.js | 5 +--- .../containers/__tests__/Layout-test.js | 4 +-- .../__tests__/TraceAccordion-test.js | 5 +--- .../UnconnectedContainersVisibility-test.js | 14 ++------- src/components/containers/derived.js | 2 +- src/components/fields/ArrowSelector.js | 2 +- src/components/fields/AxesCreator.js | 10 +++---- src/components/fields/AxesSelector.js | 6 ++-- src/components/fields/AxisInterval.js | 8 ++--- src/components/fields/ColorscalePicker.js | 2 +- src/components/fields/DataSelector.js | 4 +-- src/components/fields/DropdownCustom.js | 8 ++--- src/components/fields/FilterOperation.js | 6 ++-- src/components/fields/GroupCreator.js | 10 +++---- src/components/fields/LineSelectors.js | 6 ++-- src/components/fields/MarkerColor.js | 2 +- src/components/fields/MultiColorPicker.js | 28 ++++++++--------- src/components/fields/PieColorscalePicker.js | 2 +- src/components/fields/RectanglePositioner.js | 6 ++-- src/components/fields/SubplotCreator.js | 14 ++++----- src/components/fields/SymbolSelector.js | 2 +- src/components/fields/TextEditor.js | 4 +-- src/components/fields/TextPosition.js | 2 +- src/components/fields/UpdateMenuButtons.js | 2 +- src/components/fields/derived.js | 30 +++++++++---------- src/components/widgets/ColorPicker.js | 6 ++-- src/components/widgets/ColorscalePicker.js | 4 +-- src/components/widgets/DateTimePicker.js | 4 +-- src/components/widgets/Dropdown.js | 10 +++---- src/components/widgets/Dropzone.js | 2 +- .../widgets/FlaglistCheckboxGroup.js | 6 ++-- src/components/widgets/SymbolSelector.js | 4 +-- src/components/widgets/TextInput.js | 2 +- src/components/widgets/TraceTypeSelector.js | 14 ++++----- .../widgets/text_editors/MultiFormat.js | 4 +-- .../text_editors/RichText/LinkDecorator.js | 2 +- .../text_editors/RichText/LinkEditor.js | 6 ++-- .../RichText/decoratorStrategies.js | 2 +- .../widgets/text_editors/RichText/index.js | 2 +- .../widgets/text_editors/convertFormats.js | 18 +++++------ src/default_panels/GraphCreatePanel.js | 4 +-- src/default_panels/GraphTransformsPanel.js | 4 +-- src/default_panels/StyleAxesPanel.js | 12 ++++---- src/default_panels/StyleColorbarsPanel.js | 2 +- src/default_panels/StyleTracesPanel.js | 2 +- src/lib/__tests__/connectLayoutToPlot-test.js | 4 +-- src/lib/__tests__/connectTraceToPlot-test.js | 4 +-- src/lib/__tests__/dereference-test.js | 2 +- src/lib/__tests__/maybeAdjustSrc-test.js | 2 +- src/lib/__tests__/transpose-test.js | 6 ++-- src/lib/__tests__/unpackPlotProps-test.js | 8 ++--- src/lib/__tests__/walkObject-test.js | 14 ++++----- src/lib/computeTraceOptionsFromSchema.js | 8 +++-- src/lib/connectAggregationToTransform.js | 2 +- src/lib/connectAnnotationToLayout.js | 2 +- src/lib/connectAxesToLayout.js | 6 ++-- src/lib/connectCartesianSubplotToLayout.js | 2 +- src/lib/connectImageToLayout.js | 2 +- src/lib/connectLayersToMapbox.js | 2 +- src/lib/connectLayoutToPlot.js | 4 +-- src/lib/connectNonCartesianSubplotToLayout.js | 2 +- src/lib/connectRangeSelectorToAxis.js | 2 +- src/lib/connectShapeToLayout.js | 2 +- src/lib/connectSliderToLayout.js | 2 +- src/lib/connectTraceToPlot.js | 16 +++++----- src/lib/connectTransformToTrace.js | 2 +- src/lib/connectUpdateMenuToLayout.js | 2 +- src/lib/dereference.js | 6 ++-- src/lib/getAllAxes.js | 12 ++++---- src/lib/index.js | 12 ++++---- src/lib/multiValues.js | 2 +- src/lib/sortMenu.js | 10 +++---- src/lib/striptags.js | 2 +- src/lib/traceTypes.js | 6 ++-- src/lib/unpackPlotProps.js | 16 +++++----- src/lib/walkObject.js | 2 +- src/shame.js | 22 +++++++------- 92 files changed, 284 insertions(+), 295 deletions(-) diff --git a/src/DefaultEditor.js b/src/DefaultEditor.js index 711b285f1..f3ac9be18 100644 --- a/src/DefaultEditor.js +++ b/src/DefaultEditor.js @@ -33,13 +33,13 @@ class DefaultEditor extends Component { } hasTransforms() { - return this.context.fullData.some(d => TRANSFORMABLE_TRACES.includes(d.type)); + return this.context.fullData.some((d) => TRANSFORMABLE_TRACES.includes(d.type)); } hasAxes() { return ( Object.keys(this.context.fullLayout._subplots).filter( - type => + (type) => !['cartesian', 'mapbox'].includes(type) && this.context.fullLayout._subplots[type].length > 0 ).length > 0 @@ -63,15 +63,15 @@ class DefaultEditor extends Component { } hasColorbars() { - return this.context.fullData.some(d => traceHasColorbar({}, d)); + return this.context.fullData.some((d) => traceHasColorbar({}, d)); } hasLegend() { - return this.context.fullData.some(t => t.showlegend !== undefined); // eslint-disable-line no-undefined + return this.context.fullData.some((t) => t.showlegend !== undefined); // eslint-disable-line no-undefined } hasMaps() { - return this.context.fullData.some(d => + return this.context.fullData.some((d) => [...TRACE_TO_AXIS.geo, ...TRACE_TO_AXIS.mapbox].includes(d.type) ); } diff --git a/src/EditorControls.js b/src/EditorControls.js index 8a6704569..2d01105bd 100644 --- a/src/EditorControls.js +++ b/src/EditorControls.js @@ -31,7 +31,7 @@ class EditorControls extends Component { constructor(props, context) { super(props, context); - this.localize = key => localizeString(this.props.dictionaries || {}, this.props.locale, key); + this.localize = (key) => localizeString(this.props.dictionaries || {}, this.props.locale, key); // we only need to compute this once. if (this.props.plotly) { @@ -107,7 +107,7 @@ class EditorControls extends Component { props = shamefullyCreateSplitStyleProps(graphDiv, attr, traceIndex, splitTraceGroup); } - props.forEach(p => { + props.forEach((p) => { if (value !== void 0) { p.set(value); } @@ -429,8 +429,8 @@ EditorControls.defaultProps = { showFieldTooltips: false, locale: 'en', traceTypesConfig: { - categories: _ => categoryLayout(_), - traces: _ => traceTypes(_), + categories: (_) => categoryLayout(_), + traces: (_) => traceTypes(_), complex: true, }, fontOptions: DEFAULT_FONTS, diff --git a/src/__stories__/index.js b/src/__stories__/index.js index 2890c9408..0790d682c 100644 --- a/src/__stories__/index.js +++ b/src/__stories__/index.js @@ -98,7 +98,7 @@ const panelsToTest = { funnelarea: ['GraphCreatePanel', 'StyleTracesPanel'], }; -window.URL.createObjectURL = function() { +window.URL.createObjectURL = function () { return null; }; @@ -128,10 +128,10 @@ const panelFixture = (Panel, group, name, figure, customConfig) => { let stories = storiesOf('Panels', module); -Object.keys(mocks).forEach(m => { +Object.keys(mocks).forEach((m) => { const selectedPanels = panelsToTest[m] ? panelsToTest[m] : Object.keys(panels); - selectedPanels.forEach(p => { + selectedPanels.forEach((p) => { const words = p.split(/(?=[A-Z])/); const panelGroup = words[0]; const panelName = words.slice(1, -1).join(' '); diff --git a/src/__tests__/syntax-test.js b/src/__tests__/syntax-test.js index 1397f465f..be3c23005 100644 --- a/src/__tests__/syntax-test.js +++ b/src/__tests__/syntax-test.js @@ -3,16 +3,16 @@ import fs from 'fs'; import glob from 'glob'; const BLACK_LIST = ['fdescribe', 'fit', 'xdescribe', 'xit', 'it\\.only', 'describe\\.only']; -const REGEXS = BLACK_LIST.map(token => new RegExp(`^\\s*${token}\\(.*`)); +const REGEXS = BLACK_LIST.map((token) => new RegExp(`^\\s*${token}\\(.*`)); describe('Syntax and test validation', () => { describe(`ensures ${BLACK_LIST} is not present in tests`, () => { const files = glob.sync('!(node_modules|examples)/**/__tests__/*.js'); - files.forEach(file => + files.forEach((file) => it(`checks ${file} for test checks`, () => { const code = fs.readFileSync(file, {encoding: 'utf-8'}); - code.split('\n').forEach(line => { - expect(REGEXS.some(re => re.test(line))).toBe(false); + code.split('\n').forEach((line) => { + expect(REGEXS.some((re) => re.test(line))).toBe(false); }); }) ); diff --git a/src/components/PanelMenuWrapper.js b/src/components/PanelMenuWrapper.js index 536e51b5e..0841bd112 100644 --- a/src/components/PanelMenuWrapper.js +++ b/src/components/PanelMenuWrapper.js @@ -9,7 +9,7 @@ class PanelsWithSidebar extends Component { super(props); const opts = this.computeMenuOptions(props); - const firstSidebarGroup = opts.filter(o => o.panels)[0]; + const firstSidebarGroup = opts.filter((o) => o.panels)[0]; this.state = { group: firstSidebarGroup.name, @@ -53,7 +53,7 @@ class PanelsWithSidebar extends Component { let groupIndex; const childrenArray = sortMenu(React.Children.toArray(children), menuPanelOrder); - childrenArray.forEach(child => { + childrenArray.forEach((child) => { if (!child) { return; } diff --git a/src/components/containers/MapboxLayersAccordion.js b/src/components/containers/MapboxLayersAccordion.js index 226edcd88..508f2086f 100644 --- a/src/components/containers/MapboxLayersAccordion.js +++ b/src/components/containers/MapboxLayersAccordion.js @@ -30,7 +30,7 @@ class MapboxLayersAccordion extends Component { const addAction = { label: _('Layer'), - handler: context => { + handler: (context) => { const {fullContainer, updateContainer} = context; if (updateContainer) { const mapboxLayerIndex = Array.isArray(fullContainer.layers) diff --git a/src/components/containers/PlotlyFold.js b/src/components/containers/PlotlyFold.js index e7a706877..a01d8fca1 100644 --- a/src/components/containers/PlotlyFold.js +++ b/src/components/containers/PlotlyFold.js @@ -63,7 +63,7 @@ export class Fold extends Component { canDelete && typeof deleteContainer === 'function' ? (
{ + onClick={(e) => { e.stopPropagation(); deleteContainer(foldInfo); }} @@ -76,7 +76,7 @@ export class Fold extends Component {
{ + onClick={(e) => { // prevents fold toggle to happen when clicking on moving arrow controls e.stopPropagation(); @@ -92,7 +92,7 @@ export class Fold extends Component { { + onClick={(e) => { // prevents fold toggle to happen when clicking on moving arrow controls e.stopPropagation(); if (canMoveDown) { @@ -184,7 +184,7 @@ class PlotlyFold extends Fold { determineVisibility(nextProps, nextContext) { this.foldVisible = false; - React.Children.forEach(nextProps.children, child => { + React.Children.forEach(nextProps.children, (child) => { if (!child || this.foldVisible) { return; } diff --git a/src/components/containers/PlotlyPanel.js b/src/components/containers/PlotlyPanel.js index e3c20d19e..2466ce1cd 100644 --- a/src/components/containers/PlotlyPanel.js +++ b/src/components/containers/PlotlyPanel.js @@ -47,7 +47,7 @@ export class Panel extends Component { toggleFolds() { const {individualFoldStates} = this.state; - const hasOpen = individualFoldStates.length > 0 && individualFoldStates.some(s => s !== true); + const hasOpen = individualFoldStates.length > 0 && individualFoldStates.some((s) => s !== true); this.setState({ individualFoldStates: individualFoldStates.map(() => hasOpen), }); @@ -61,7 +61,7 @@ export class Panel extends Component { // to get proper number of child folds and initialize component state let numFolds = 0; - React.Children.forEach(this.props.children, child => { + React.Children.forEach(this.props.children, (child) => { if (((child && child.type && child.type.plotly_editor_traits) || {}).foldable) { numFolds++; } @@ -114,7 +114,7 @@ export class Panel extends Component { addAction={this.props.addAction} allowCollapse={this.props.showExpandCollapse && individualFoldStates.length > 1} toggleFolds={this.toggleFolds} - hasOpen={individualFoldStates.some(s => s === false)} + hasOpen={individualFoldStates.some((s) => s === false)} />
{newChildren}
diff --git a/src/components/containers/PlotlySection.js b/src/components/containers/PlotlySection.js index 21a615897..946aa3dc7 100644 --- a/src/components/containers/PlotlySection.js +++ b/src/components/containers/PlotlySection.js @@ -51,7 +51,7 @@ export default class PlotlySection extends Section { const {isVisible} = unpackPlotProps(nextProps, nextContext); this.sectionVisible = isVisibleGivenCustomConfig(isVisible, nextProps, nextContext); - React.Children.forEach(nextProps.children, child => { + React.Children.forEach(nextProps.children, (child) => { if (!child || this.sectionVisible) { return; } diff --git a/src/components/containers/RangeSelectorAccordion.js b/src/components/containers/RangeSelectorAccordion.js index 8e2c454ab..17ef7b9a3 100644 --- a/src/components/containers/RangeSelectorAccordion.js +++ b/src/components/containers/RangeSelectorAccordion.js @@ -42,7 +42,7 @@ class RangeSelectorAccordion extends Component { const addAction = { label: _('Button'), - handler: context => { + handler: (context) => { const {fullContainer, updateContainer} = context; if (updateContainer) { const rangeselectorIndex = Array.isArray(fullContainer.rangeselector.buttons) diff --git a/src/components/containers/SubplotAccordion.js b/src/components/containers/SubplotAccordion.js index 8d746eaef..c7ae24280 100644 --- a/src/components/containers/SubplotAccordion.js +++ b/src/components/containers/SubplotAccordion.js @@ -22,11 +22,11 @@ class SubplotAccordion extends Component { const subplotFolds = []; const allCartesianAxisCombinations = data.reduce((acc, curVal, inx) => { - if (TRACE_TO_AXIS.cartesian.some(c => c === curVal.type)) { + if (TRACE_TO_AXIS.cartesian.some((c) => c === curVal.type)) { const xaxis = 'xaxis' + (curVal.xaxis ? curVal.xaxis.substring(1) : ''); const yaxis = 'yaxis' + (curVal.yaxis ? curVal.yaxis.substring(1) : ''); - const existingComboIndex = acc.findIndex(t => t.xaxis === xaxis && t.yaxis === yaxis); + const existingComboIndex = acc.findIndex((t) => t.xaxis === xaxis && t.yaxis === yaxis); if (existingComboIndex === -1) { acc.push({ xaxis: xaxis, @@ -43,7 +43,7 @@ class SubplotAccordion extends Component { }, []); allCartesianAxisCombinations.forEach( - d => + (d) => (subplotFolds[d.index[0]] = ( { + Object.keys(layout).forEach((layoutKey) => { const traceIndexes = []; let subplotName; if ( - ['geo', 'mapbox', 'polar', 'gl3d', 'ternary'].some(subplotType => { + ['geo', 'mapbox', 'polar', 'gl3d', 'ternary'].some((subplotType) => { subplotName = getSubplotTitle(layoutKey, subplotType, _); const trIndex = SUBPLOT_TO_ATTR[subplotType].layout === layoutKey - ? data.findIndex(trace => TRACE_TO_AXIS[subplotType].some(tt => tt === trace.type)) - : data.findIndex(trace => trace[SUBPLOT_TO_ATTR[subplotType].data] === layoutKey); + ? data.findIndex((trace) => + TRACE_TO_AXIS[subplotType].some((tt) => tt === trace.type) + ) + : data.findIndex((trace) => trace[SUBPLOT_TO_ATTR[subplotType].data] === layoutKey); if (trIndex !== -1) { traceIndexes.push(trIndex); } diff --git a/src/components/containers/TraceAccordion.js b/src/components/containers/TraceAccordion.js index db64c4f3d..0da73a990 100644 --- a/src/components/containers/TraceAccordion.js +++ b/src/components/containers/TraceAccordion.js @@ -30,7 +30,7 @@ class TraceAccordion extends Component { if (base && base.length && context.fullData.length) { this.filteredTraces = base.filter((t, i) => { - const fullTrace = props.canGroup ? t : context.fullData.filter(tr => tr.index === i)[0]; + const fullTrace = props.canGroup ? t : context.fullData.filter((tr) => tr.index === i)[0]; if (fullTrace) { const trace = context.data[fullTrace.index]; @@ -54,7 +54,7 @@ class TraceAccordion extends Component { const dataArrayPositionsByTraceType = {}; const fullDataArrayPositionsByTraceType = {}; - this.filteredTraces.forEach(trace => { + this.filteredTraces.forEach((trace) => { const traceType = plotlyTraceToCustomTrace(trace); if (!dataArrayPositionsByTraceType[traceType]) { dataArrayPositionsByTraceType[traceType] = []; @@ -73,7 +73,7 @@ class TraceAccordion extends Component { t.value === type).label} + name={traceTypes(_).find((t) => t.value === type).label} fullDataArrayPosition={fullDataArrayPositionsByTraceType[type]} > {this.props.children} diff --git a/src/components/containers/TraceRequiredPanel.js b/src/components/containers/TraceRequiredPanel.js index e5f538e3b..13e4efcb3 100644 --- a/src/components/containers/TraceRequiredPanel.js +++ b/src/components/containers/TraceRequiredPanel.js @@ -5,7 +5,7 @@ import {LayoutPanel} from './derived'; class TraceRequiredPanel extends Component { hasTrace() { - return this.context.fullData.filter(trace => trace.visible).length > 0; + return this.context.fullData.filter((trace) => trace.visible).length > 0; } render() { diff --git a/src/components/containers/TransformAccordion.js b/src/components/containers/TransformAccordion.js index 81bd56e8e..1c19a8055 100644 --- a/src/components/containers/TransformAccordion.js +++ b/src/components/containers/TransformAccordion.js @@ -26,15 +26,15 @@ class TransformAccordion extends Component { const transformBy = container.transforms && - container.transforms.map(tr => { + container.transforms.map((tr) => { let foldNameSuffix = ''; if (tr.groupssrc) { const groupssrc = - dataSourceOptions && dataSourceOptions.find(d => d.value === tr.groupssrc); + dataSourceOptions && dataSourceOptions.find((d) => d.value === tr.groupssrc); foldNameSuffix = `: ${groupssrc && groupssrc.label ? groupssrc.label : tr.groupssrc}`; } else if (tr.targetsrc) { const targetsrc = - dataSourceOptions && dataSourceOptions.find(d => d.value === tr.targetsrc); + dataSourceOptions && dataSourceOptions.find((d) => d.value === tr.targetsrc); foldNameSuffix = `: ${targetsrc && targetsrc.label ? targetsrc.label : tr.targetsrc}`; } return foldNameSuffix; @@ -47,8 +47,9 @@ class TransformAccordion extends Component { type === tr.type)[0].label}${transformBy && - transformBy[i]}`} + name={`${transformTypes.filter(({type}) => type === tr.type)[0].label}${ + transformBy && transformBy[i] + }`} canDelete={true} > {children} @@ -58,8 +59,8 @@ class TransformAccordion extends Component { // cannot have 2 Split transforms on one trace: // https://github.com/plotly/plotly.js/issues/1742 const addActionOptions = - container.transforms && container.transforms.some(t => t.type === 'groupby') - ? transformTypes.filter(t => t.type !== 'groupby') + container.transforms && container.transforms.some((t) => t.type === 'groupby') + ? transformTypes.filter((t) => t.type !== 'groupby') : transformTypes; const addAction = { @@ -67,7 +68,7 @@ class TransformAccordion extends Component { handler: addActionOptions.map(({label, type}) => { return { label, - handler: context => { + handler: (context) => { const {fullContainer, updateContainer} = context; if (updateContainer) { const transformIndex = Array.isArray(fullContainer.transforms) diff --git a/src/components/containers/UpdateMenuAccordion.js b/src/components/containers/UpdateMenuAccordion.js index 735c1e9fb..385ed4ea9 100644 --- a/src/components/containers/UpdateMenuAccordion.js +++ b/src/components/containers/UpdateMenuAccordion.js @@ -22,7 +22,7 @@ class UpdateMenuAccordion extends Component { buttons: _('Buttons'), }; const menuType = localizedType[upd.type] || localizedType.dropdown; - const activeBtn = upd.buttons.filter(b => b._index === upd.active)[0]; + const activeBtn = upd.buttons.filter((b) => b._index === upd.active)[0]; const foldName = menuType + (activeBtn ? ': ' + activeBtn.label : ''); return ( diff --git a/src/components/containers/__tests__/AnnotationAccordion-test.js b/src/components/containers/__tests__/AnnotationAccordion-test.js index 52ae052fd..55a96bbdf 100644 --- a/src/components/containers/__tests__/AnnotationAccordion-test.js +++ b/src/components/containers/__tests__/AnnotationAccordion-test.js @@ -60,10 +60,7 @@ describe('', () => { ); - editor - .find('.js-fold__delete') - .at(0) - .simulate('click'); + editor.find('.js-fold__delete').at(0).simulate('click'); const update = beforeDeleteAnnotation.mock.calls[0][0]; expect(update.annotationIndex).toBe(0); diff --git a/src/components/containers/__tests__/Layout-test.js b/src/components/containers/__tests__/Layout-test.js index dbb12a17e..4838cfb87 100644 --- a/src/components/containers/__tests__/Layout-test.js +++ b/src/components/containers/__tests__/Layout-test.js @@ -7,9 +7,9 @@ import {connectLayoutToPlot} from 'lib'; import {mount} from 'enzyme'; const Layouts = [PlotlyPanel, PlotlyFold, PlotlySection].map(connectLayoutToPlot); -const Editor = props => ; +const Editor = (props) => ; -Layouts.forEach(Layout => { +Layouts.forEach((Layout) => { describe(`<${Layout.displayName}>`, () => { it(`wraps container with fullValue pointing to gd._fullLayout`, () => { const wrapper = mount( diff --git a/src/components/containers/__tests__/TraceAccordion-test.js b/src/components/containers/__tests__/TraceAccordion-test.js index eb4d185c7..1cc360ad6 100644 --- a/src/components/containers/__tests__/TraceAccordion-test.js +++ b/src/components/containers/__tests__/TraceAccordion-test.js @@ -51,10 +51,7 @@ describe('', () => { ); - editor - .find('.js-fold__delete') - .at(0) - .simulate('click'); + editor.find('.js-fold__delete').at(0).simulate('click'); expect(beforeDeleteTrace).toBeCalled(); const update = beforeDeleteTrace.mock.calls[0][0]; diff --git a/src/components/containers/__tests__/UnconnectedContainersVisibility-test.js b/src/components/containers/__tests__/UnconnectedContainersVisibility-test.js index fc172067d..f60b87fbf 100644 --- a/src/components/containers/__tests__/UnconnectedContainersVisibility-test.js +++ b/src/components/containers/__tests__/UnconnectedContainersVisibility-test.js @@ -54,18 +54,8 @@ describe('Basic Panel rules', () => { it('PANEL shows collapse functionality, FOLD is foldable', () => { expect(wrapper.find('.panel__header__collapse').length).toEqual(1); - expect( - wrapper - .find(Fold) - .first() - .props().folded - ).toBe(false); - expect( - typeof wrapper - .find(Fold) - .first() - .props().toggleFold - ).toBe('function'); + expect(wrapper.find(Fold).first().props().folded).toBe(false); + expect(typeof wrapper.find(Fold).first().props().toggleFold).toBe('function'); }); }); }); diff --git a/src/components/containers/derived.js b/src/components/containers/derived.js index 2a2608f28..f59fb0e46 100644 --- a/src/components/containers/derived.js +++ b/src/components/containers/derived.js @@ -16,7 +16,7 @@ const TraceTypeSection = (props, context) => { mode === 'trace' && fullContainer && traceTypes.includes(fullContainer.type); const ifConnectedToLayout = - mode === 'layout' && fullData && fullData.some(t => traceTypes.includes(t.type)); + mode === 'layout' && fullData && fullData.some((t) => traceTypes.includes(t.type)); if (ifConnectedToTrace || ifConnectedToLayout) { return ; diff --git a/src/components/fields/ArrowSelector.js b/src/components/fields/ArrowSelector.js index b599a5dd6..d22ec513c 100644 --- a/src/components/fields/ArrowSelector.js +++ b/src/components/fields/ArrowSelector.js @@ -29,7 +29,7 @@ const ARROW_OPTIONS = ARROW_PATHS.map(({path}, index) => { }; }); -const ArrowSelector = props => { +const ArrowSelector = (props) => { return ; }; diff --git a/src/components/fields/AxesCreator.js b/src/components/fields/AxesCreator.js index d73d883ae..603c9588b 100644 --- a/src/components/fields/AxesCreator.js +++ b/src/components/fields/AxesCreator.js @@ -19,7 +19,7 @@ class UnconnectedAxisCreator extends Component { const currentAxisId = this.props.fullContainer[this.props.attr]; const currentTraceIndex = this.props.fullContainer.index; return this.context.fullData.some( - d => d.index !== currentTraceIndex && d[this.props.attr] === currentAxisId + (d) => d.index !== currentTraceIndex && d[this.props.attr] === currentAxisId ); } @@ -63,7 +63,7 @@ class UnconnectedAxisCreator extends Component { if ( currentAxisId !== update && !this.context.fullData.some( - trace => + (trace) => trace[this.props.attr] === currentAxisId && trace.index !== this.props.fullContainer.index ) ) { @@ -94,7 +94,7 @@ class UnconnectedAxisCreator extends Component { attr={this.props.attr} clearable={false} options={this.props.options} - updatePlot={u => this.updateAxis(u)} + updatePlot={(u) => this.updateAxis(u)} extraComponent={extraComponent} /> ); @@ -123,7 +123,7 @@ class UnconnectedAxesCreator extends Component { render() { const axisType = traceTypeToAxisType(this.props.container.type); const isFirstTraceOfAxisType = - this.context.data.filter(d => traceTypeToAxisType(d.type) === axisType).length === 1; + this.context.data.filter((d) => traceTypeToAxisType(d.type) === axisType).length === 1; if (isFirstTraceOfAxisType) { return null; @@ -133,7 +133,7 @@ class UnconnectedAxesCreator extends Component { const controls = []; function getOptions(axisType) { - return fullLayout._subplots[axisType].map(axisId => ({ + return fullLayout._subplots[axisType].map((axisId) => ({ label: getParsedTemplateString(getAxisTitle(fullLayout[axisIdToAxisName(axisId)]), { meta: fullLayout.meta, }), diff --git a/src/components/fields/AxesSelector.js b/src/components/fields/AxesSelector.js index b7a4f6c0b..cf0d68b5b 100644 --- a/src/components/fields/AxesSelector.js +++ b/src/components/fields/AxesSelector.js @@ -24,10 +24,10 @@ class AxesSelector extends Component { const multipleSublots = fullLayout && fullLayout._subplots && - Object.values(fullLayout._subplots).some(s => s.length > 1); + Object.values(fullLayout._subplots).some((s) => s.length > 1); const options = multipleSublots - ? axesOptions.map(option => + ? axesOptions.map((option) => option.value === 'allaxes' ? option : { @@ -40,7 +40,7 @@ class AxesSelector extends Component { : axesOptions; const totalCharsInOptions = - (options && options.map(o => o.label).reduce((acc, o) => acc + o.length, 0)) || 0; + (options && options.map((o) => o.label).reduce((acc, o) => acc + o.length, 0)) || 0; return maxOptions || totalCharsInOptions >= maxCharsThatFitInRadio ? ( diff --git a/src/components/fields/AxisInterval.js b/src/components/fields/AxisInterval.js index 07040952a..0aaf2588c 100644 --- a/src/components/fields/AxisInterval.js +++ b/src/components/fields/AxisInterval.js @@ -26,7 +26,7 @@ function getSmallestUnit(milliseconds) { let smallestUnit = 'milliseconds'; - ['seconds', 'minutes', 'days'].forEach(unit => { + ['seconds', 'minutes', 'days'].forEach((unit) => { if ( milliseconds % units[unit] === 0 && (smallestUnit === 'milliseconds' || @@ -167,13 +167,13 @@ export class UnconnectedAxisInterval extends Component { {value: 'milliseconds', label: _('Milliseconds')}, ]} clearable={false} - onChange={value => this.onUnitChange(value)} + onChange={(value) => this.onUnitChange(value)} value={this.state.units} />
this.update(value)} + onUpdate={(value) => this.update(value)} editableClassName="AxisInterval-milliseconds" />
@@ -181,7 +181,7 @@ export class UnconnectedAxisInterval extends Component { this.props.updatePlot(value)} + onUpdate={(value) => this.props.updatePlot(value)} /> ); diff --git a/src/components/fields/ColorscalePicker.js b/src/components/fields/ColorscalePicker.js index be05e2bca..a8421fb93 100644 --- a/src/components/fields/ColorscalePicker.js +++ b/src/components/fields/ColorscalePicker.js @@ -35,7 +35,7 @@ export class UnconnectedColorscalePicker extends Component { render() { const {fullValue} = this.props; - const colorscale = Array.isArray(fullValue) ? fullValue.map(v => v[1]) : null; + const colorscale = Array.isArray(fullValue) ? fullValue.map((v) => v[1]) : null; return ( diff --git a/src/components/fields/DataSelector.js b/src/components/fields/DataSelector.js index d0c36aa46..fb5886de3 100644 --- a/src/components/fields/DataSelector.js +++ b/src/components/fields/DataSelector.js @@ -84,8 +84,8 @@ export class UnconnectedDataSelector extends Component { if (Array.isArray(adjustedValue)) { data = adjustedValue - .filter(v => Array.isArray(this.dataSources[v])) - .map(v => this.dataSources[v]); + .filter((v) => Array.isArray(this.dataSources[v])) + .map((v) => this.dataSources[v]); } else { data = this.dataSources[adjustedValue] || null; } diff --git a/src/components/fields/DropdownCustom.js b/src/components/fields/DropdownCustom.js index 4b1280307..73ec5f407 100644 --- a/src/components/fields/DropdownCustom.js +++ b/src/components/fields/DropdownCustom.js @@ -18,7 +18,7 @@ export class UnconnectedDropdownCustom extends Component { this.state = { custom: this.value === props.customOpt || - !this.props.options.map(o => o.value).includes(this.value), + !this.props.options.map((o) => o.value).includes(this.value), }; } @@ -47,7 +47,7 @@ export class UnconnectedDropdownCustom extends Component { render() { const {options, attr, customOpt} = this.props; const value = - (this.value === '' || !options.map(o => o.value).includes(this.value)) && this.state.custom + (this.value === '' || !options.map((o) => o.value).includes(this.value)) && this.state.custom ? customOpt : this.value; @@ -66,8 +66,8 @@ export class UnconnectedDropdownCustom extends Component { {this.state.custom && ( this.setValue(value, true)} - onChange={value => { + updatePlot={(value) => this.setValue(value, true)} + onChange={(value) => { if (value) { this.setValue(value, true); } diff --git a/src/components/fields/FilterOperation.js b/src/components/fields/FilterOperation.js index 771ffb9dc..4ec6e8bad 100644 --- a/src/components/fields/FilterOperation.js +++ b/src/components/fields/FilterOperation.js @@ -5,7 +5,7 @@ import DropdownWidget from '../widgets/Dropdown'; import TextInput from '../widgets/TextInput'; import {connectToContainer} from 'lib'; -const operations = _ => ({ +const operations = (_) => ({ inequality: [ {value: '!=', label: _('Target ≠ Reference')}, {value: '<', label: _('Target < Reference')}, @@ -34,7 +34,7 @@ const findOperation = (operator, _) => { let op = 'inequality'; const ops = operations(_); for (const key in ops) { - if (ops.hasOwnProperty(key) && ops[key].map(o => o.value).indexOf(operator) !== -1) { + if (ops.hasOwnProperty(key) && ops[key].map((o) => o.value).indexOf(operator) !== -1) { op = key; break; } @@ -142,7 +142,7 @@ class UnconnectedFilterValue extends Component { val = op === 'inrange' || op === 'exrange' ? [v, this.state.valueMax] : v; if (op === 'inset' || op === 'exset') { val = val.split(','); - val = val.map(v => v.trim()); + val = val.map((v) => v.trim()); } this.props.updatePlot(val); } diff --git a/src/components/fields/GroupCreator.js b/src/components/fields/GroupCreator.js index c46ff0dd4..21a1b1dd7 100644 --- a/src/components/fields/GroupCreator.js +++ b/src/components/fields/GroupCreator.js @@ -9,7 +9,7 @@ import {MULTI_VALUED} from 'lib/constants'; class UnconnectedGroupCreator extends Component { getAllGroups() { - return [...new Set(this.context.data.map(t => t[this.props.attr]))].filter(g => Boolean(g)); + return [...new Set(this.context.data.map((t) => t[this.props.attr]))].filter((g) => Boolean(g)); } canAddGroup() { @@ -23,14 +23,14 @@ class UnconnectedGroupCreator extends Component { return ( !currentGroup || - this.context.fullData.some(d => d.index !== currentTraceIndex && d[attr] === currentGroup) + this.context.fullData.some((d) => d.index !== currentTraceIndex && d[attr] === currentGroup) ); } addAndUpdateGroup() { const allGroups = this.context.fullData - .map(t => parseInt(t[this.props.attr], 10)) - .filter(n => Number.isInteger(n)); + .map((t) => parseInt(t[this.props.attr], 10)) + .filter((n) => Number.isInteger(n)); // don't want to pass empty array to max allGroups.push(0); @@ -45,7 +45,7 @@ class UnconnectedGroupCreator extends Component { const options = [{label: _('None'), value: ''}]; const allGroups = this.getAllGroups(); - allGroups.forEach(g => options.push({label: `${prefix} ${g}`, value: g})); + allGroups.forEach((g) => options.push({label: `${prefix} ${g}`, value: g})); options.sort((a, b) => a.value - b.value); const icon = ; diff --git a/src/components/fields/LineSelectors.js b/src/components/fields/LineSelectors.js index 1a684a7e7..b37426bbd 100644 --- a/src/components/fields/LineSelectors.js +++ b/src/components/fields/LineSelectors.js @@ -43,14 +43,14 @@ const computeOptions = (strokeData, stroke) => value, })); -export const LineShapeSelector = props => ( +export const LineShapeSelector = (props) => ( ); -export const LineDashSelector = props => ( +export const LineDashSelector = (props) => ( + computeOptions={(lineColor) => computeOptions(strokeDashes, lineColor).concat([ { label: '', diff --git a/src/components/fields/MarkerColor.js b/src/components/fields/MarkerColor.js index 838bc859c..e2ea97213 100644 --- a/src/components/fields/MarkerColor.js +++ b/src/components/fields/MarkerColor.js @@ -147,7 +147,7 @@ class UnconnectedMarkerColor extends Component { // TO DO: https://github.com/plotly/react-chart-editor/issues/654 const noSplitsPresent = container && - (!container.transforms || !container.transforms.filter(t => t.type === 'groupby').length); + (!container.transforms || !container.transforms.filter((t) => t.type === 'groupby').length); if (noSplitsPresent) { const {type} = this.state; diff --git a/src/components/fields/MultiColorPicker.js b/src/components/fields/MultiColorPicker.js index 9cb16e373..7904a465d 100644 --- a/src/components/fields/MultiColorPicker.js +++ b/src/components/fields/MultiColorPicker.js @@ -13,16 +13,16 @@ const CustomColorscalePicker = connectToContainer(UnconnectedColorscalePicker, { if ( props.attr === 'marker.color' && context.fullData - .filter(t => context.traceIndexes.includes(t.index)) - .every(t => t.marker && t.marker.color) && + .filter((t) => context.traceIndexes.includes(t.index)) + .every((t) => t.marker && t.marker.color) && plotProps.fullValue && typeof plotProps.fullValue === 'string' ) { plotProps.fullValue = context.fullData && context.fullData - .filter(t => context.traceIndexes.includes(t.index)) - .map(t => [0, t.marker.color]); + .filter((t) => context.traceIndexes.includes(t.index)) + .map((t) => [0, t.marker.color]); } }, }); @@ -34,7 +34,7 @@ class UnconnectedMultiColorPicker extends Component { selectedConstantColorOption: context.traceIndexes.length > 1 && props.fullValue && - props.fullValue.every(v => v[1] === props.fullValue[0][1]) + props.fullValue.every((v) => v[1] === props.fullValue[0][1]) ? 'single' : 'multiple', }; @@ -52,7 +52,7 @@ class UnconnectedMultiColorPicker extends Component { setColors(colorscale, colorscaleType) { const numberOfTraces = this.props.tracesToColor.length; - const colors = colorscale.map(c => c[1]); + const colors = colorscale.map((c) => c[1]); let adjustedColors = colors; @@ -60,11 +60,11 @@ class UnconnectedMultiColorPicker extends Component { adjustedColors = adjustColorscale(colors, numberOfTraces, colorscaleType); } - if (adjustedColors.every(c => c === adjustedColors[0]) || colorscaleType === 'categorical') { + if (adjustedColors.every((c) => c === adjustedColors[0]) || colorscaleType === 'categorical') { adjustedColors = adjustColorscale(colors, numberOfTraces, colorscaleType, {repeat: true}); } - const updates = adjustedColors.map(color => ({ + const updates = adjustedColors.map((color) => ({ [this.props.attr]: color, })); @@ -98,7 +98,7 @@ class UnconnectedMultiColorPicker extends Component { onOptionChange={ this.props.onConstantColorOptionChange ? this.props.onConstantColorOptionChange - : value => this.setState({selectedConstantColorOption: value}) + : (value) => this.setState({selectedConstantColorOption: value}) } /> {selectedConstantColorOption === 'single' ? singleMessage : multiMessage} @@ -152,17 +152,17 @@ export default connectToContainer(UnconnectedMultiColorPicker, { let tracesToColor = []; const dedupedTraceIndexes = []; - context.traceIndexes.forEach(i => { + context.traceIndexes.forEach((i) => { if (!dedupedTraceIndexes.includes(i)) { dedupedTraceIndexes.push(i); } }); - dedupedTraceIndexes.forEach(traceIndex => { - const traces = context.fullData.filter(trace => trace.index === traceIndex); + dedupedTraceIndexes.forEach((traceIndex) => { + const traces = context.fullData.filter((trace) => trace.index === traceIndex); tracesToColor = tracesToColor.concat(traces); - traces.forEach(t => { + traces.forEach((t) => { const value = nestedProperty(t, props.attr).get(); if (value) { colors.push(value); @@ -171,7 +171,7 @@ export default connectToContainer(UnconnectedMultiColorPicker, { }); plotProps.tracesToColor = tracesToColor; - plotProps.fullValue = colors.map(c => [0, c]); + plotProps.fullValue = colors.map((c) => [0, c]); } }, }); diff --git a/src/components/fields/PieColorscalePicker.js b/src/components/fields/PieColorscalePicker.js index 8f68a1219..ff4c1626c 100644 --- a/src/components/fields/PieColorscalePicker.js +++ b/src/components/fields/PieColorscalePicker.js @@ -59,7 +59,7 @@ export default connectToContainer(UnconnectedPieColorscalePicker, { (Array.isArray(plotProps.fullValue) && !plotProps.fullValue.length)) && context.graphDiv.calcdata ) { - plotProps.fullValue = context.graphDiv.calcdata[0].map(d => d.color); + plotProps.fullValue = context.graphDiv.calcdata[0].map((d) => d.color); } if (context.traceIndexes.length > 1) { diff --git a/src/components/fields/RectanglePositioner.js b/src/components/fields/RectanglePositioner.js index 81abae7f6..b7cea240e 100644 --- a/src/components/fields/RectanglePositioner.js +++ b/src/components/fields/RectanglePositioner.js @@ -28,7 +28,7 @@ class UnconnectedRectanglePositioner extends Component { const y0 = (fieldHeightPx - (height + y)) / fieldHeightPx; const y1 = (fieldHeightPx - y) / fieldHeightPx; - const snap = this.state.snap ? v => Math.round(v * gridRes) / gridRes : v => v; + const snap = this.state.snap ? (v) => Math.round(v * gridRes) / gridRes : (v) => v; const payload = {}; @@ -82,7 +82,7 @@ class UnconnectedRectanglePositioner extends Component { this.setState({snap: snap})} + onOptionChange={(snap) => this.setState({snap: snap})} activeOption={this.state.snap} options={[ {label: _('On'), value: true}, @@ -120,7 +120,7 @@ class UnconnectedRectanglePositioner extends Component { rotatable={false} draggable={!this.state.snap} zoomable={zoomable} - onResize={style => { + onResize={(style) => { this.sendUpdate({ fieldWidthPx, fieldHeightPx, diff --git a/src/components/fields/SubplotCreator.js b/src/components/fields/SubplotCreator.js index 953d6625d..1d4ef80fd 100644 --- a/src/components/fields/SubplotCreator.js +++ b/src/components/fields/SubplotCreator.js @@ -13,7 +13,7 @@ class UnconnectedSingleSubplotCreator extends Component { const currentAxisId = this.props.fullContainer[this.props.attr]; const currentTraceIndex = this.props.fullContainer.index; return this.context.fullData.some( - d => d.index !== currentTraceIndex && d[this.props.attr] === currentAxisId + (d) => d.index !== currentTraceIndex && d[this.props.attr] === currentAxisId ); } @@ -42,7 +42,7 @@ class UnconnectedSingleSubplotCreator extends Component { if ( currentSubplotId !== update && !this.context.fullData.some( - trace => + (trace) => trace[SUBPLOT_TO_ATTR[this.props.layoutAttr].data] === currentSubplotId && trace.index !== this.props.fullContainer.index ) @@ -74,7 +74,7 @@ class UnconnectedSingleSubplotCreator extends Component { attr={this.props.attr} clearable={false} options={this.props.options} - updatePlot={u => this.updateSubplot(u)} + updatePlot={(u) => this.updateSubplot(u)} extraComponent={extraComponent} /> ); @@ -103,12 +103,12 @@ const SingleSubplotCreator = connectToContainer(UnconnectedSingleSubplotCreator) class UnconnectedSubplotCreator extends Component { render() { const subplotType = traceTypeToAxisType(this.props.container.type); - if (!['geo', 'mapbox', 'polar', 'gl3d', 'ternary'].some(t => t === subplotType)) { + if (!['geo', 'mapbox', 'polar', 'gl3d', 'ternary'].some((t) => t === subplotType)) { return null; } const isFirstTraceOfAxisType = - this.context.data.filter(d => traceTypeToAxisType(d.type) === subplotType).length === 1; + this.context.data.filter((d) => traceTypeToAxisType(d.type) === subplotType).length === 1; if (isFirstTraceOfAxisType) { return null; } @@ -116,7 +116,7 @@ class UnconnectedSubplotCreator extends Component { const {fullLayout, localize: _} = this.context; function getOptions(subplotType) { - return fullLayout._subplots[subplotType].map(subplotId => ({ + return fullLayout._subplots[subplotType].map((subplotId) => ({ label: getSubplotTitle(subplotId, subplotType, _), value: subplotId, })); @@ -162,7 +162,7 @@ export default connectToContainer(UnconnectedSubplotCreator, { data.length > 1 && data[fullContainer.index] && ['geo', 'mapbox', 'polar', 'gl3d', 'ternary'].some( - t => t === traceTypeToAxisType(data[fullContainer.index].type) + (t) => t === traceTypeToAxisType(data[fullContainer.index].type) ); }, }); diff --git a/src/components/fields/SymbolSelector.js b/src/components/fields/SymbolSelector.js index 456d4601e..26cf366d8 100644 --- a/src/components/fields/SymbolSelector.js +++ b/src/components/fields/SymbolSelector.js @@ -379,7 +379,7 @@ class SymbolSelector extends Component { this.symbolOptions = this.props.container.type === 'scatter3d' - ? SYMBOLS.filter(option => option.threeD) + ? SYMBOLS.filter((option) => option.threeD) : [...SYMBOLS]; } diff --git a/src/components/fields/TextEditor.js b/src/components/fields/TextEditor.js index 676e6e7f3..80c17d380 100644 --- a/src/components/fields/TextEditor.js +++ b/src/components/fields/TextEditor.js @@ -27,7 +27,7 @@ export class UnconnectedTextEditor extends Component { let adjustedValue = value; if (templateStrings) { - adjustedValue = adjustedValue.replace(TEMPLATE_STRING_REGEX, match => { + adjustedValue = adjustedValue.replace(TEMPLATE_STRING_REGEX, (match) => { const index = INDEX_IN_TEMPLATE_STRING_REGEX.exec(match); if (index) { const adjustedIndex = parseInt(index[3], 10) - 1; @@ -45,7 +45,7 @@ export class UnconnectedTextEditor extends Component { getAdjustedFullValue(fullValue) { const templateStrings = this.hasTemplateStrings(fullValue); if (templateStrings) { - return fullValue.replace(TEMPLATE_STRING_REGEX, match => { + return fullValue.replace(TEMPLATE_STRING_REGEX, (match) => { const index = INDEX_IN_TEMPLATE_STRING_REGEX.exec(match); if (index) { const adjustedIndex = parseInt(index[3], 10) + 1; diff --git a/src/components/fields/TextPosition.js b/src/components/fields/TextPosition.js index f9a90b301..1e2cdaf39 100644 --- a/src/components/fields/TextPosition.js +++ b/src/components/fields/TextPosition.js @@ -52,7 +52,7 @@ export class UnconnectedTextPosition extends Component { { + onOptionChange={(value) => { this.setState({posType: value}); if (value === 'simple') { this.props.updatePlot('middle center'); diff --git a/src/components/fields/UpdateMenuButtons.js b/src/components/fields/UpdateMenuButtons.js index 3edf503b5..52d389e69 100644 --- a/src/components/fields/UpdateMenuButtons.js +++ b/src/components/fields/UpdateMenuButtons.js @@ -22,7 +22,7 @@ class UpdateMenuButtons extends Component { attr="buttons" label={_('Button')} options={options} - updatePlot={index => this.setState({currentButtonIndex: index})} + updatePlot={(index) => this.setState({currentButtonIndex: index})} clearable={false} fullValue={this.state.currentButtonIndex} /> diff --git a/src/components/fields/derived.js b/src/components/fields/derived.js index 188b0536f..013319dc0 100644 --- a/src/components/fields/derived.js +++ b/src/components/fields/derived.js @@ -21,14 +21,14 @@ export const AxisAnchorDropdown = connectToContainer(UnconnectedDropdown, { let options = []; if (props.attr.startsWith('xaxis')) { - options = context.fullLayout._subplots.yaxis.map(axis => { + options = context.fullLayout._subplots.yaxis.map((axis) => { return { label: getAxisTitle(context.fullLayout[axisIdToAxisName(axis)]), value: axis, }; }); } else if (props.attr.startsWith('yaxis')) { - options = context.fullLayout._subplots.xaxis.map(axis => { + options = context.fullLayout._subplots.xaxis.map((axis) => { return { label: getAxisTitle(context.fullLayout[axisIdToAxisName(axis)]), value: axis, @@ -46,14 +46,14 @@ export const AxisOverlayDropdown = connectToContainer(UnconnectedDropdown, { let options = []; if (props.attr.startsWith('xaxis')) { - options = context.fullLayout._subplots.xaxis.map(axis => { + options = context.fullLayout._subplots.xaxis.map((axis) => { return { label: getAxisTitle(context.fullLayout[axisIdToAxisName(axis)]), value: axis, }; }); } else if (props.attr.startsWith('yaxis')) { - options = context.fullLayout._subplots.yaxis.map(axis => { + options = context.fullLayout._subplots.yaxis.map((axis) => { return { label: getAxisTitle(context.fullLayout[axisIdToAxisName(axis)]), value: axis, @@ -65,7 +65,7 @@ export const AxisOverlayDropdown = connectToContainer(UnconnectedDropdown, { // filter out the current axisID, can't overlay over itself plotProps.options = options.filter( - option => + (option) => context.fullContainer && context.fullContainer.xaxis && context.fullContainer.yaxis && @@ -276,7 +276,7 @@ const numericFractionModifyPlotProps = (props, context, plotProps) => { plotProps.fullValue = Math.round((100 * (fullValue - min)) / (max - min)); } - plotProps.updatePlot = v => { + plotProps.updatePlot = (v) => { if (isNumeric(v)) { updatePlot((v / 100) * (max - min) + min); } else { @@ -307,7 +307,7 @@ export const NumericFractionInverse = connectToContainer(UnconnectedNumericFract plotProps.fullValue = Math.round((1 - fullValue) * 100); } - plotProps.updatePlot = v => { + plotProps.updatePlot = (v) => { if (isNumeric(v)) { updatePlot(1 - v / 100); } else { @@ -336,7 +336,7 @@ export const NumericReciprocal = connectToContainer(UnconnectedNumeric, { plotProps.fullValue = 1 / fullValue; } - plotProps.updatePlot = v => { + plotProps.updatePlot = (v) => { if (isNumeric(v)) { updatePlot(1 / v); } else { @@ -374,7 +374,7 @@ export const AnnotationArrowRef = connectToContainer(UnconnectedDropdown, { if (currentAxisRef === 'paper') { // If currentAxesRef is paper provide all axes options to user. - const axes = getAllAxes(context.fullLayout).filter(a => a._id); + const axes = getAllAxes(context.fullLayout).filter((a) => a._id); if (axes.length > 0) { plotProps.options = [ {label: _('in pixels'), value: 'pixel'}, @@ -419,7 +419,7 @@ export const AnnotationRef = connectToContainer(UnconnectedDropdown, { ); } - const axes = getAllAxes(context.fullLayout).filter(a => a._id); + const axes = getAllAxes(context.fullLayout).filter((a) => a._id); if (axes.length > 0) { plotProps.options = [ {label: _('Canvas'), value: 'paper'}, @@ -430,7 +430,7 @@ export const AnnotationRef = connectToContainer(UnconnectedDropdown, { } if (currentOffsetRef !== 'pixel') { - plotProps.updatePlot = v => { + plotProps.updatePlot = (v) => { if (!plotProps.updateContainer) { return; } @@ -455,7 +455,7 @@ export const AnnotationRef = connectToContainer(UnconnectedDropdown, { export const PositioningRef = connectToContainer(UnconnectedDropdown, { modifyPlotProps: (props, context, plotProps) => { - const axes = getAllAxes(context.fullLayout).filter(a => a._id); + const axes = getAllAxes(context.fullLayout).filter((a) => a._id); if (axes.length > 0) { plotProps.options = [ {label: 'Canvas', value: 'paper'}, @@ -486,7 +486,7 @@ export const PositioningNumeric = connectToContainer(UnconnectedNumericOrDate, { plotProps.fullValue = Math.round(100 * fullValue); } - plotProps.updatePlot = v => { + plotProps.updatePlot = (v) => { if (isNumeric(v)) { updatePlot(v / 100); } else { @@ -698,7 +698,7 @@ export const MapboxSourceArray = connectToContainer(Text, { plotProps.fullValue = fullValue[0]; } - plotProps.updatePlot = v => { + plotProps.updatePlot = (v) => { if (v.length) { updatePlot([v]); } else { @@ -807,7 +807,7 @@ export const LevelRendered = connectToContainer(UnconnectedDropdown, { if (context.container.ids && context.container.ids.length) { plotProps.isVisible = true; plotProps.options = [{label: _('Root'), value: ''}].concat( - context.container.ids.map(i => ({label: i, value: i})) + context.container.ids.map((i) => ({label: i, value: i})) ); } }, diff --git a/src/components/widgets/ColorPicker.js b/src/components/widgets/ColorPicker.js index 45efa1bb7..384020be4 100644 --- a/src/components/widgets/ColorPicker.js +++ b/src/components/widgets/ColorPicker.js @@ -7,9 +7,9 @@ import {CustomPicker as customPicker} from 'react-color'; // Utility functions for converting ColorPicker color objects or raw strings // into TinyColor objects. -const extractRGB = c => c.rgb || c; -const getColorSource = c => (c.source === 'hex' ? c.hex : extractRGB(c)); -const toTinyColor = c => tinycolor(getColorSource(c)); +const extractRGB = (c) => c.rgb || c; +const getColorSource = (c) => (c.source === 'hex' ? c.hex : extractRGB(c)); +const toTinyColor = (c) => tinycolor(getColorSource(c)); class Custom extends Component { render() { diff --git a/src/components/widgets/ColorscalePicker.js b/src/components/widgets/ColorscalePicker.js index fa9e7ed84..2460a204a 100644 --- a/src/components/widgets/ColorscalePicker.js +++ b/src/components/widgets/ColorscalePicker.js @@ -34,8 +34,8 @@ class Scale extends Component { const {selectedColorscaleType, showColorscalePicker} = this.state; const description = COLOR_PICKER_CONSTANTS.COLORSCALE_DESCRIPTIONS[selectedColorscaleType]; const colorscaleOptions = COLOR_PICKER_CONSTANTS.COLORSCALE_TYPES.filter( - type => type !== 'custom' - ).map(type => ({ + (type) => type !== 'custom' + ).map((type) => ({ label: type + ' scales', value: type, })); diff --git a/src/components/widgets/DateTimePicker.js b/src/components/widgets/DateTimePicker.js index 72ce7ccd0..062548f19 100644 --- a/src/components/widgets/DateTimePicker.js +++ b/src/components/widgets/DateTimePicker.js @@ -136,7 +136,7 @@ export default class DateTimePicker extends Component { }, []); const isNoon = - parsedTime[0] === '12' && parsedTime.slice(1).every(part => parseInt(part, 10) === 0); + parsedTime[0] === '12' && parsedTime.slice(1).every((part) => parseInt(part, 10) === 0); return !isValidDateTime || time === '' || JSDate.toDateString() === 'Invalid Date' ? '' @@ -271,7 +271,7 @@ export default class DateTimePicker extends Component { className="datepicker-container-rce" modifiers={{highlighted: isValidJSDate ? JSDate : ''}} month={isValidJSDate ? JSDate : new Date()} - onDayClick={value => { + onDayClick={(value) => { const plotlyDate = this.toPlotlyJSDate(value).split(' ')[0]; this.onDateChange(plotlyDate); this.onDateUpdate(plotlyDate); diff --git a/src/components/widgets/Dropdown.js b/src/components/widgets/Dropdown.js index f49a9d20b..61cb32ada 100644 --- a/src/components/widgets/Dropdown.js +++ b/src/components/widgets/Dropdown.js @@ -17,7 +17,7 @@ class Dropdown extends Component { return onChange(null); } - return multi ? onChange(selection.map(s => s[valueKey])) : onChange(selection[valueKey]); + return multi ? onChange(selection.map((s) => s[valueKey])) : onChange(selection[valueKey]); } render() { @@ -43,7 +43,7 @@ class Dropdown extends Component { dropdownStyle.width = width; } - const opts = options.map(opt => + const opts = options.map((opt) => typeof opt === 'string' ? {label: opt, [valueKey]: opt} : opt ); @@ -57,7 +57,7 @@ class Dropdown extends Component {