Skip to content

Commit

Permalink
fix: indent second and thrid ternary blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
nickofthyme committed Jun 8, 2020
1 parent e5b053a commit e3ba904
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 127 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ module.exports = {
indent: ['error', 2, {
SwitchCase: 1,
MemberExpression: 1,
offsetTernaryExpressions: true,
}],
'max-len': [
'warn',
Expand Down
38 changes: 19 additions & 19 deletions integration/jest_puppeteer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,30 @@ const sharedConfig = {
const customConfig = {
...(isDebug
? {
launch: {
dumpio: false,
headless: false,
slowMo: 500,
devtools: true,
...sharedConfig,
},
}
launch: {
dumpio: false,
headless: false,
slowMo: 500,
devtools: true,
...sharedConfig,
},
}
: {
// https://github.com/gidztech/jest-puppeteer-docker/issues/24
chromiumFlags: [], // for docker chromium options
connect: {
...sharedConfig,
},
}),
chromiumFlags: [], // for docker chromium options
connect: {
...sharedConfig,
},
}),
server: useLocalStorybook
? null
: {
command: `yarn start --port=${port} --quiet`,
port,
usedPortAction: 'error',
launchTimeout: 120000,
debug: true,
},
command: `yarn start --port=${port} --quiet`,
port,
usedPortAction: 'error',
launchTimeout: 120000,
debug: true,
},
...baseConfig,
};

Expand Down
48 changes: 24 additions & 24 deletions src/chart_types/goal_chart/renderer/canvas/canvas_renderers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ export function renderCanvas2d(
...Object.assign({}, ...ticks.map(({ value, text }, i) => ({ [`tick_${i}`]: { value, text } }))),
...(circular
? {
centralMajor: { value: 0, text: centralMajor },
centralMinor: { value: 0, text: centralMinor },
}
centralMajor: { value: 0, text: centralMajor },
centralMinor: { value: 0, text: centralMinor },
}
: {}),
};

Expand Down Expand Up @@ -194,29 +194,29 @@ export function renderCanvas2d(
},
...(circular
? [
{
order: 6,
landmarks: { at: 'centralMajor' },
aes: {
shape: 'text',
textAlign: 'center',
textBaseline: 'bottom',
fillColor: 'black',
fontShape: { fontStyle: 'normal', fontVariant: 'normal', fontWeight: '900', fontFamily: 'sans-serif' },
{
order: 6,
landmarks: { at: 'centralMajor' },
aes: {
shape: 'text',
textAlign: 'center',
textBaseline: 'bottom',
fillColor: 'black',
fontShape: { fontStyle: 'normal', fontVariant: 'normal', fontWeight: '900', fontFamily: 'sans-serif' },
},
},
},
{
order: 6,
landmarks: { at: 'centralMinor' },
aes: {
shape: 'text',
textAlign: 'center',
textBaseline: 'top',
fillColor: 'black',
fontShape: { fontStyle: 'normal', fontVariant: 'normal', fontWeight: '300', fontFamily: 'sans-serif' },
{
order: 6,
landmarks: { at: 'centralMinor' },
aes: {
shape: 'text',
textAlign: 'center',
textBaseline: 'top',
fillColor: 'black',
fontShape: { fontStyle: 'normal', fontVariant: 'normal', fontWeight: '300', fontFamily: 'sans-serif' },
},
},
},
]
]
: []),
];

Expand Down
4 changes: 2 additions & 2 deletions src/chart_types/partition_chart/layout/utils/calcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export function getTextColor(shapeFillColor: Color, textColor: Color, textInvert
const inverseForContrast = textInvertible && specifiedTextColorIsDark === backgroundIsDark;
return inverseForContrast
? to === undefined
? `rgb(${255 - tr}, ${255 - tg}, ${255 - tb})`
: `rgba(${255 - tr}, ${255 - tg}, ${255 - tb}, ${to})`
? `rgb(${255 - tr}, ${255 - tg}, ${255 - tb})`
: `rgba(${255 - tr}, ${255 - tg}, ${255 - tb}, ${to})`
: textColor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ export function ringSectorConstruction(config: Config, innerRadius: Radius, ring
const rectangleCirclines = outerRadiusFromRectangleWidth === Infinity && outerRadiusFromRectanglHeight === Infinity
? []
: [
{ x: INFINITY_RADIUS - outerRadiusFromRectangleWidth, y: 0, r: INFINITY_RADIUS, inside: true },
{ x: -INFINITY_RADIUS + outerRadiusFromRectangleWidth, y: 0, r: INFINITY_RADIUS, inside: true },
{ x: 0, y: INFINITY_RADIUS - outerRadiusFromRectanglHeight, r: INFINITY_RADIUS, inside: true },
{ x: 0, y: -INFINITY_RADIUS + outerRadiusFromRectanglHeight, r: INFINITY_RADIUS, inside: true },
];
{ x: INFINITY_RADIUS - outerRadiusFromRectangleWidth, y: 0, r: INFINITY_RADIUS, inside: true },
{ x: -INFINITY_RADIUS + outerRadiusFromRectangleWidth, y: 0, r: INFINITY_RADIUS, inside: true },
{ x: 0, y: INFINITY_RADIUS - outerRadiusFromRectanglHeight, r: INFINITY_RADIUS, inside: true },
{ x: 0, y: -INFINITY_RADIUS + outerRadiusFromRectanglHeight, r: INFINITY_RADIUS, inside: true },
];
return [...sectorCirclines, ...rectangleCirclines];
};
}
Expand Down Expand Up @@ -216,9 +216,9 @@ export const getRectangleRowGeometry: GetShapeRowGeometry<RectangleConstruction>
const { top, right, bottom, left } = typeof padding === 'number'
? { top: padding, right: padding, bottom: padding, left: padding }
: {
...{ top: defaultPad, right: defaultPad, bottom: defaultPad, left: defaultPad },
...padding,
};
...{ top: defaultPad, right: defaultPad, bottom: defaultPad, left: defaultPad },
...padding,
};

const overhang = 0.05;
const topPaddingAdjustment = fontSize < 6 ? 0 : Math.max(1, Math.min(2, fontSize / 16));
Expand Down Expand Up @@ -332,8 +332,8 @@ function fill<C>(
const verticalAlignment = middleAlign
? VerticalAlignments.middle
: (node.depth < layers.length
? VerticalAlignments.bottom
: VerticalAlignments.top);
? VerticalAlignments.bottom
: VerticalAlignments.top);
const fontSizes = allFontSizes[Math.min(node.depth, allFontSizes.length) - 1];
const { textColor, textInvertible, fontStyle, fontVariant, fontFamily, fontWeight, valueFormatter, padding } = {
fontFamily: configFontFamily,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ export function linkTextLayout(
);
const { text, width, verticalOffset } = linkLabel.fontSize / 2 <= cy + diskCenter.y && cy + diskCenter.y <= rectHeight - linkLabel.fontSize / 2
? fitText(measure, labelText, allottedLabelWidth, linkLabel.fontSize, {
...labelFontSpec,
text: labelText,
})
...labelFontSpec,
text: labelText,
})
: { text: '', width: 0, verticalOffset: 0 };
const link: PointTuples = [
[x0, y0],
Expand Down
38 changes: 19 additions & 19 deletions src/chart_types/partition_chart/layout/viewmodel/viewmodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,17 @@ function rectangleConstruction(treeHeight: number, topGroove: number) {
return function(node: ShapeTreeNode): RectangleConstruction {
return node.depth < treeHeight
? {
x0: node.x0,
y0: node.y0px,
x1: node.x1,
y1: node.y0px + getTopPadding(topGroove, node.y1px - node.y0px),
}
x0: node.x0,
y0: node.y0px,
x1: node.x1,
y1: node.y0px + getTopPadding(topGroove, node.y1px - node.y0px),
}
: {
x0: node.x0,
y0: node.y0px,
x1: node.x1,
y1: node.y1px,
};
x0: node.x0,
y0: node.y0px,
x1: node.x1,
y1: node.y1px,
};
};
}

Expand Down Expand Up @@ -232,11 +232,11 @@ export function shapeViewModel(

const rawChildNodes: Array<Part> = treemapLayout
? treemap(tree, treemapAreaAccessor, topGrooveAccessor(topGroove), grooveAccessor, {
x0: -width / 2,
y0: -height / 2,
width,
height,
})
x0: -width / 2,
y0: -height / 2,
width,
height,
})
: sunburst(tree, sunburstAreaAccessor, { x0: 0, y0: -1 }, clockwiseSectors, specialFirstInnermostSector);

const shownChildNodes = rawChildNodes.filter((n: Part) => {
Expand Down Expand Up @@ -331,10 +331,10 @@ export function shapeViewModel(
treemapLayout
? ({ x0, y0, x1, y1 }) => x0 <= x && x <= x1 && y0 <= y && y <= y1
: ({ x0, y0px, x1, y1px }) => {
const angleX = (Math.atan2(y, x) + TAU / 4 + TAU) % TAU;
const yPx = Math.sqrt(x * x + y * y);
return x0 <= angleX && angleX <= x1 && y0px <= yPx && yPx <= y1px;
},
const angleX = (Math.atan2(y, x) + TAU / 4 + TAU) % TAU;
const yPx = Math.sqrt(x * x + y * y);
return x0 <= angleX && angleX <= x1 && y0px <= yPx && yPx <= y1px;
},
);

// combined viewModel
Expand Down
20 changes: 10 additions & 10 deletions src/chart_types/xy_chart/annotations/line/dimensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ function computeYDomainLineAnnotationDimensions(

const annotationMarker: AnnotationMarker | undefined = marker
? {
icon: marker,
color: lineColor,
dimension: markerDimension,
position: markerPosition,
}
icon: marker,
color: lineColor,
dimension: markerDimension,
position: markerPosition,
}
: undefined;
const lineProp: AnnotationLineProps = {
anchor,
Expand Down Expand Up @@ -279,11 +279,11 @@ function computeXDomainLineAnnotationDimensions(

const annotationMarker: AnnotationMarker | undefined = marker
? {
icon: marker,
color: lineColor,
dimension: markerDimension,
position: markerPosition,
}
icon: marker,
color: lineColor,
dimension: markerDimension,
position: markerPosition,
}
: undefined;
const lineProp: AnnotationLineProps = {
anchor,
Expand Down
22 changes: 11 additions & 11 deletions src/chart_types/xy_chart/rendering/rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ export function getRadiusFn(data: DataSeriesDatum[], lineWidth: number, markSize
mark === null
? acc
: {
min: Math.min(acc.min, mark / 2),
max: Math.max(acc.max, mark / 2),
},
min: Math.min(acc.min, mark / 2),
max: Math.max(acc.max, mark / 2),
},
{ min: Infinity, max: -Infinity },
);
const adjustedMarkSizeRatio = Math.min(Math.max(markSizeRatio, 0), 100);
Expand Down Expand Up @@ -332,8 +332,8 @@ export function renderBars(
// only show displayValue for even bars if showOverlappingValue
const displayValueText = displayValueSettings && displayValueSettings.isAlternatingValueLabel
? barGeometries.length % 2 === 0
? formattedDisplayValue
: undefined
? formattedDisplayValue
: undefined
: formattedDisplayValue;

const computedDisplayValueWidth = bboxCalculator.compute(displayValueText || '', padding, fontSize, fontFamily)
Expand All @@ -344,12 +344,12 @@ export function renderBars(

const displayValue = displayValueSettings && displayValueSettings.showValueLabel
? {
text: displayValueText,
width: displayValueWidth,
height: fontSize,
hideClippedValue,
isValueContainedInElement: displayValueSettings.isValueContainedInElement,
}
text: displayValueText,
width: displayValueWidth,
height: fontSize,
hideClippedValue,
isValueContainedInElement: displayValueSettings.isValueContainedInElement,
}
: undefined;

const seriesIdentifier: XYChartSeriesIdentifier = {
Expand Down
6 changes: 3 additions & 3 deletions src/chart_types/xy_chart/state/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,9 @@ function renderGeometries(

const displayValueSettings = spec.displayValueSettings
? {
valueFormatter,
...spec.displayValueSettings,
}
valueFormatter,
...spec.displayValueSettings,
}
: undefined;

const renderedBars = renderBars(
Expand Down
10 changes: 5 additions & 5 deletions src/components/legend/legend_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ export class LegendListItem extends Component<LegendItemProps, LegendItemState>
handleColorClick = (changable: boolean): MouseEventHandler | undefined =>
changable
? (event) => {
event.stopPropagation();
this.toggleIsOpen();
}
event.stopPropagation();
this.toggleIsOpen();
}
: undefined;

toggleIsOpen = () => {
Expand Down Expand Up @@ -207,8 +207,8 @@ export class LegendListItem extends Component<LegendItemProps, LegendItemState>
const extra = getExtra(extraValues, item, totalItems);
const style = item.depth
? {
marginLeft: LEGEND_HIERARCHY_MARGIN * (item.depth ?? 0),
}
marginLeft: LEGEND_HIERARCHY_MARGIN * (item.depth ?? 0),
}
: undefined;
return (
<>
Expand Down
6 changes: 3 additions & 3 deletions src/scales/scale_continuous.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ export class ScaleContinuous implements Scale {
// This is forcing a return type of number[] but is really (number|Date)[]
return integersOnly
? (this.d3Scale as D3ScaleNonTime)
.ticks(ticks)
.filter((item: number) => typeof item === 'number' && item % 1 === 0)
.map((item: number) => parseInt(item.toFixed(0), 10))
.ticks(ticks)
.filter((item: number) => typeof item === 'number' && item % 1 === 0)
.map((item: number) => parseInt(item.toFixed(0), 10))
: (this.d3Scale as D3ScaleNonTime).ticks(ticks);
}

Expand Down
Loading

0 comments on commit e3ba904

Please sign in to comment.