diff --git a/client/.eslintrc b/client/.eslintrc index 1c891637e..2348d895a 100644 --- a/client/.eslintrc +++ b/client/.eslintrc @@ -24,7 +24,6 @@ "react/jsx-filename-extension": 0, "react/jsx-no-target-blank": 0, "react/no-find-dom-node": 0, - "no-mixed-operators": 0, "no-restricted-properties": 0, "class-methods-use-this": 0, } diff --git a/client/app/scripts/charts/node-networks-overlay.js b/client/app/scripts/charts/node-networks-overlay.js index a125309a4..520f19565 100644 --- a/client/app/scripts/charts/node-networks-overlay.js +++ b/client/app/scripts/charts/node-networks-overlay.js @@ -26,7 +26,7 @@ function NodeNetworksOverlay({offset, size, stack, networks = makeList()}) { const bars = networks.map((n, i) => ( - {hasMetric && getClipPathDefinition(clipId, size, height, -size * 0.5, size * 0.5 - height)} + {hasMetric && getClipPathDefinition(clipId, size, height, -halfSize, halfSize - height)} {highlighted && } diff --git a/client/app/scripts/charts/node-shape-hexagon.js b/client/app/scripts/charts/node-shape-hexagon.js index 1d1cd9763..7dba51ee2 100644 --- a/client/app/scripts/charts/node-shape-hexagon.js +++ b/client/app/scripts/charts/node-shape-hexagon.js @@ -48,8 +48,13 @@ export default function NodeShapeHexagon({id, highlighted, size, color, metric}) return ( - {hasMetric && getClipPathDefinition(clipId, - size * (1 + hexCurve * 2), height, -size * hexCurve, (size - height) * shadowSize * 2)} + {hasMetric && getClipPathDefinition( + clipId, + size * (1 + (hexCurve * 2)), + height, + -(size * hexCurve), + (size - height) * (shadowSize * 2) + )} {highlighted && } diff --git a/client/app/scripts/charts/node-shape-stack.js b/client/app/scripts/charts/node-shape-stack.js index 3d691888c..1c5cd5f65 100644 --- a/client/app/scripts/charts/node-shape-stack.js +++ b/client/app/scripts/charts/node-shape-stack.js @@ -5,8 +5,8 @@ export default function NodeShapeStack(props) { const contrastMode = isContrastMode(); const Shape = props.shape; const [dx, dy] = contrastMode ? [0, 8] : [0, 5]; - const dsx = (props.size * 2 + (dx * 2)) / (props.size * 2); - const dsy = (props.size * 2 + (dy * 2)) / (props.size * 2); + const dsx = (props.size + dx) / props.size; + const dsy = (props.size + dy) / props.size; const hls = [dsx, dsy]; return ( diff --git a/client/app/scripts/charts/nodes-chart-edges.js b/client/app/scripts/charts/nodes-chart-edges.js index 0f6fed7f7..3e0d3ce90 100644 --- a/client/app/scripts/charts/nodes-chart-edges.js +++ b/client/app/scripts/charts/nodes-chart-edges.js @@ -26,8 +26,8 @@ class NodesChartEdges extends React.Component { !(selectedNetworkNodes.contains(edge.get('source')) && selectedNetworkNodes.contains(edge.get('target'))); const blurred = !highlighted && (otherNodesSelected || - !focused && noMatches || - !focused && noSelectedNetworks); + (!focused && noMatches) || + (!focused && noSelectedNetworks)); return ( node.set('blurred', - selectedNodeId && !node.get('focused') - || searchQuery && !searchNodeMatches.has(node.get('id')) - && !node.get('highlighted') - || selectedNetwork - && !(node.get('networks') || makeList()).find(n => n.get('id') === selectedNetwork)); + (selectedNodeId && !node.get('focused')) + || (searchQuery && !searchNodeMatches.has(node.get('id')) && !node.get('highlighted')) + || (selectedNetwork && !(node.get('networks') || makeList()).find(n => n.get('id') === selectedNetwork))); // make sure blurred nodes are in the background const sortNodes = (node) => { diff --git a/client/app/scripts/charts/nodes-chart.js b/client/app/scripts/charts/nodes-chart.js index 9eed90d3b..ff1cd2cb4 100644 --- a/client/app/scripts/charts/nodes-chart.js +++ b/client/app/scripts/charts/nodes-chart.js @@ -266,9 +266,10 @@ class NodesChart extends React.Component { // move origin node to center of viewport const zoomScale = state.scale; const translate = [state.panTranslateX, state.panTranslateY]; - const centerX = (-translate[0] + (state.width + props.margins.left - - DETAILS_PANEL_WIDTH) / 2) / zoomScale; - const centerY = (-translate[1] + (state.height + props.margins.top) / 2) / zoomScale; + const viewportHalfWidth = ((state.width + props.margins.left) - DETAILS_PANEL_WIDTH) / 2; + const viewportHalfHeight = (state.height + props.margins.top) / 2; + const centerX = (-translate[0] + viewportHalfWidth) / zoomScale; + const centerY = (-translate[1] + viewportHalfHeight) / zoomScale; stateNodes = stateNodes.mergeIn([props.selectedNodeId], { x: centerX, y: centerY @@ -283,10 +284,10 @@ class NodesChart extends React.Component { stateNodes = stateNodes.map((node, nodeId) => { const index = adjacentLayoutNodeIds.indexOf(nodeId); if (index > -1) { - const angle = offsetAngle + Math.PI * 2 * index / adjacentCount; + const angle = offsetAngle + ((Math.PI * 2 * index) / adjacentCount); return node.merge({ - x: centerX + radius * Math.sin(angle), - y: centerY + radius * Math.cos(angle) + x: centerX + (radius * Math.sin(angle)), + y: centerY + (radius * Math.cos(angle)) }); } return node; diff --git a/client/app/scripts/charts/nodes-layout.js b/client/app/scripts/charts/nodes-layout.js index 98dd27e89..efd356541 100644 --- a/client/app/scripts/charts/nodes-layout.js +++ b/client/app/scripts/charts/nodes-layout.js @@ -237,8 +237,8 @@ function layoutSingleNodes(layout, opts) { } // default margins - offsetX = offsetX || margins.left + nodeWidth / 2; - offsetY = offsetY || margins.top + nodeHeight / 2; + offsetX = offsetX || (margins.left + nodeWidth) / 2; + offsetY = offsetY || (margins.top + nodeHeight) / 2; const columns = Math.ceil(Math.sqrt(singleNodes.size)); let row = 0; @@ -251,8 +251,8 @@ function layoutSingleNodes(layout, opts) { col = 0; row += 1; } - singleX = col * (nodesep + nodeWidth) + offsetX; - singleY = row * (ranksep + nodeHeight) + offsetY; + singleX = (col * (nodesep + nodeWidth)) + offsetX; + singleY = (row * (ranksep + nodeHeight)) + offsetY; col += 1; return node.merge({ x: singleX, @@ -263,8 +263,8 @@ function layoutSingleNodes(layout, opts) { }); // adjust layout dimensions if graph is now bigger - result.width = Math.max(layout.width, singleX + nodeWidth / 2 + nodesep); - result.height = Math.max(layout.height, singleY + nodeHeight / 2 + ranksep); + result.width = Math.max(layout.width, singleX + (nodeWidth / 2) + nodesep); + result.height = Math.max(layout.height, singleY + (nodeHeight / 2) + ranksep); result.nodes = nodes; } @@ -290,12 +290,12 @@ export function shiftLayoutToCenter(layout, opts) { if (layout.width < width) { const xMin = layout.nodes.minBy(n => n.get('x')); const xMax = layout.nodes.maxBy(n => n.get('x')); - offsetX = (width - (xMin.get('x') + xMax.get('x'))) / 2 + margins.left; + offsetX = ((width - (xMin.get('x') + xMax.get('x'))) / 2) + margins.left; } if (layout.height < height) { const yMin = layout.nodes.minBy(n => n.get('y')); const yMax = layout.nodes.maxBy(n => n.get('y')); - offsetY = (height - (yMin.get('y') + yMax.get('y'))) / 2 + margins.top; + offsetY = ((height - (yMin.get('y') + yMax.get('y'))) / 2) + margins.top; } if (offsetX || offsetY) { diff --git a/client/app/scripts/components/details-card.js b/client/app/scripts/components/details-card.js index e72aa4fca..703719ce9 100644 --- a/client/app/scripts/components/details-card.js +++ b/client/app/scripts/components/details-card.js @@ -33,15 +33,15 @@ class DetailsCard extends React.Component { const scaleY = origin.height / (window.innerHeight - MARGINS.bottom - MARGINS.top) / 2; const scaleX = origin.width / WIDTH / 2; const centerX = window.innerWidth - MARGINS.right - (WIDTH / 2); - const centerY = (panelHeight) / 2 + MARGINS.top; - const dx = (origin.left + origin.width / 2) - centerX; - const dy = (origin.top + origin.height / 2) - centerY; + const centerY = (panelHeight / 2) + MARGINS.top; + const dx = (origin.left + (origin.width / 2)) - centerX; + const dy = (origin.top + (origin.height / 2)) - centerY; transform = `translate(${dx}px, ${dy}px) scale(${scaleX},${scaleY})`; } else { // stack effect: shift top cards to the left, shrink lower cards vertically const shiftX = -1 * this.props.index * OFFSET; const position = this.props.cardCount - this.props.index - 1; // reverse index - const scaleY = position === 0 ? 1 : (panelHeight - 2 * OFFSET * position) / panelHeight; + const scaleY = (position === 0) ? 1 : (panelHeight - (2 * OFFSET * position)) / panelHeight; if (scaleY !== 1) { transform = `translateX(${shiftX}px) scaleY(${scaleY})`; } else { diff --git a/client/app/scripts/components/matched-text.js b/client/app/scripts/components/matched-text.js index f444ba722..7aaa07d49 100644 --- a/client/app/scripts/components/matched-text.js +++ b/client/app/scripts/components/matched-text.js @@ -84,7 +84,7 @@ class MatchedText extends React.Component { render() { const { match, text, truncate, maxLength } = this.props; - const showFullValue = !truncate || match && match.start + match.length > truncate; + const showFullValue = !truncate || (match && (match.start + match.length) > truncate); const displayText = showFullValue ? text : text.slice(0, truncate); if (!match) { diff --git a/client/app/scripts/components/terminal.js b/client/app/scripts/components/terminal.js index b9a43940d..4eadf7b6a 100644 --- a/client/app/scripts/components/terminal.js +++ b/client/app/scripts/components/terminal.js @@ -264,7 +264,7 @@ class Terminal extends React.Component { this.props.dispatch(clickCloseTerminal(this.getPipeId())); const bcr = ReactDOM.findDOMNode(this).getBoundingClientRect(); - const minWidth = this.state.characterWidth * 80 + (8 * 2); + const minWidth = (this.state.characterWidth * 80) + (8 * 2); openNewWindow(`terminal.html#!/state/${paramString}`, bcr, minWidth); } diff --git a/client/app/scripts/utils/array-utils.js b/client/app/scripts/utils/array-utils.js index 52cc098e0..4dd6e7de0 100644 --- a/client/app/scripts/utils/array-utils.js +++ b/client/app/scripts/utils/array-utils.js @@ -6,6 +6,6 @@ export function uniformSelect(array, size) { } return _.range(size).map(index => - array[parseInt(index * array.length / (size - 1 + 1e-9), 10)] + array[parseInt(index * (array.length / (size - (1 - 1e-9))), 10)] ); } diff --git a/client/app/scripts/utils/metric-utils.js b/client/app/scripts/utils/metric-utils.js index 2515d5b89..5acf724ae 100644 --- a/client/app/scripts/utils/metric-utils.js +++ b/client/app/scripts/utils/metric-utils.js @@ -6,7 +6,7 @@ import { formatMetricSvg } from './string-utils'; import { colors } from './color-utils'; export function getClipPathDefinition(clipId, size, height, - x = -size * 0.5, y = size * 0.5 - height) { + x = -size * 0.5, y = (size * 0.5) - height) { return ( @@ -44,7 +44,7 @@ export function getMetricValue(metric, size) { let displayedValue = Number(value).toFixed(1); if (displayedValue > 0 && (!max || displayedValue < max)) { const baseline = 0.1; - displayedValue = valuePercentage * (1 - baseline * 2) + baseline; + displayedValue = (valuePercentage * (1 - (baseline * 2))) + baseline; } else if (displayedValue >= m.max && displayedValue > 0) { displayedValue = 1; }